From 6ea6d50ccb9607429486a01d3144c7d32322e1b5 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 30 Aug 2011 01:15:43 -0400 Subject: [feature/extension-manager] Don't cache the phpbb_root_path in the ext manager Otherwise the paths are incorrect from e.g. adm/ PHPBB3-10323 --- phpBB/includes/extension/finder.php | 2 ++ phpBB/includes/extension/manager.php | 14 ++++++++++---- tests/cron/provider_test.php | 2 +- tests/extension/finder_test.php | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php index ee08b0a82a..9a0727a50c 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/includes/extension/finder.php @@ -161,6 +161,8 @@ class phpbb_extension_finder */ public function directory($directory) { + $directory = preg_replace('#(?:^|/)\./#', '/', $directory); + if (strlen($directory) > 1 && $directory[strlen($directory) - 1] === '/') { $directory = substr($directory, 0, -1); diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index a6c8ebb3d0..ef714638c3 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -93,7 +93,7 @@ class phpbb_extension_manager */ public function get_extension_path($name) { - return $this->phpbb_root_path . 'ext/' . basename($name) . '/'; + return 'ext/' . basename($name) . '/'; } /** @@ -315,7 +315,13 @@ class phpbb_extension_manager */ public function all_configured() { - return $this->extensions; + $configured = array(); + foreach ($this->extensions as $name => $data) + { + $data['ext_path'] = $this->phpbb_root_path . $data['ext_path']; + $configured[$name] = $data; + } + return $configured; } /** @@ -331,7 +337,7 @@ class phpbb_extension_manager { if ($data['ext_active']) { - $enabled[$name] = $data['ext_path']; + $enabled[$name] = $this->phpbb_root_path . $data['ext_path']; } } return $enabled; @@ -350,7 +356,7 @@ class phpbb_extension_manager { if (!$data['ext_active']) { - $disabled[$name] = $data['ext_path']; + $disabled[$name] = $this->phpbb_root_path . $data['ext_path']; } } return $disabled; diff --git a/tests/cron/provider_test.php b/tests/cron/provider_test.php index 3a0545ffc6..662bb34c13 100644 --- a/tests/cron/provider_test.php +++ b/tests/cron/provider_test.php @@ -19,7 +19,7 @@ class phpbb_cron_provider_test extends PHPUnit_Framework_TestCase 'testext' => array( 'ext_name' => 'testext', 'ext_active' => true, - 'ext_path' => dirname(__FILE__) . '/ext/testext/' + 'ext_path' => 'ext/testext/' ), )); $this->provider = new phpbb_cron_provider($this->extension_manager); diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 8d7d38d4d8..9031e1cb47 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -23,12 +23,12 @@ class phpbb_extension_finder_test extends phpbb_test_case 'foo' => array( 'ext_name' => 'foo', 'ext_active' => '1', - 'ext_path' => dirname(__FILE__) . '/ext/foo/', + 'ext_path' => 'ext/foo/', ), 'bar' => array( 'ext_name' => 'bar', 'ext_active' => '1', - 'ext_path' => dirname(__FILE__) . '/ext/bar/', + 'ext_path' => 'ext/bar/', ), )); -- cgit v1.2.1