Page MenuHomePhabricator

"PHP Deprecated: Use of MediaWiki\Parser\ParserOutput::setTOCHTML was deprecated in MediaWiki 1.40" in PHPUnit tests
Closed, ResolvedPublic

Description

The following PHP deprecation notice is emitted when running PHPUnit tests in MW master, as can be seen in CI (ex):

> phpunit '--group' 'Database' '--exclude-group' 'Broken,ParserFuzz,Stub,Standalone'
Using PHP 7.4.33
Running with MediaWiki settings because there might be integration tests
PHP Deprecated:  Use of MediaWiki\Parser\ParserOutput::setTOCHTML was deprecated in MediaWiki 1.40. [Called from MediaWiki\Tests\Parser\ParserCacheSerializationTestCases::getParserOutputTestCases in /workspace/src/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php at line 236] in /workspace/src/includes/debug/MWDebug.php on line 378
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

This is not causing the build to fail. I suspect it only affects tests, and the notice might be emitted early on during the PHPUnit initialisation process (e.g., when running data providers). Once this is investigated and resolved, we should probably find a way to have this kind of notices make the PHPUnit command fail, as I've seen similar silent warnings quite a few times over the years.

Event Timeline

I've briefly looked at the code, and it looks like the code in question is already suppressing the warning, but the ParserOutput class has been namespaced and the filterDeprecationForTest call is no longer doing anything.

Change 991949 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] tests: Fix deprecation filter in ParserCacheSerializationTestCases

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

Change 991949 merged by jenkins-bot:

[mediawiki/core@master] tests: Fix deprecation filter in ParserCacheSerializationTestCases

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

This doesn't seem to be fixed and/or has regressed since...

https://integration.wikimedia.org/ci/job/mwcore-phpunit-coverage-patch/68302/console

20:25:13 PHP Deprecated:  Use of MediaWiki\Parser\ParserOutput::setTOCHTML was deprecated in MediaWiki 1.40. [Called from MediaWiki\Tests\Parser\ParserCacheSerializationTestCases::getParserOutputTestCases in /workspace/src/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php at line 236] in /workspace/src/includes/debug/MWDebug.php on line 379

Change 1004244 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/core@master] ParserCacheSerializationTestCases: Fix MWDebug::filterDeprecationForTest call for setTOCHTML

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

Change 1004244 merged by jenkins-bot:

[mediawiki/core@master] ParserCacheSerializationTestCases: Fix MWDebug::filterDeprecationForTest call for setTOCHTML

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

Or not?

16:02:41 PHP Deprecated:  Use of MediaWiki\Parser\ParserOutput::setTOCHTML was deprecated in MediaWiki 1.40. [Called from MediaWiki\Tests\Parser\ParserCacheSerializationTestCases::getParserOutputTestCases in /workspace/src/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php at line 236] in /workspace/src/includes/debug/MWDebug.php on line 379

The real issue is that ParserCacheSerializationTestCases is testing a bunch of ancient parser cache formats that (by now) haven't been used in production for years. There *is* a filterDeprecated call which is supposed to allow those test cases to use a bunch of stuff from ParserOutput that's long since been deprecated, but apparently it's not happening at the right place in phpunit setup.

The real solution is probably just to punt the old test cases (T353570), rather than waste time figuring out why filterDeprecated is being called at the wrong times.

Change 1006143 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] tests: Avoid php warnings about deprecation from data providers

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

Change 1006143 merged by jenkins-bot:

[mediawiki/core@master] tests: Avoid php warnings about deprecation from data providers

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