diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 4e5968fed..976b2e8af 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -126,6 +126,9 @@ abstract class Presenter extends Control implements Application\IPresenter /** @var ITemplateFactory */ private $templateFactory; + /** @var Nette\Http\Url */ + private $refUrlCache; + public function __construct() { @@ -973,9 +976,9 @@ protected function createRequest($component, $destination, array $args, $mode) } // CONSTRUCT URL - static $refUrl; + $refUrl = $this->refUrlCache; if ($refUrl === NULL) { - $refUrl = new Http\Url($this->httpRequest->getUrl()); + $this->refUrlCache = $refUrl = new Http\Url($this->httpRequest->getUrl()); $refUrl->setPath($this->httpRequest->getUrl()->getScriptPath()); } if (!$this->router) { diff --git a/tests/Application/Presenter.twoDomains.phpt b/tests/Application/Presenter.twoDomains.phpt new file mode 100644 index 000000000..badb81b53 --- /dev/null +++ b/tests/Application/Presenter.twoDomains.phpt @@ -0,0 +1,56 @@ +setScriptPath('/index.php'); + + $presenter = new TestPresenter; + $presenter->injectPrimary( + NULL, + new MockPresenterFactory, + new Application\Routers\SimpleRouter, + new Http\Request($url), + new Http\Response + ); + + $request = new Application\Request('Test', Http\Request::GET, []); + $presenter->run($request); + + Assert::same( 'http://' . $domain . '/index.php?action=default&presenter=Test', $presenter->link('//this') ); +} + +testLink('first.localhost'); +testLink('second.localhost');