ZF-9162: baseUrl() view helper returns no path


Three use cases in a view script:

echo '


p>#1: ' . $this->baseUrl();

$front = Zend_Controller_Front::getInstance(); echo '


p>#2: ' . $front->getBaseUrl();

$baseUrlHelper = new Zend_View_Helper_BaseUrl(); echo '


p>#3: ' . $baseUrlHelper->getBaseUrl();

1 returns an empty string, #2 and #3 return the correct URL/path.

Changing method getBaseUrl() in class Zend_View_Helper_BaseUrl, line 83, from "if ($this->_baseUrl === null) { ..." to "if (!$this->_baseUrl) { ..." fixes the problem for me.


I'm not able to replicate the issue with a test. The attached test case passes. Am I missing something?

When I ran the provided test, both against trunk and 1.10.1, it passed.

The only way I can get the described behavior is with the following test:

    public function testZF9162()
        $baseUrl = 'http://foobar';
        $view = new Zend_View();
        $view->addBasePath(dirname(__FILE__) . '/_files');

        $this->assertEquals($baseUrl, $view->render('testBaseUrl.phtml'));

The difference here is calling ```` twice, once w/ the empty string and once with the actual base url AND having a call to $view->baseUrl() in between them. This causes the BaseUrl Helper to cache the base url.