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

Issue Type: Bug Created: 2010-02-12T15:30:25.000+0000 Last Updated: 2011-07-30T23:28:25.000+0000 Status: Open Fix version(s): Reporter: Alexander Barton (alexbarton) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

Related issues: Attachments: - ZF9162-unit-test.patch


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.


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:

<pre class="highlight">
    public function testZF9162()
        $baseUrl = '<a href="http://foobar">http://foobar</a>';
        $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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.