From 5f5019183320929d16059efba515ae922ffc8dbd Mon Sep 17 00:00:00 2001 From: Christian Schnegelberger Date: Thu, 25 Sep 2025 10:23:11 +0200 Subject: [PATCH 1/2] Remove function validateSearchSynonymsFile and validateSearchIgnoreWordsFile --- .../Validator/FileValidator.php | 97 ------------------- 1 file changed, 97 deletions(-) diff --git a/src/Phpbb/TranslationValidator/Validator/FileValidator.php b/src/Phpbb/TranslationValidator/Validator/FileValidator.php index 89d3ba4..5bec8d0 100644 --- a/src/Phpbb/TranslationValidator/Validator/FileValidator.php +++ b/src/Phpbb/TranslationValidator/Validator/FileValidator.php @@ -252,14 +252,6 @@ public function validate($sourceFile, $originFile) { $this->validateHelpFile($sourceFile, $originFile); } - else if ($originFile == $this->originLanguagePath . 'search_synonyms.php') - { - $this->validateSearchSynonymsFile($originFile); - } - else if ($originFile == $this->originLanguagePath . 'search_ignore_words.php') - { - $this->validateSearchIgnoreWordsFile($originFile); - } else if (substr($originFile, -4) === '.php') { $this->validateLangFile($sourceFile, $originFile); @@ -589,95 +581,6 @@ public function validateHelpFile($sourceFile, $originFile) } } - /** - * Validates the search_synonyms.php file - * - * Files must only contain the variable $synonyms. - * This variable must be an array of string => string entries. - * - * @todo Check for template vars and html - * - * @param string $originFile File to validate - * @return null - */ - public function validateSearchSynonymsFile($originFile) - { - $originFilePath = $this->originPath . '/' . $originFile; - - if (!$this->safeMode) - { - /** @var $synonyms */ - include($originFilePath); - - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 3 || !isset($defined_variables['synonyms']) || gettype($defined_variables['synonyms']) != 'array') - { - $this->output->addMessage(Output::FATAL, 'Must only contain the synonyms-array', $originFile); - return; - } - } - - else - { - /** @var $synonyms */ - $synonyms = ValidatorRunner::langParser($originFilePath); - $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check synonym variables.', $originFile); - } - - foreach ($synonyms as $synonym1 => $synonym2) - { - if (gettype($synonym1) != 'string' || gettype($synonym2) != 'string') - { - $this->output->addMessage(Output::FATAL, 'Must only contain entries of type string => string: ' . serialize($synonym1) . ' => ' . serialize($synonym2), $originFile); - } - } - } - - /** - * Validates the search_ignore_words.php file - * - * Files must only contain the variable $words. - * This variable must be an array of string entries. - * - * @todo Check for template vars and html - * - * @param string $originFile File to validate - * @return null - */ - public function validateSearchIgnoreWordsFile($originFile) - { - $originFilePath = $this->originPath . '/' . $originFile; - - if (!$this->safeMode) - { - /** @var $words */ - include($originFilePath); - - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 3 || !isset($defined_variables['words']) || gettype($defined_variables['words']) != 'array') - { - $this->output->addMessage(Output::FATAL, 'Must only contain the words-array', $originFile); - return; - } - } - - else - { - /** @var $words */ - $words = ValidatorRunner::langParser($originFilePath); - $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check word variables.', $originFile); - } - - foreach ($words as $word) - { - if (gettype($word) != 'string') - { - //@todo use $i - $this->output->addMessage(Output::FATAL, 'Must only contain entries of type string: ' . serialize($word), $originFile); - } - } - } - /** * Validates the LICENSE file * From abc0d84ae4833604bd99a1c853ab9205d619d8a5 Mon Sep 17 00:00:00 2001 From: Christian Schnegelberger Date: Thu, 25 Sep 2025 10:32:01 +0200 Subject: [PATCH 2/2] Remove tests for search_ignore_words and search_synonyms --- tests/FileValidator/ValidateSearchTest.php | 72 ------------------- .../additional_variable.php | 9 --- .../search_ignore_words/invalid_word.php | 6 -- .../search_ignore_words/invalid_words.php | 3 - .../origin/search_ignore_words/no_words.php | 5 -- .../origin/search_ignore_words/valid.php | 5 -- .../search_synonyms/additional_variable.php | 9 --- .../search_synonyms/invalid_synonym.php | 8 --- .../search_synonyms/invalid_synonyms.php | 3 - .../origin/search_synonyms/no_synonyms.php | 5 -- .../fixtures/origin/search_synonyms/valid.php | 5 -- 11 files changed, 130 deletions(-) delete mode 100644 tests/FileValidator/ValidateSearchTest.php delete mode 100644 tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php delete mode 100644 tests/FileValidator/fixtures/origin/search_ignore_words/invalid_word.php delete mode 100644 tests/FileValidator/fixtures/origin/search_ignore_words/invalid_words.php delete mode 100644 tests/FileValidator/fixtures/origin/search_ignore_words/no_words.php delete mode 100644 tests/FileValidator/fixtures/origin/search_ignore_words/valid.php delete mode 100644 tests/FileValidator/fixtures/origin/search_synonyms/additional_variable.php delete mode 100644 tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php delete mode 100644 tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php delete mode 100644 tests/FileValidator/fixtures/origin/search_synonyms/no_synonyms.php delete mode 100644 tests/FileValidator/fixtures/origin/search_synonyms/valid.php diff --git a/tests/FileValidator/ValidateSearchTest.php b/tests/FileValidator/ValidateSearchTest.php deleted file mode 100644 index 2a1eab8..0000000 --- a/tests/FileValidator/ValidateSearchTest.php +++ /dev/null @@ -1,72 +0,0 @@ - string: s:3:"bar"; => i:1;-search_synonyms/invalid_synonym.php-', - Output::FATAL . '-Must only contain entries of type string => string: i:0; => s:4:"this";-search_synonyms/invalid_synonym.php-', - Output::FATAL . '-Must only contain entries of type string => string: i:1; => i:2;-search_synonyms/invalid_synonym.php-', - )), - ); - } - - /** - * @dataProvider validateSearchSynonymsFileData - */ - public function testValidateSearchSynonymsFile($file, $expected) - { - $this->validator->validateSearchSynonymsFile($file); - $this->assertOutputMessages($expected); - } - - public function validateSearchIgnoreWordsFileData() - { - return array( - array('search_ignore_words/valid.php', array()), - array('search_ignore_words/no_words.php', array( - Output::FATAL . '-Must only contain the words-array-search_ignore_words/no_words.php-', - )), - array('search_ignore_words/invalid_words.php', array( - Output::FATAL . '-Must only contain the words-array-search_ignore_words/invalid_words.php-', - )), - array('search_ignore_words/additional_variable.php', array( - Output::FATAL . '-Must only contain the words-array-search_ignore_words/additional_variable.php-', - )), - array('search_ignore_words/invalid_word.php', array( - Output::FATAL . '-Must only contain entries of type string: i:0;-search_ignore_words/invalid_word.php-', - )), - ); - } - - /** - * @dataProvider validateSearchIgnoreWordsFileData - */ - public function testValidateSearchIgnoreWordsFile($file, $expected) - { - $this->validator->validateSearchIgnoreWordsFile($file); - $this->assertOutputMessages($expected); - } -} diff --git a/tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php b/tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php deleted file mode 100644 index 67ab127..0000000 --- a/tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php +++ /dev/null @@ -1,9 +0,0 @@ - 'Abfluss', -); diff --git a/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php b/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php deleted file mode 100644 index a0aea96..0000000 --- a/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php +++ /dev/null @@ -1,8 +0,0 @@ - 'valid', - 'bar' => 1, - 0 => 'this', - 1 => 2, -); diff --git a/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php b/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php deleted file mode 100644 index ef357b0..0000000 --- a/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php +++ /dev/null @@ -1,3 +0,0 @@ - 'Abfluss', -); diff --git a/tests/FileValidator/fixtures/origin/search_synonyms/valid.php b/tests/FileValidator/fixtures/origin/search_synonyms/valid.php deleted file mode 100644 index 6d33b81..0000000 --- a/tests/FileValidator/fixtures/origin/search_synonyms/valid.php +++ /dev/null @@ -1,5 +0,0 @@ - 'Abfluss', -);