diff --git a/src/Core/Convert.php b/src/Core/Convert.php index 3e8743bcf84..3db7472a28f 100644 --- a/src/Core/Convert.php +++ b/src/Core/Convert.php @@ -232,9 +232,11 @@ public static function xml2raw($val) * @param SimpleXMLElement $xml * * @return mixed + * @deprecated 4.11.0 Will be removed without equivalent functionality */ protected static function recursiveXMLToArray($xml) { + Deprecation::notice('4.11.0', 'Will be removed without equivalent functionality'); $x = null; if ($xml instanceof SimpleXMLElement) { $attributes = $xml->attributes(); diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index a0015d191d3..4f1922b1f87 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -141,16 +141,23 @@ public static function outputNotices(): void if (!self::isEnabled()) { return; } + $outputMessages = []; // using a while loop with array_shift() to ensure that self::$userErrorMessageBuffer will have // have values removed from it before calling user_error() while (count(self::$userErrorMessageBuffer)) { $arr = array_shift(self::$userErrorMessageBuffer); $message = $arr['message']; + // often the same deprecation message appears dozens of times, which isn't helpful + // only need to show a single instance of each message + if (in_array($message, $outputMessages)) { + continue; + } $calledInsideWithNoReplacement = $arr['calledInsideWithNoReplacement']; if ($calledInsideWithNoReplacement && !self::$showNoReplacementNotices) { continue; } user_error($message, E_USER_DEPRECATED); + $outputMessages[] = $message; } } diff --git a/src/Dev/State/FixtureTestState.php b/src/Dev/State/FixtureTestState.php index 13312531d42..48731ca6587 100644 --- a/src/Dev/State/FixtureTestState.php +++ b/src/Dev/State/FixtureTestState.php @@ -215,9 +215,10 @@ protected function resolveFixturePath($fixtureFilePath, SapphireTest $test) */ protected function getTestAbsolutePath(SapphireTest $test) { - $filename = ClassLoader::inst()->getItemPath(get_class($test)); + $class = get_class($test); + $filename = ClassLoader::inst()->getItemPath($class); if (!$filename) { - throw new LogicException('getItemPath returned null for ' . static::class + throw new LogicException('getItemPath returned null for ' . $class . '. Try adding flush=1 to the test run.'); } return dirname($filename ?? ''); diff --git a/src/ORM/RelatedData/StandardRelatedDataService.php b/src/ORM/RelatedData/StandardRelatedDataService.php index 2c3eab624f0..04501fc2334 100644 --- a/src/ORM/RelatedData/StandardRelatedDataService.php +++ b/src/ORM/RelatedData/StandardRelatedDataService.php @@ -162,7 +162,7 @@ private function findTableNameContainingComponentIDField(string $class, string $ $tableName = $this->dataObjectSchema->tableName($candidateClass); break; } - $candidateClass = get_parent_class($class ?? ''); + $candidateClass = get_parent_class($candidateClass ?? ''); } return $tableName; } diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index 34965546a64..db54479839c 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -548,9 +548,10 @@ protected function getFileListForModule(Module $module) */ public function collectFromCode($content, $fileName, Module $module) { - // Get namespace either from $fileName or $module fallback + // Get "namespace" either from $fileName or $module fallback $namespace = $fileName ? basename($fileName) : $module->getName(); + $usedFQCNs = []; $entities = []; $tokens = token_get_all("markTestSkipped('Test calls deprecated code'); + } /** @var LoggerInterface $logger */ $logger = $this->createMock(LoggerInterface::class); diff --git a/tests/php/Security/SecurityDefaultAdminTest.php b/tests/php/Security/SecurityDefaultAdminTest.php index ec691936b23..082e7895b90 100644 --- a/tests/php/Security/SecurityDefaultAdminTest.php +++ b/tests/php/Security/SecurityDefaultAdminTest.php @@ -7,6 +7,7 @@ use SilverStripe\Security\PasswordEncryptor; use SilverStripe\Security\Permission; use SilverStripe\Security\DefaultAdminService; +use SilverStripe\Security\Security; class SecurityDefaultAdminTest extends SapphireTest { @@ -35,6 +36,7 @@ protected function setUp(): void $this->defaultUsername = null; $this->defaultPassword = null; } + Security::config()->set('password_encryption_algorithm', 'blowfish'); DefaultAdminService::setDefaultAdmin('admin', 'password'); Permission::reset(); } diff --git a/tests/php/View/RequirementsTest.php b/tests/php/View/RequirementsTest.php index be8c02de0b8..d4569331e20 100644 --- a/tests/php/View/RequirementsTest.php +++ b/tests/php/View/RequirementsTest.php @@ -14,6 +14,7 @@ use SilverStripe\Core\Manifest\ResourceURLGenerator; use SilverStripe\Control\SimpleResourceURLGenerator; use SilverStripe\Core\Config\Config; +use SilverStripe\Dev\Deprecation; use SilverStripe\View\SSViewer; use SilverStripe\View\ThemeResourceLoader; diff --git a/tests/php/i18n/i18nTextCollectorTest.php b/tests/php/i18n/i18nTextCollectorTest.php index c79bdddaa3a..df33ced4706 100644 --- a/tests/php/i18n/i18nTextCollectorTest.php +++ b/tests/php/i18n/i18nTextCollectorTest.php @@ -348,6 +348,64 @@ public function getMagicConstantStringFromSelf() ); } + public function testCollectFromClassSyntax() + { + $c = i18nTextCollector::create(); + $mymodule = ModuleLoader::inst()->getManifest()->getModule('i18ntestmodule'); + $php = <<assertEquals( + [ + 'SilverStripe\\Versioned\\Versioned.OTHER_NAMESPACE' => "New Lines", + 'SilverStripe\\Framework\\Core\\SameNamespaceClass.SAME_NAMESPACE' => 'Slash=\\, Quote=\'', + 'Some\\Space\\MyClass.ALIAS_CLASS' => 'Slash=\\, Quote="', + 'NoNamespaceClass.NO_NAMESPACE' => 'Self Class', + ], + $c->collectFromCode($php, null, $mymodule) + ); + } public function testNewlinesInEntityValues() {