aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-09-09 17:28:56 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-09-09 17:28:56 -0500
commitf30b87519e9ead41525e1979cbce874e8a84e2b8 (patch)
treec21dc4ba2e8642e96e472df60518e55fd1be77e1 /phpBB
parent2146d0c36b1bec9dffba49e9727f8b493a0fb0f2 (diff)
downloadforums-f30b87519e9ead41525e1979cbce874e8a84e2b8.tar
forums-f30b87519e9ead41525e1979cbce874e8a84e2b8.tar.gz
forums-f30b87519e9ead41525e1979cbce874e8a84e2b8.tar.bz2
forums-f30b87519e9ead41525e1979cbce874e8a84e2b8.tar.xz
forums-f30b87519e9ead41525e1979cbce874e8a84e2b8.zip
[ticket/11832] Inject dependencies for phpbb_get_web_root_path (also moving)
Function moved from phpbb_get_web_root_path to filesystem::get_web_root_path PHPBB3-11832
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/config/services.yml2
-rw-r--r--phpBB/includes/functions.php49
-rw-r--r--phpBB/phpbb/filesystem.php69
4 files changed, 77 insertions, 45 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index a7b7db28ac..cbcd146832 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -47,7 +47,7 @@ if (!defined('PHPBB_INSTALLED'))
// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
- $phpbb_filesystem = new phpbb_filesystem();
+ $phpbb_filesystem = new phpbb_filesystem($phpbb_root_path);
$script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 2808e81337..01e470f87f 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -169,6 +169,8 @@ services:
filesystem:
class: phpbb_filesystem
+ arguments:
+ - %core.root_path%
groupposition.legend:
class: phpbb_groupposition_legend
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 7cc3e11129..844609e4e3 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,8 +7,6 @@
*
*/
-use Symfony\Component\HttpFoundation\Request;
-
/**
* @ignore
*/
@@ -2413,7 +2411,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
global $_SID, $_EXTRA_URL, $phpbb_hook;
global $phpbb_dispatcher;
- global $symfony_request, $phpbb_root_path;
+ global $symfony_request, $phpbb_root_path, $phpbb_container;
if ($params === '' || (is_array($params) && empty($params)))
{
@@ -2421,7 +2419,8 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
$params = false;
}
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request);
if ($corrected_path)
{
$url = substr($corrected_path . $url, strlen($phpbb_root_path));
@@ -5218,7 +5217,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request);
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output
@@ -5725,42 +5725,3 @@ function phpbb_create_symfony_request(phpbb_request $request)
$symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
return $symfony_request;
}
-
-/**
-* Get a relative root path from the current URL
-*
-* @param Request $symfony_request Symfony Request object
-*/
-function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '')
-{
- global $phpbb_container;
-
- static $path;
- if (null !== $path)
- {
- return $path;
- }
-
- $path_info = $symfony_request->getPathInfo();
- if ($path_info === '/')
- {
- $path = $phpbb_root_path;
- return $path;
- }
-
- $filesystem = $phpbb_container->get('filesystem');
- $path_info = $filesystem->clean_path($path_info);
-
- // Do not count / at start of path
- $corrections = substr_count(substr($path_info, 1), '/');
-
- // When URL Rewriting is enabled, app.php is optional. We have to
- // correct for it not being there
- if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false)
- {
- $corrections -= 1;
- }
-
- $path = $phpbb_root_path . str_repeat('../', $corrections);
- return $path;
-}
diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php
index 27cab48fb0..a85a254865 100644
--- a/phpBB/phpbb/filesystem.php
+++ b/phpBB/phpbb/filesystem.php
@@ -6,6 +6,9 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
+
+use Symfony\Component\HttpFoundation\Request;
+
/**
* @ignore
*/
@@ -20,6 +23,72 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_filesystem
{
+ /** @var string */
+ protected $phpbb_root_path;
+
+ /**
+ * Constructor
+ *
+ * @param string $phpbb_root_path
+ */
+ public function __construct($phpbb_root_path)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ }
+
+ /**
+ * Get the phpBB root path
+ *
+ * @return string
+ */
+ public function get_phpbb_root_path()
+ {
+ return $this->phpbb_root_path;
+ }
+
+ /**
+ * Get a relative root path from the current URL
+ *
+ * @param Request $symfony_request Symfony Request object
+ * @return string
+ */
+ function get_web_root_path(Request $symfony_request = null)
+ {
+ if ($symfony_request === null)
+ {
+ return '';
+ }
+
+ static $path;
+ if (null !== $path)
+ {
+ return $path;
+ }
+
+ $path_info = $symfony_request->getPathInfo();
+ if ($path_info === '/')
+ {
+ $path = $this->phpbb_root_path;
+ return $path;
+ }
+
+ $path_info = $this->clean_path($path_info);
+
+ // Do not count / at start of path
+ $corrections = substr_count(substr($path_info, 1), '/');
+
+ // When URL Rewriting is enabled, app.php is optional. We have to
+ // correct for it not being there
+ if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false)
+ {
+ $corrections -= 1;
+ }
+
+ $path = $this->phpbb_root_path . str_repeat('../', $corrections);
+
+ return $path;
+ }
+
/**
* Eliminates useless . and .. components from specified path.
*