Page MenuHomePhabricator

[GENERAL] PHP 8.4 issues in WMDE/Wikidata libraries
Closed, ResolvedPublic

Description

Starting in PHP 8.4, the “old-style” syntax for nullable parameters like Parser $parser = null is deprecated. It should be changed to ?Parser $parser = null – or, if the parameter should not actually have a default argument, to just ?Parser $parser. This is required for compatibility with PHP 8.4 (which is currently used by some developers and will be used in production in future) without raising tons of deprecation warnings.

Acceptance criteria:

  • The libraries listed below use the latest version of the MediaWiki codesniffer config.
    • data-values/common
    • data-values/geo
    • data-values/interfaces
    • data-values/number
    • data-values/time
    • diff/diff
    • serialization/serialization
    • wmde/hamcrest-html-matchers
  • New versions of the libraries have been released
    • data-values/common
    • data-values/geo
    • data-values/interfaces
    • data-values/number
    • data-values/time
    • diff/diff
    • serialization/serialization
    • wmde/hamcrest-html-matchers
  • The new versions are used in Wikibase / mediawiki/vendor.git.
  • The PHPCS rule MediaWiki.Usage.NullableType.ExplicitNullableTypes is not disabled in their .phpcs.xml.
  • Any violations have been fixed.

cf T376276: PHP 8.4: Implicitly nullable parameter declarations deprecated and T379509: [GENERAL] Fix implicit nullable types in Wikibase

In T376276#10306963, Umherirrender wrote:

Running the sniff from T362014 against mediawiki/vendor shows many code in different packages

Event Timeline

Lucas_Werkmeister_WMDE renamed this task from PHP 8.4 issues in WMDE/Wikidata libraries to [GENERAL] PHP 8.4 issues in WMDE/Wikidata libraries.Nov 21 2024, 2:03 PM
Lucas_Werkmeister_WMDE updated the task description. (Show Details)

Prio Notes:

Impact AreaAffected
production / end usersnot yet
monitoring
development efforts
onboarding efforts
additional stakeholders✔ (people who already want to run Wikibase on PHP 8.4)

Change #1101486 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Replace calls to deprecated `defaultOption` with `withDefaultOption`

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

Unassigned and moved back to ready for dev as Arthur is OOO this week

Change #1108396 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/vendor@master] Upgrade wikibase-related libraries for PHP 8.4 compatibility

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

The released version of data-values/geo (4.5.0) includes a change to drop support for PHP 7.4. Since our infrastructure still uses PHP 7.4 (T319432), this creates problems for us. I opened an issue and created a pull request to revert the deprecation. Until that is merged and tagged, we can't upgrade to the version of data-values/geo that fixes the PHP 8.4 deprecation issue.

The released version of data-values/geo (4.5.0) includes a change to drop support for PHP 7.4. Since our infrastructure still uses PHP 7.4 (T319432), this creates problems for us. I opened an issue and created a pull request to revert the deprecation. Until that is merged and tagged, we can't upgrade to the version of data-values/geo that fixes the PHP 8.4 deprecation issue.

I merged that and tagged 4.5.1 which restores PHP 7.4 support.

Change #1108416 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Loosen data-values/number version constraint to prepare update

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

Change #1108427 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseQualityConstraints@master] Declare compatibility with data-values/number 0.13.0

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

Change #1108416 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Loosen data-values/number version constraint to prepare update

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

Change #1108427 merged by jenkins-bot:

[mediawiki/extensions/WikibaseQualityConstraints@master] Declare compatibility with data-values/number 0.13.0

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

Change #1108396 merged by jenkins-bot:

[mediawiki/vendor@master] Upgrade wikibase-related libraries for PHP 8.4 compatibility

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

Codesearch suggests that the rule is not disabled anywhere. The Wikibase code and libraries have been updated.

Change #1101486 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace calls to deprecated `defaultOption` with `withDefaultOption`

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