ZF-9162: baseUrl() view helper returns no path
Description
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.
Comments
Posted by John Kelly (postalservice14) on 2011-05-27T22:10:47.000+0000
I'm not able to replicate the issue with a test. The attached test case passes. Am I missing something?
Posted by H Hatfield (hhatfield) on 2011-07-30T23:23:42.000+0000
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:
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.