From 1c0a5df13290f22f4bc6fbb0a5c87c39d805df31 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 30 May 2018 16:15:58 +1200 Subject: [PATCH] Object upgrade notice for 3.7.0 changelog See https://forum.silverstripe.org/t/php-7-2-backwards-compat-for-module-maintainers-on-ss-3-7/464/5 --- docs/en/04_Changelogs/3.7.0.md | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/en/04_Changelogs/3.7.0.md diff --git a/docs/en/04_Changelogs/3.7.0.md b/docs/en/04_Changelogs/3.7.0.md new file mode 100644 index 000000000..80b75e697 --- /dev/null +++ b/docs/en/04_Changelogs/3.7.0.md @@ -0,0 +1,43 @@ +# 3.7.0 (unreleased) + +## SilverStripe 3.7 and PHP 7.2 and Object subclasses + +### For Project Code + +SilverStripe 3.7 now supports PHP 7.2, which is exciting, but PHP 7.2 introduces an `object` keyword. +To use it, you can replace any uses of `Object` with `SS_Object` in your own project code. + +```diff +-class MyClass extends Object ++class MyClass extends SS_Object +{ + public function myFunction() + { +- $foo = Object::has_extension('MyExtension'); ++ $foo = SS_Object::has_extension('MyExtension'); + } +} +``` + +You are also reliant on any SilverStripe modules directly using `Object` to upgrade their codebase. +Matches for `SS_Object` in the module codebase will tell you it's been upgraded. +A search for `extends Object` or `Object::` isn't fool proof, but will give you an indication +that the module still needs to be upgraded. If in doubt, check the module README. + +### For Module Authors + +If you are publishing a 3.x-compatible module that directly references the `Object` class, +we recommend that you replace all references to `Object` with `SS_Object`, +and add the following line to your module's `_config.php` +in order to support both current SilverStripe 3.x and SilverStripe 3.7 releases running on PHP 7.2: + +```php +// Ensure compatibility with PHP 7.2 ("object" is a reserved word), +// with SilverStripe 3.6 (using Object) and SilverStripe 3.7 (using SS_Object) +if (!class_exists('SS_Object')) class_alias('Object', 'SS_Object'); +``` + +Don't forget to mention explicit PHP 7.2 and SilverStripe 3.7 compatibility in your module README. + +Note that in SilverStripe 4.x, the `Object` class was deleted so there isn’t an `SS_Object` class there either +(see [https://docs.silverstripe.org/en/4/changelogs/4.0.0/](changelog)) \ No newline at end of file