-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PHP supported version #10219
Comments
I have done some internal testing on all of the sites we manage on SS4.10 with PHP8.1, everything runs properly but there are a ton of deprecation notices due to PHP8.1 not allowing null being passed to non-nullable internal functions. There are also some more deprecation notices around wrong return types being returned. https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg When setting your environment type to 'test' or 'live' these are hidden but it looks like a lot of core code is going to need to be updated. Some example notices that we are seeing are -
|
List of deprecations in 8.1 - https://php.watch/versions/8.1 (scroll to bottom of doc) I've got a draft PR up that's a work in progress I was initialially worried about the Serializable being deprecated, in particular if any sites had custom code that saved serialized classes to the database, rather than just to the /tmp/silverstripe-cache-php cache, where a new dir would be created on php upgrade. The worry was because our existing implementations uses json_encode, rather than and assoc_array. I've written this test script that demonstrates that old persisted data will fallback to the old unserialise() implementations if needed The recommended solution is to add the new __serialize() and __unserialize() magic methods (and optionally remove the Seraliaze interface as we're during php7.3 support.
Running this in PHP8.1 outputs:
|
Sample rector.php file used to help with conversion - see https://github.com/rectorphp/rector Note: on framework it hangs about 90% through the process. Also on a run on assets it did not detect everything File.php:1336 was missed. So it seems OK to run this, though it's not going to fix everything. Needs to run in php8.0 (or less), or possibly php8.1 with deprecation warnings turned off <?php
// rector.php
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
// paths to refactor; solid alternative to CLI arguments
$parameters->set(Option::PATHS, [__DIR__ . '/vendor/silverstripe/framework/src']);
// is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81);
// // Path to phpstan with extensions, that PHPStan in Rector uses to determine types
// $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan-for-config.neon');
// register single rule
$services = $containerConfigurator->services();
$services->set(NullToStrictStringFuncCallArgRector::class);
}; |
related: silverstripe/silverstripe-staticpublishqueue#135 (since this is a supported module) |
Merged most of the thing I could ... I think we're missing a framework PR. |
Got a work in progress PR to try to squash all the warnings: #10237. Probably not necessary to get that other PR over the line to close this card. |
Framework PR was merged - was linked above (2nd from top) - #10232 |
#10250 will track follow up work to squash all the warnings. |
1 similar comment
#10250 will track follow up work to squash all the warnings. |
PHP 8.1 has been released in December. Our current constraint don't stop you from installing Silverstripe CMS on PHP8.1 but we don't know for sure everything works because we don't currently run unit test for it. PHP7.3 has also been EOL.
Acceptance criteria
Entire silverstripe/recipe-kitchen-sink is upgraded to 8.1 compatibilityReferences toSerializable
are removedserialize/unserialize
methods are marked as@deprecated
and reference matching__serialize/__unserialize
methods.Stretch goal
PHP7.3 builds still run on older releasesPRs
The text was updated successfully, but these errors were encountered: