diff --git a/src/Control/Middleware/FlushMiddleware.php b/src/Control/Middleware/FlushMiddleware.php index e3bd61fbebb..98b49423b12 100644 --- a/src/Control/Middleware/FlushMiddleware.php +++ b/src/Control/Middleware/FlushMiddleware.php @@ -2,10 +2,12 @@ namespace SilverStripe\Control\Middleware; -use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; +use SilverStripe\Core\BaseKernel; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Flushable; +use SilverStripe\Core\Injector\Injector; +use SilverStripe\Core\Kernel; /** * Triggers a call to flush() on all implementors of Flushable. @@ -14,7 +16,9 @@ class FlushMiddleware implements HTTPMiddleware { public function process(HTTPRequest $request, callable $delegate) { - if (Director::isManifestFlushed()) { + /** @var BaseKernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + if ((method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) { // Disable cache when flushing HTTPCacheControlMiddleware::singleton()->disableCache(true); diff --git a/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php b/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php index 6f189286edc..f2b62d0c267 100644 --- a/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php +++ b/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php @@ -2,10 +2,10 @@ namespace SilverStripe\Control\Middleware\URLSpecialsMiddleware; +use SilverStripe\Core\BaseKernel; use SilverStripe\Core\Kernel; use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Startup\ScheduledFlushDiscoverer; -use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; /** @@ -30,11 +30,12 @@ public function scheduleFlush(HTTPRequest $request) { $flush = array_key_exists('flush', $request->getVars() ?? []) || ($request->getURL() === 'dev/build'); - if (!$flush || Director::isManifestFlushed()) { + /** @var BaseKernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + if (!$flush || (method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) { return false; } - $kernel = Injector::inst()->get(Kernel::class); ScheduledFlushDiscoverer::scheduleFlush($kernel); return true; diff --git a/src/Core/BaseKernel.php b/src/Core/BaseKernel.php index ee3370d54ad..d2d66e47ccf 100644 --- a/src/Core/BaseKernel.php +++ b/src/Core/BaseKernel.php @@ -259,12 +259,9 @@ protected function bootErrorHandling() * Get the environment type * * @return string - * - * @deprecated 4.12.0 Use Director::get_environment_type() instead */ public function getEnvironment() { - Deprecation::notice('4.12.0', 'Use Director::get_environment_type() instead'); // Check set if ($this->enviroment) { return $this->enviroment; diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index 5bd17cda6d0..29afa9038b9 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -179,7 +179,7 @@ public static function get_enabled() // noop } - private static function get_is_enabled(): bool + public static function get_is_enabled(): bool { if (!Director::isDev()) { return false; diff --git a/src/ORM/Connect/DBSchemaManager.php b/src/ORM/Connect/DBSchemaManager.php index 698f17cd52c..6bfee6b03b7 100644 --- a/src/ORM/Connect/DBSchemaManager.php +++ b/src/ORM/Connect/DBSchemaManager.php @@ -60,12 +60,9 @@ abstract class DBSchemaManager /** * @param string $table * @param string $class - * - * @deprecated 4.0.1 Will be removed without equivalent functionality */ public static function showTableNameWarning($table, $class) { - Deprecation::notice('4.0.1', 'Will be removed without equivalent functionality'); static::$table_name_warnings[$table] = $class; } diff --git a/tests/php/Control/DirectorTest.php b/tests/php/Control/DirectorTest.php index 05e24046bd9..bb797f7d4bf 100644 --- a/tests/php/Control/DirectorTest.php +++ b/tests/php/Control/DirectorTest.php @@ -16,6 +16,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Environment; use SilverStripe\Core\Kernel; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; /** @@ -856,6 +857,9 @@ public function testTestIgnoresHashes() public function testRequestFilterInDirectorTest() { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $filter = new DirectorTest\TestRequestFilter; $processor = new RequestProcessor([$filter]); diff --git a/tests/php/Control/HTTPRequestTest.php b/tests/php/Control/HTTPRequestTest.php index cf0acc0ca32..15d750775d2 100644 --- a/tests/php/Control/HTTPRequestTest.php +++ b/tests/php/Control/HTTPRequestTest.php @@ -6,6 +6,7 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\Middleware\TrustedProxyMiddleware; use SilverStripe\Control\Session; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; class HTTPRequestTest extends SapphireTest @@ -155,12 +156,18 @@ public function detectMethodDataProvider() */ public function testDetectMethod($realMethod, $post, $expected) { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $actual = HTTPRequest::detect_method($realMethod, $post); $this->assertEquals($expected, $actual); } public function testBadDetectMethod() { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $this->expectException(\InvalidArgumentException::class); HTTPRequest::detect_method('POST', ['_method' => 'Boom']); } diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index ed601871404..016862d3ae3 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -16,6 +16,8 @@ class DeprecationTest extends SapphireTest private $oldHandler = null; + private bool $noticesWereEnabled = false; + protected function setup(): void { // Use custom error handler for two reasons: @@ -23,6 +25,7 @@ protected function setup(): void // - Allow the use of expectDeprecation(), which doesn't work with E_USER_DEPRECATION by default // https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210 parent::setup(); + $this->noticesWereEnabled = Deprecation::get_is_enabled(); $this->oldHandler = set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { if ($errno === E_USER_DEPRECATED) { if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) { @@ -42,7 +45,9 @@ protected function setup(): void protected function tearDown(): void { - Deprecation::disable(); + if (!$this->noticesWereEnabled) { + Deprecation::disable(); + } set_error_handler($this->oldHandler); $this->oldHandler = null; parent::tearDown(); diff --git a/tests/php/ORM/SQLSelectTest.php b/tests/php/ORM/SQLSelectTest.php index f3618ebe09a..f58d538e2e3 100755 --- a/tests/php/ORM/SQLSelectTest.php +++ b/tests/php/ORM/SQLSelectTest.php @@ -24,18 +24,6 @@ class SQLSelectTest extends SapphireTest protected $oldDeprecation = null; - protected function setUp(): void - { - parent::setUp(); - $this->oldDeprecation = Deprecation::dump_settings(); - } - - protected function tearDown(): void - { - Deprecation::restore_settings($this->oldDeprecation); - parent::tearDown(); - } - public function testCount() { diff --git a/tests/php/ORM/TransactionTest.php b/tests/php/ORM/TransactionTest.php index 8c524e78c6d..8ac60e5b510 100644 --- a/tests/php/ORM/TransactionTest.php +++ b/tests/php/ORM/TransactionTest.php @@ -20,18 +20,6 @@ class TransactionTest extends SapphireTest private static $originalVersionInfo; - protected function setUp(): void - { - parent::setUp(); - self::$originalVersionInfo = Deprecation::dump_settings(); - } - - protected function tearDown(): void - { - Deprecation::restore_settings(self::$originalVersionInfo); - parent::tearDown(); - } - public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/php/View/ArrayDataTest.php b/tests/php/View/ArrayDataTest.php index b90258f7947..c7c7599b6b9 100644 --- a/tests/php/View/ArrayDataTest.php +++ b/tests/php/View/ArrayDataTest.php @@ -67,9 +67,6 @@ public function testSetField() public function testGetArray() { - $originalDeprecation = Deprecation::dump_settings(); - Deprecation::notification_version('2.4'); - $array = [ 'Foo' => 'Foo', 'Bar' => 'Bar', @@ -79,8 +76,6 @@ public function testGetArray() $arrayData = new ArrayData($array); $this->assertEquals($arrayData->toMap(), $array); - - Deprecation::restore_settings($originalDeprecation); } public function testArrayToObject()