Page MenuHomePhabricator

Use PHP 8.0 polyfills
Closed, ResolvedPublic

Description

I will soon upload a commit to Gerrit that adds the symfony/polyfill-php80 package to Parsoid. Since Core depends on Parsoid, that means PHP 8.0 polyfills will be available in Core too. I think we should add the package as a core dependency and start using it.

My reason for doing this in Parsoid is because I'm doing a lot of small tweaks to code style, especially regex usage, and I don't want to have to repeat that review once PHP 8.0 becomes the minimum version. I want to use str_contains, str_starts_with and str_ends_with now and then not touch that code again.

Also, using these functions now will improve performance on PHP 8.0. I'm arguing on T271736 that production should soon switch to PHP 8.0.

We haven't had to do this for a while because there haven't been many new functions that we would want to use. There used to be polyfills in GlobalFunctions.php for mbstring and PHP 5.x, but they were eventually removed as our minimum requirements changed.

Event Timeline

Requiring the polyfill is very low cost, on platforms where you know you have a specific PHP version or extension installed, the polyfill can be replaced out so it has zero overhead: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/vendor/+/refs/heads/master/composer.json#135

AFAIS we can enable the 8.0 polyfill without needing the 7.3/7.4 polyfills, which is nice.

Note that symfony/polyfill-php80 is already in mediawiki/vendor (as is symfony/polyfill-php73) – added in e7868430c and currently using version 1.22.0 (as of 9b4522dcd). Adding this as a dependency to core is 'free' from a process POV. We could sling it out as part of REL1_37?

Change 720165 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/services/parsoid@master] Allow PHP 8.0 polyfills

https://gerrit.wikimedia.org/r/720165

Change 720165 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Allow PHP 8.0 polyfills

https://gerrit.wikimedia.org/r/720165

Change 720806 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Update symfony/polyfill-php80 to 1.23.1

https://gerrit.wikimedia.org/r/720806

Change 720809 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.14.0-a18

https://gerrit.wikimedia.org/r/720809

Note that symfony/polyfill-php80 is already in mediawiki/vendor (as is symfony/polyfill-php73) – added in e7868430c and currently using version 1.22.0 (as of 9b4522dcd). Adding this as a dependency to core is 'free' from a process POV. We could sling it out as part of REL1_37?

Done as I3c73c6f8c2189837c50a1f2bb39900ce44b3d5da to vendor -- though it sounds like we might want to add this dependency to core as well for REL1_37 ?

Change 720806 merged by jenkins-bot:

[mediawiki/vendor@master] Update symfony/polyfill-php73 to 1.23.0 and polyfill-php80 to 1.23.1

https://gerrit.wikimedia.org/r/720806

Change 720809 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.14.0-a18

https://gerrit.wikimedia.org/r/720809

Change 720815 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/720815

Change 720815 merged by jenkins-bot:

[mediawiki/core@master] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/720815

Change 720846 had a related patch set uploaded (by Jforrester; author: C. Scott Ananian):

[mediawiki/core@REL1_37] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/720846

Change 720846 merged by jenkins-bot:

[mediawiki/core@REL1_37] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/720846

Change 724973 had a related patch set uploaded (by Reedy; author: C. Scott Ananian):

[mediawiki/core@REL1_36] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/724973

Change 724974 had a related patch set uploaded (by Reedy; author: C. Scott Ananian):

[mediawiki/core@REL1_35] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/724974

Change 724974 merged by jenkins-bot:

[mediawiki/core@REL1_35] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/724974

Change 724973 merged by jenkins-bot:

[mediawiki/core@REL1_36] Add symfony/polyfill-php80

https://gerrit.wikimedia.org/r/724973