From 0d374eb94f7339a74f8eeb392e3f907dae66cad3 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 10 Mar 2023 12:21:27 +1300 Subject: [PATCH 1/5] MNT Update development dependencies --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ce3daf5..ed2fa54 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", "psr/simple-cache": "^1.0", - "silverstripe/framework": "^4.12" + "silverstripe/framework": "4.13.x-dev" }, "require-dev": { "phpunit/phpunit": "^9.5", @@ -21,4 +21,4 @@ "SilverStripe\\Config\\Tests\\": "tests/" } } -} +} \ No newline at end of file From fca86224e2029df4978d89cf26686d8fe268b10f Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 10 Mar 2023 15:55:36 +1300 Subject: [PATCH 2/5] MNT Update release dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ed2fa54..88e051b 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", "psr/simple-cache": "^1.0", - "silverstripe/framework": "4.13.x-dev" + "silverstripe/framework": "4.13.0-beta1" }, "require-dev": { "phpunit/phpunit": "^9.5", From 625cf9b8893607373cd3cd2ff5b295916acc838e Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 10 Mar 2023 15:55:39 +1300 Subject: [PATCH 3/5] MNT Update development dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 88e051b..ed2fa54 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", "psr/simple-cache": "^1.0", - "silverstripe/framework": "4.13.0-beta1" + "silverstripe/framework": "4.13.x-dev" }, "require-dev": { "phpunit/phpunit": "^9.5", From 733f004627ff03da900d9cf68ff6948327d2120c Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:48:06 +1300 Subject: [PATCH 4/5] MNT Revert erroneous dependency changes (#84) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ed2fa54..a80309f 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", "psr/simple-cache": "^1.0", - "silverstripe/framework": "4.13.x-dev" + "silverstripe/framework": "^4.12" }, "require-dev": { "phpunit/phpunit": "^9.5", From e4a66ae63348bbd95f4c30b70789ad8380409e82 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 17 Mar 2023 18:53:56 +1300 Subject: [PATCH 5/5] DEP Decouple from silverstripe/framework --- composer.json | 5 ++-- src/Collections/DeltaConfigCollection.php | 6 +++- src/Collections/MemoryConfigCollection.php | 34 ++++++++++++++++++---- src/Middleware/MiddlewareCommon.php | 22 +++++++++++--- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index a80309f..5fa0c7b 100644 --- a/composer.json +++ b/composer.json @@ -7,8 +7,7 @@ "symfony/finder": "^3.4 || ^4.0", "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", - "psr/simple-cache": "^1.0", - "silverstripe/framework": "^4.12" + "psr/simple-cache": "^1.0" }, "require-dev": { "phpunit/phpunit": "^9.5", @@ -21,4 +20,4 @@ "SilverStripe\\Config\\Tests\\": "tests/" } } -} \ No newline at end of file +} diff --git a/src/Collections/DeltaConfigCollection.php b/src/Collections/DeltaConfigCollection.php index 7f5e870..b464519 100644 --- a/src/Collections/DeltaConfigCollection.php +++ b/src/Collections/DeltaConfigCollection.php @@ -151,7 +151,11 @@ public function isDeltaReset($class = null) */ public function unserialize($serialized) { - Deprecation::notice('1.6.0', 'Use __unserialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.6.0', 'Use __unserialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __unserialize() instead', E_USER_DEPRECATED); + } parent::unserialize($serialized); $this->postInit(); } diff --git a/src/Collections/MemoryConfigCollection.php b/src/Collections/MemoryConfigCollection.php index 6ffe745..1239b93 100644 --- a/src/Collections/MemoryConfigCollection.php +++ b/src/Collections/MemoryConfigCollection.php @@ -118,7 +118,11 @@ public function checkForDeprecatedConfig($class, $name): void $deprecated = $this->getClassConfig('__deprecated', true); $data = $deprecated['config'][strtolower($class)][$name] ?? []; if (!empty($data)) { - Deprecation::notice($data['version'], $data['message'], Deprecation::SCOPE_CONFIG); + if (class_exists(Deprecation::class)) { + Deprecation::notice($data['version'], $data['message'], Deprecation::SCOPE_CONFIG); + } else { + user_error($data['message'], E_USER_DEPRECATED); + } } } @@ -216,7 +220,11 @@ public function getAll() */ public function update($class, $name, $value) { - Deprecation::notice('1.0.0', 'Use merge() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.0.0', 'Use merge() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use merge() instead', E_USER_DEPRECATED); + } $this->merge($class, $name, $value); return $this; } @@ -229,7 +237,15 @@ public function update($class, $name, $value) public function merge($class, $name, $value) { if (!is_array($value)) { - Deprecation::notice('1.12.0', 'Use set() if $value is not an array instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use set() if $value is not an array instead'); + } else { + user_error( + 'Non-array values for the $value argument in ' . __METHOD__ + . ' are deprecated. Use set() if $value is not an array instead', + E_USER_DEPRECATED + ); + } } // Detect mergeable config $existing = $this->get($class, $name, true); @@ -297,7 +313,11 @@ public function __unserialize(array $data): void */ public function serialize() { - Deprecation::notice('1.12.0', 'Use __serialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use __serialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __serialize() instead', E_USER_DEPRECATED); + } return serialize($this->__serialize()); } @@ -311,7 +331,11 @@ public function serialize() */ public function unserialize($serialized) { - Deprecation::notice('1.12.0', 'Use __unserialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use __unserialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __unserialize() instead', E_USER_DEPRECATED); + } $data = unserialize($serialized ?? ''); $this->__unserialize($data); } diff --git a/src/Middleware/MiddlewareCommon.php b/src/Middleware/MiddlewareCommon.php index bbfd279..4201322 100644 --- a/src/Middleware/MiddlewareCommon.php +++ b/src/Middleware/MiddlewareCommon.php @@ -71,11 +71,18 @@ public function __unserialize(array $data): void * The __serialize() magic method will be automatically used instead of this * * @return string - * @deprecated 1.12.0 Will be removed without equivalent functionality to replace it + * @deprecated 1.12.0 Will be replaced with __serialize() */ public function serialize() { - Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Will be replaced with __serialize()'); + } else { + user_error( + __METHOD__ . ' is deprecated. Will be replaced with __serialize()', + E_USER_DEPRECATED + ); + } return json_encode(array_values($this->__serialize() ?? [])); } @@ -85,11 +92,18 @@ public function serialize() * and the PHP version used in less than PHP 9.0 * * @param string $serialized - * @deprecated 1.12.0 Will be removed without equivalent functionality to replace it + * @deprecated 1.12.0 Will be replaced with __unserialize() */ public function unserialize($serialized) { - Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Will be replaced with __unserialize()'); + } else { + user_error( + __METHOD__ . ' is deprecated. Will be replaced with __unserialize()', + E_USER_DEPRECATED + ); + } $values = json_decode($serialized ?? '', true); foreach (array_keys($this->__serialize() ?? []) as $i => $key) { if (!property_exists($this, $key ?? '')) {