aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2015-01-17 11:05:18 +0100
committerTristan Darricau <github@nicofuma.fr>2015-01-17 11:40:10 +0100
commit6842831d6baa59425ec83cc2ebbae377942824ce (patch)
tree991136c6fc7b063d5fabe64750c9e1f7db433ba8
parent0344e61b8cd5d3964bcfae147e2bebc8c74fa3be (diff)
downloadforums-6842831d6baa59425ec83cc2ebbae377942824ce.tar
forums-6842831d6baa59425ec83cc2ebbae377942824ce.tar.gz
forums-6842831d6baa59425ec83cc2ebbae377942824ce.tar.bz2
forums-6842831d6baa59425ec83cc2ebbae377942824ce.tar.xz
forums-6842831d6baa59425ec83cc2ebbae377942824ce.zip
[ticket/13513] Use paths relative to the phpBB root in the router
PHPBB3-13513
-rw-r--r--phpBB/phpbb/extension/manager.php17
-rw-r--r--phpBB/phpbb/routing/router.php14
-rw-r--r--tests/controller/common_helper_route.php2
-rw-r--r--tests/controller/controller_test.php2
-rw-r--r--tests/pagination/pagination_test.php2
5 files changed, 21 insertions, 16 deletions
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index 76f0e3558e..880973d5fb 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -464,15 +464,17 @@ class manager
* All enabled and disabled extensions are considered configured. A purged
* extension that is no longer in the database is not configured.
*
+ * @param bool $phpbb_relative Whether the path should be relative to phpbb root
+ *
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
- public function all_configured()
+ public function all_configured($phpbb_relative = true)
{
$configured = array();
foreach ($this->extensions as $name => $data)
{
- $data['ext_path'] = $this->phpbb_root_path . $data['ext_path'];
+ $data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
$configured[$name] = $data;
}
return $configured;
@@ -480,18 +482,19 @@ class manager
/**
* Retrieves all enabled extensions.
+ * @param bool $phpbb_relative Whether the path should be relative to phpbb root
*
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
- public function all_enabled()
+ public function all_enabled($phpbb_relative = true)
{
$enabled = array();
foreach ($this->extensions as $name => $data)
{
if ($data['ext_active'])
{
- $enabled[$name] = $this->phpbb_root_path . $data['ext_path'];
+ $enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
}
return $enabled;
@@ -500,17 +503,19 @@ class manager
/**
* Retrieves all disabled extensions.
*
+ * @param bool $phpbb_relative Whether the path should be relative to phpbb root
+ *
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
- public function all_disabled()
+ public function all_disabled($phpbb_relative = true)
{
$disabled = array();
foreach ($this->extensions as $name => $data)
{
if (!$data['ext_active'])
{
- $disabled[$name] = $this->phpbb_root_path . $data['ext_path'];
+ $disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
}
return $disabled;
diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php
index 1003708540..601d774129 100644
--- a/phpBB/phpbb/routing/router.php
+++ b/phpBB/phpbb/routing/router.php
@@ -106,25 +106,25 @@ class router implements RouterInterface
/**
* Find the list of routing files
*
- * @param array $paths Array of paths where to look for routing files.
+ * @param array $paths Array of paths where to look for routing files (they must be relative to the phpBB root path).
* @return router
*/
public function find_routing_files(array $paths)
{
- $this->routing_files = array($this->phpbb_root_path . 'config/' . $this->environment . '/routing/environment.yml');
+ $this->routing_files = array('config/' . $this->environment . '/routing/environment.yml');
foreach ($paths as $path)
{
- if (file_exists($path . 'config/' . $this->environment . '/routing/environment.yml'))
+ if (file_exists($this->phpbb_root_path . $path . 'config/' . $this->environment . '/routing/environment.yml'))
{
$this->routing_files[] = $path . 'config/' . $this->environment . '/routing/environment.yml';
}
- else if (!is_dir($path . 'config/' . $this->environment))
+ else if (!is_dir($this->phpbb_root_path . $path . 'config/' . $this->environment))
{
- if (file_exists($path . 'config/default/routing/environment.yml'))
+ if (file_exists($this->phpbb_root_path . $path . 'config/default/routing/environment.yml'))
{
$this->routing_files[] = $path . 'config/default/routing/environment.yml';
}
- else if (!is_dir($path . 'config/default/routing') && file_exists($path . 'config/routing.yml'))
+ else if (!is_dir($this->phpbb_root_path . $path . 'config/default/routing') && file_exists($this->phpbb_root_path . $path . 'config/routing.yml'))
{
$this->routing_files[] = $path . 'config/routing.yml';
}
@@ -164,7 +164,7 @@ class router implements RouterInterface
{
if ($this->route_collection == null || empty($this->routing_files))
{
- $this->find_routing_files($this->extension_manager->all_enabled())
+ $this->find_routing_files($this->extension_manager->all_enabled(false))
->find($this->phpbb_root_path);
}
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 19d40cf071..3f98d51f16 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -114,7 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
);
$this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
- $this->router->find_routing_files($this->extension_manager->all_enabled());
+ $this->router->find_routing_files($this->extension_manager->all_enabled(false));
$this->router->find(dirname(__FILE__) . '/');
// Set correct current phpBB root path
$this->root_path = $this->get_phpbb_root_path();
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 354a902831..86615fe4dc 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -41,7 +41,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
public function test_router_find_files()
{
$router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
- $router->find_routing_files($this->extension_manager->all_enabled());
+ $router->find_routing_files($this->extension_manager->all_enabled(false));
$routes = $router->find(__DIR__)->get_routes();
// This will need to be updated if any new routes are defined
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 1b9e8c751c..7d928d8820 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -39,7 +39,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
- $router->find_routing_files($manager->all_enabled());
+ $router->find_routing_files($manager->all_enabled(false));
$router->find(dirname(__FILE__) . '/');
$request = new phpbb_mock_request();