Skip to content

Commit

Permalink
Merge branch '3.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Apr 6, 2015
2 parents a11994d + 53ed8a3 commit 201f5cb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
6 changes: 6 additions & 0 deletions phpBB/phpbb/controller/helper.php
Expand Up @@ -145,6 +145,12 @@ public function route($route, array $params = array(), $is_amp = true, $session_

$base_url = $context->getBaseUrl();

// Append page name if base URL does not contain it
if (!empty($page_name) && strpos($base_url, '/' . $page_name) === false)
{
$base_url .= '/' . $page_name;
}

// If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
$base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);

Expand Down
7 changes: 6 additions & 1 deletion tests/controller/common_helper_route.php
Expand Up @@ -47,6 +47,11 @@ protected function get_uri()
return '/app.php';
}

protected function get_base_uri()
{
return $this->get_uri();
}

protected function get_script_name()
{
return 'app.php';
Expand All @@ -62,7 +67,7 @@ protected function generate_route_objects()
$this->request = new phpbb_mock_request();
$this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
$this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
$this->request->overwrite('REQUEST_URI', $this->get_uri(), \phpbb\request\request_interface::SERVER);
$this->request->overwrite('REQUEST_URI', $this->get_base_uri(), \phpbb\request\request_interface::SERVER);
$this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
$this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);

Expand Down
43 changes: 43 additions & 0 deletions tests/controller/helper_route_slash_test.php
@@ -0,0 +1,43 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/common_helper_route.php';

class phpbb_controller_helper_route_slash_test extends phpbb_controller_common_helper_route
{
protected function get_phpbb_root_path()
{
return './../';
}

protected function get_uri()
{
return '/phpBB3/app.php';
}

protected function get_base_uri()
{
return '/phpBB3';
}

protected function get_script_name()
{
return 'app.php';
}

protected function path_to_app()
{
return 'phpBB3/';
}
}

0 comments on commit 201f5cb

Please sign in to comment.