diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php index 27ed629595d7ca395687ff637c7eedd28a8e8bf7..efdd2d6f5f4f53f4f1b16b28403ef899eadc34b1 100644 --- a/lib/classes/Request.class.php +++ b/lib/classes/Request.class.php @@ -150,7 +150,7 @@ class Request implements ArrayAccess, IteratorAggregate * Return the filename of the currently executing script. * @return string */ - public static function script_name(): string + public static function scriptName(): string { return $_SERVER['SCRIPT_NAME']; } @@ -159,9 +159,9 @@ class Request implements ArrayAccess, IteratorAggregate * Returns the complete path info including duplicated slashes. * $_SERVER['PATH_INFO'] will remove them. */ - public static function path_info(): string + public static function pathInfo(): string { - $script_name = self::script_name(); + $script_name = self::scriptName(); $script_name = preg_quote($script_name, '#'); $script_name = str_replace('/', '/+', $script_name); diff --git a/lib/classes/restapi/Router.php b/lib/classes/restapi/Router.php index 7650919f7286295ce63a4c616b0f4aea54d0fd1c..232e9fe9d2eaea86040e4ef5cb5a4e09fbbb2d17 100644 --- a/lib/classes/restapi/Router.php +++ b/lib/classes/restapi/Router.php @@ -523,7 +523,7 @@ class Router private function normalizeDispatchURI($uri) { - return $uri ?? \Request::path_info(); + return $uri ?? \Request::pathInfo(); } private function normalizeRequestMethod($method) diff --git a/public/api.php b/public/api.php index 1376ae4cd56245f0a69ce611ca5233bc0c6bbff7..762c140b58784b6a3aa7dc9f74534a5d1665d0d9 100644 --- a/public/api.php +++ b/public/api.php @@ -45,7 +45,7 @@ namespace RESTAPI { // Initialize RESTAPI plugins \PluginEngine::getPlugins('RESTAPIPlugin'); - $uri = \Request::path_info(); + $uri = \Request::pathInfo(); // Check version if (defined('RESTAPI\\VERSION') && preg_match('~^/v(\d+)~i', $uri, $match)) { diff --git a/public/assets.php b/public/assets.php index 824f84c4102de9802e40a0b8b47ceaa54adc97fa..a0baa6dcd05df7746b815622d7b7040fa0d99d2d 100644 --- a/public/assets.php +++ b/public/assets.php @@ -15,7 +15,7 @@ require_once '../lib/bootstrap.php'; // Obtain request information -$uri = ltrim(Request::path_info(), '/'); +$uri = ltrim(Request::pathInfo(), '/'); list($type, $id) = explode('/', $uri, 2); // Setup response diff --git a/public/dispatch.php b/public/dispatch.php index 3bd9291cb20d5438a1a5e0a426e93b4070479c84..68d03996bef498b5ca5dd7a91d5eaf3615ca023b 100644 --- a/public/dispatch.php +++ b/public/dispatch.php @@ -22,4 +22,4 @@ require '../lib/bootstrap.php'; URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']); $dispatcher = app(\Trails_Dispatcher::class); -$dispatcher->dispatch(Request::path_info()); +$dispatcher->dispatch(Request::pathInfo()); diff --git a/public/install.php b/public/install.php index c10f928f46affb7bd8f8fc3aee7a2a8d4db35d73..52f4bf01a52bc9646ac659304b33e12b769590ab 100644 --- a/public/install.php +++ b/public/install.php @@ -55,7 +55,7 @@ if (!function_exists('_')) { $GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); # get plugin class from request -$dispatch_to = ltrim(Request::path_info(), '/'); +$dispatch_to = ltrim(Request::pathInfo(), '/'); $dispatcher = new Trails_Dispatcher( '../app', $_SERVER['SCRIPT_NAME'], 'admin/install'); $dispatcher->dispatch("admin/install/{$dispatch_to}"); diff --git a/public/plugins.php b/public/plugins.php index 368113dc9e33432e4aa3649f6e701dfb8d30eacc..99373a053fd58691eb6e4e2bf5dff09b3f1ba18b 100644 --- a/public/plugins.php +++ b/public/plugins.php @@ -27,7 +27,7 @@ try { require_once 'lib/seminar_open.php'; // get plugin class from request - $dispatch_to = Request::path_info(); + $dispatch_to = Request::pathInfo(); list($plugin_class, $unconsumed) = PluginEngine::routeRequest($dispatch_to); // handle legacy forum plugin URLs diff --git a/public/web_migrate.php b/public/web_migrate.php index 02eeb956e080f63c5eee8ef5618d891db2b8cd7f..79fba05449e67548b81baeb30790543ae27fe9fc 100644 --- a/public/web_migrate.php +++ b/public/web_migrate.php @@ -34,7 +34,7 @@ $_language_path = init_i18n($_SESSION['_language']); $GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); # get plugin class from request -$dispatch_to = Request::path_info() ?: ''; +$dispatch_to = Request::pathInfo() ?: ''; $dispatcher = app(\Trails_Dispatcher::class); $dispatcher->trails_uri = $_SERVER['SCRIPT_NAME']; diff --git a/tests/unit/lib/classes/RequestTest.php b/tests/unit/lib/classes/RequestTest.php index 00351968839509467c0286f48a5c7b2aa8b05add..dd1adc9bc2897392ba12728849a7f89999eaea64 100644 --- a/tests/unit/lib/classes/RequestTest.php +++ b/tests/unit/lib/classes/RequestTest.php @@ -112,20 +112,20 @@ class RequestTest extends \Codeception\Test\Unit public function testScriptName(): void { $this->setScriptName('/index.php'); - $this->assertEquals('/index.php', Request::script_name()); + $this->assertEquals('/index.php', Request::scriptName()); } /** * @depends testPath * @depends testScriptName - * @covers Request::path_info + * @covers Request::pathInfo * @dataProvider PathProvider */ public function testPathInfo(string $request_uri, string $script_name, string $expected): void { $this->setScriptName($script_name); $this->setRequestUri($request_uri); - $this->assertEquals($expected, Request::path_info()); + $this->assertEquals($expected, Request::pathInfo()); } /**