Page MenuHomePhabricator

Test failures under PHPUnit 9.6: "Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10"
Closed, ResolvedPublic

Description

Current status: Mitigated by pinning PHPUnit 9.5.x; task remains open so we can figure out how to properly resolve this and update to PHPUnit 9.6. (PHPUnit 10 drops support for PHP ≤8.0, so we won’t be able to update to that too soon.)


CI is failing with the following error/warning (example build):

11:26:00 There were 42 warnings:
11:26:00 
11:26:00 1) DeprecatedGlobalTest::testWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 2) MediaWiki\HookContainer\HookContainerTest::testEmitDeprecationWarnings
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 3) MediaWiki\Tests\Unit\Revision\MutableRevisionRecordTest::testGetIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 4) MediaWiki\Tests\Unit\Revision\MutableRevisionRecordTest::testGetPageIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 5) MediaWiki\Tests\Unit\Revision\MutableRevisionRecordTest::testGetParentIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 6) MediaWiki\Tests\Unit\Revision\RevisionArchiveRecordTest::testGetIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 7) MediaWiki\Tests\Unit\Revision\RevisionArchiveRecordTest::testGetPageIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 8) MediaWiki\Tests\Unit\Revision\RevisionArchiveRecordTest::testGetParentIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 9) MediaWiki\Tests\Unit\Revision\RevisionStoreCacheRecordTest::testGetIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 10) MediaWiki\Tests\Unit\Revision\RevisionStoreCacheRecordTest::testGetPageIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 11) MediaWiki\Tests\Unit\Revision\RevisionStoreCacheRecordTest::testGetParentIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.
11:26:00 
11:26:00 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
11:26:00 
11:26:00 12) MediaWiki\Tests\Unit\Revision\RevisionStoreRecordTest::testGetIdTriggerDeprecatedWarning
11:26:00 Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10.

Some affected patches: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/884414 & https://gerrit.wikimedia.org/r/c/mediawiki/core/+/884065.

Event Timeline

xSavitar updated the task description. (Show Details)
Lucas_Werkmeister_WMDE triaged this task as Unbreak Now! priority.EditedFeb 3 2023, 9:55 AM

Also affects Wikibase, so shared CI blocker ⇒ UBN. I suspect we need to pin PHPUnit to 9.5, since 9.6 and 10 (both released today) are effectively both breaking changes, regardless of the major/minor version change.

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

[mediawiki/core@master] Pin PHPUnit to 9.5.x

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

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

[mediawiki/extensions/Wikibase@master] DNM: Empty change to test CI

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

Change 886325 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/Wikibase@master] DNM: Empty change to test CI

Reason:

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

Change 886324 merged by jenkins-bot:

[mediawiki/core@master] Pin PHPUnit to 9.5.x

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

Lucas_Werkmeister_WMDE renamed this task from Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10 to Test failures under PHPUnit 9.6: "Expecting E_DEPRECATED and E_USER_DEPRECATED is deprecated and will no longer be possible in PHPUnit 10".Feb 3 2023, 10:35 AM
Lucas_Werkmeister_WMDE lowered the priority of this task from Unbreak Now! to Needs Triage.
Lucas_Werkmeister_WMDE updated the task description. (Show Details)

As far as I can tell, the only solution is to stop using the expectDeprecation, expectNotice, expectWarning and expectError methods on TestCase. I don’t see any way to filter the warning in the PHPUnit 9.6 code. There is also no PHPUnit replacement for these expectations (source):

There are no replacements. PHPUnit 10 no longer converts E_* to exceptions, therefore E_* can no longer be expected.

Does that mean we also need to stop using trigger_error() in our non-test code (e.g. MWDebug::sendRawDeprecated())? Or can we create our own way to to test this behavior?

Change 886364 had a related patch set uploaded (by Jforrester; author: Jforrester):

[labs/libraryupgrader/config@master] releases: Pin PHPUnit to 9.5.28 (latest 9.5.x as of today)

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

Maybe? Though not a lot of repositories use the deprecated expects methods, it seems.

Ack. We probably should have been pinning this earlier anyway, like we do for other CI-critical repos.

Change 886906 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[oojs/ui@master] Make Tag methods throw proper exceptions instead of warnings

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

Change 886981 had a related patch set uploaded (by Bartosz Dziewoński; author: Lucas Werkmeister (WMDE)):

[mediawiki/core@wmf/1.40.0-wmf.21] Pin PHPUnit to 9.5.x

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

Change 886981 merged by jenkins-bot:

[mediawiki/core@wmf/1.40.0-wmf.21] Pin PHPUnit to 9.5.x

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

Change 886906 merged by jenkins-bot:

[oojs/ui@master] Make Tag methods fail the same way in PHP before and after 8.1

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

Change 886364 merged by jenkins-bot:

[labs/libraryupgrader/config@master] releases: Pin PHPUnit to 9.5.28 (latest 9.5.x as of today)

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

OK, provisionally this should be avoided everywhere now except a handful of repos that are waiting to update from 8|9 to just a pinned 9.5.28.

I thought we were keeping this task open to figure out how to properly solve the issue… unless we’re fine wtih skipping PHPUnit 9.6 and going straight to 10, which we already have a task for?

I thought we were keeping this task open to figure out how to properly solve the issue… unless we’re fine wtih skipping PHPUnit 9.6 and going straight to 10, which we already have a task for?

I think that's fine (especially as PHPUnit 10 won't be for ~5 years).

Change 921070 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update OOUI to v0.47.0

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

Change 921070 merged by jenkins-bot:

[mediawiki/core@master] Update OOUI to v0.47.0

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