From c93da86f83b5661cb771641153ac7e743351dd79 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 18 Jan 2021 21:06:58 +0100 Subject: [PATCH] [ticket/10824] Add missing imports and adjust json sanitizer imports This way the imports will also be a bit more explicit to the fact that this is only a json sanitizer. PHPBB3-10824 --- phpBB/phpbb/cache/service.php | 4 ++-- phpBB/phpbb/db/migration/data/v310/style_update_p1.php | 4 ++-- phpBB/phpbb/language/language_file_helper.php | 7 ++++--- phpBB/phpbb/version_helper.php | 3 ++- tests/json/sanitizer_test.php | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index acf343e194..bce0c8d6d8 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -13,7 +13,7 @@ namespace phpbb\cache; -use phpbb\json\sanitizer; +use phpbb\json\sanitizer as json_sanitizer; /** * Class for grabbing/handling cached entries @@ -357,7 +357,7 @@ class service { // Re-parse cfg file $json = file_get_contents($filename); - $parsed_array = sanitizer::decode($json); + $parsed_array = json_sanitizer::decode($json); $parsed_array['filetime'] = @filemtime($filename); $this->driver->put('_cfg_' . $style['style_path'], $parsed_array); diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php index fe49cd2176..be66dcd8e9 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v310; -use phpbb\json\sanitizer; +use phpbb\json\sanitizer as json_sanitizer; class style_update_p1 extends \phpbb\db\migration\migration { @@ -85,7 +85,7 @@ class style_update_p1 extends \phpbb\db\migration\migration else if (file_exists($fileinfo->getPathname() . '/composer.json')) { $json = file_get_contents($fileinfo->getPathname() . '/composer.json'); - $style_data = sanitizer::decode($json); + $style_data = json_sanitizer::decode($json); if (isset($style_data['extra']['phpbb-version']) && version_compare($style_data['extra']['phpbb-version'], '4.0.0-dev', '>=')) { // 4.x style diff --git a/phpBB/phpbb/language/language_file_helper.php b/phpBB/phpbb/language/language_file_helper.php index 3126ff5836..22ad51d81d 100644 --- a/phpBB/phpbb/language/language_file_helper.php +++ b/phpBB/phpbb/language/language_file_helper.php @@ -13,7 +13,8 @@ namespace phpbb\language; -use phpbb\json\sanitizer; +use DomainException; +use phpbb\json\sanitizer as json_sanitizer; use Symfony\Component\Finder\Finder; /** @@ -55,7 +56,7 @@ class language_file_helper foreach ($finder as $file) { $json = $file->getContents(); - $data = sanitizer::decode($json); + $data = json_sanitizer::decode($json); $available_languages[] = $this->get_language_data_from_json($data); } @@ -72,7 +73,7 @@ class language_file_helper public function get_language_data_from_composer_file(string $path): array { $json_data = file_get_contents($path); - return $this->get_language_data_from_json(sanitizer::decode($json_data)); + return $this->get_language_data_from_json(json_sanitizer::decode($json_data)); } /** diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index 7c6edbea95..61737865ea 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -14,6 +14,7 @@ namespace phpbb; use phpbb\exception\version_check_exception; +use phpbb\json\sanitizer as json_sanitizer; /** * Class to handle version checking and comparison @@ -390,7 +391,7 @@ class version_helper } // Sanitize any data we retrieve from a server - $info = json\sanitizer::decode($info); + $info = json_sanitizer::decode($info); if (empty($info['stable']) && empty($info['unstable'])) { diff --git a/tests/json/sanitizer_test.php b/tests/json/sanitizer_test.php index 7082d88590..267dcaf774 100644 --- a/tests/json/sanitizer_test.php +++ b/tests/json/sanitizer_test.php @@ -11,7 +11,7 @@ * */ -use phpbb\json\sanitizer; +use phpbb\json\sanitizer as json_sanitizer; class phpbb_json_sanitizer_test extends phpbb_test_case { @@ -30,6 +30,6 @@ class phpbb_json_sanitizer_test extends phpbb_test_case */ public function test_decode_data($input, $output) { - $this->assertEquals($output, sanitizer::decode($input)); + $this->assertEquals($output, json_sanitizer::decode($input)); } }