From cb3eb84665db10e6fe55e11e694d39e742f313a4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 16:45:53 +0200 Subject: [ticket/13034] Fix the route generated for the frontend not in the phpbb root PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index dd89d0504a..931a489535 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -119,27 +119,23 @@ class helper $anchor = '#' . $params['#']; unset($params['#']); } - $url_generator = new UrlGenerator($this->route_collection, new RequestContext()); - $route_url = $url_generator->generate($route, $params); - if (strpos($route_url, '/') === 0) - { - $route_url = substr($route_url, 1); - } + $context = new RequestContext(); + $context->fromRequest($this->symfony_request); + + $script_name = $this->symfony_request->getScriptName(); + $page_name = substr($script_name, -1, 1) == '/' ? '' : basename($script_name); + $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); + + $url_generator = new UrlGenerator($this->route_collection, $context); + $route_url = $url_generator->generate($route, $params); if ($is_amp) { $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url); } - // If enable_mod_rewrite is false, we need to include app.php - $route_prefix = $this->phpbb_root_path; - if (empty($this->config['enable_mod_rewrite'])) - { - $route_prefix .= 'app.' . $this->php_ext . '/'; - } - - return append_sid($route_prefix . $route_url . $anchor, false, $is_amp, $session_id); + return append_sid($route_url . $anchor, false, $is_amp, $session_id, true); } /** -- cgit v1.2.1 From b9e7ed004c5830ce2a965702e6c8dc570291cf9b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 14 Sep 2014 23:41:15 +0200 Subject: [ticket/13034] Use utf8_basename PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 931a489535..6ad6dd1e24 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -124,7 +124,7 @@ class helper $context->fromRequest($this->symfony_request); $script_name = $this->symfony_request->getScriptName(); - $page_name = substr($script_name, -1, 1) == '/' ? '' : basename($script_name); + $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); $url_generator = new UrlGenerator($this->route_collection, $context); -- cgit v1.2.1 From 06f42f433bfb43b43d147d78bd04a35b7529cde4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 15 Sep 2014 20:25:20 +0200 Subject: [ticket/13034] Add comment PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 6ad6dd1e24..afa3c4dfa9 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -125,6 +125,8 @@ class helper $script_name = $this->symfony_request->getScriptName(); $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); + + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); $url_generator = new UrlGenerator($this->route_collection, $context); -- cgit v1.2.1 From 68ad7685bc12050cf6779d41f6ac36e8fe1a98e1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 15 Sep 2014 23:47:05 +0200 Subject: [ticket/13034] Update the base url to move to the root dir PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index afa3c4dfa9..e5e54fac00 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -43,6 +43,11 @@ class helper /* @var \phpbb\symfony_request */ protected $symfony_request; + /** + * @var \phpbb\filesystem The filesystem object + */ + protected $filesystem; + /** * phpBB root path * @var string @@ -64,15 +69,17 @@ class helper * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object + * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; + $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); @@ -126,8 +133,17 @@ class helper $script_name = $this->symfony_request->getScriptName(); $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); + $base_url = $context->getBaseUrl(); + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. - $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); + $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url); + + // We need to update the base url to move to the directory of the app.php file. + $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); + + $base_url = $this->filesystem->clean_path($base_url); + + $context->setBaseUrl($base_url); $url_generator = new UrlGenerator($this->route_collection, $context); $route_url = $url_generator->generate($route, $params); -- cgit v1.2.1