Page MenuHomePhabricator

$wgDeprecationReleaseLimit is broken
Closed, ResolvedPublic

Description

After updating translatewiki.net yesterday, we started seeing a flood of deprecation warnings in our logs. For example:

[2020-06-24 15:01:32] error.WARNING: [87a502f73677d85117d98fc3] [no req]   ErrorException from line 427 of /srv/mediawiki/workdir/includes/debug/MWDebug.php: PHP Deprecated: Use of NewRevisionFromEditComplete hook (used in onNewRevisionFromEditComplete) was deprecated in MediaWiki 1.35. [Called from MediaWiki\HookContainer\HookContainer::run in /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php at line 131] {"exception":"[object] (ErrorException(code: 0): PHP Deprecated: Use of NewRevisionFromEditComplete hook (used in onNewRevisionFromEditComplete) was deprecated in MediaWiki 1.35. [Called from MediaWiki\\HookContainer\\HookContainer::run in /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php at line 131] at /srv/mediawiki/workdir/includes/debug/MWDebug.php:427)
[stacktrace]
#0 [internal function]: MWExceptionHandler::handleError(16384, 'Use of NewRevis...', '/srv/mediawiki/...', 427, Array)
#1 /srv/mediawiki/workdir/includes/debug/MWDebug.php(427): trigger_error('Use of NewRevis...', 16384)
#2 /srv/mediawiki/workdir/includes/debug/MWDebug.php(331): MWDebug::sendMessage('Use of NewRevis...', 'deprecated', 16384)
#3 /srv/mediawiki/workdir/includes/debug/MWDebug.php(301): MWDebug::sendRawDeprecated('Use of NewRevis...', true, 'MediaWiki\\\\HookC...')
#4 /srv/mediawiki/workdir/includes/debug/MWDebug.php(234): MWDebug::deprecatedMsg('Use of NewRevis...', '1.35', 'MediaWiki', 4)
#5 /srv/mediawiki/workdir/includes/GlobalFunctions.php(1031): MWDebug::deprecated('NewRevisionFrom...', '1.35', 'MediaWiki', 3)
#6 /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php(316): wfDeprecated('NewRevisionFrom...', '1.35', false)
#7 /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php(131): MediaWiki\\HookContainer\\HookContainer->callLegacyHook('NewRevisionFrom...', Array, Array, Array)
#8 /srv/mediawiki/workdir/includes/HookContainer/HookRunner.php(2680): MediaWiki\\HookContainer\\HookContainer->run('NewRevisionFrom...', Array)
#9 /srv/mediawiki/workdir/includes/Storage/PageUpdater.php(1225): MediaWiki\\HookContainer\\HookRunner->onNewRevisionFromEditComplete(Object(WikiPage), Object(Revision), false, Object(User), Array)
#10 /srv/mediawiki/workdir/includes/Storage/PageUpdater.php(796): MediaWiki\\Storage\\PageUpdater->doCreate(Object(CommentStoreComment), Object(User), 65)
#11 /srv/mediawiki/workdir/includes/page/WikiPage.php(1973): MediaWiki\\Storage\\PageUpdater->saveRevision(Object(CommentStoreComment), 65)
#12 /srv/mediawiki/workdir/includes/EditPage.php(2347): WikiPage->doEditContent(Object(WikitextContent), Object(CommentStoreComment), 65, false, Object(User), 'text/x-wiki', Array, 0)
#13 /srv/mediawiki/workdir/includes/EditPage.php(1616): EditPage->internalAttemptSave(Array, false)
#14 /srv/mediawiki/workdir/includes/api/ApiEditPage.php(416): EditPage->attemptSave(Array)
#15 /srv/mediawiki/workdir/includes/api/ApiMain.php(1585): ApiEditPage->execute()
#16 /srv/mediawiki/workdir/includes/api/ApiMain.php(525): ApiMain->executeAction()
#17 /srv/mediawiki/workdir/includes/api/ApiMain.php(496): ApiMain->executeActionWithErrorHandling()
#18 /srv/mediawiki/workdir/api.php(84): ApiMain->execute()
#19 {main}
","exception_id":"87a502f73677d85117d98fc3","exception_url":"[no req]","caught_by":"mwe_handler"} []
[24-Jun-2020 15:01:32 UTC] PHP Deprecated:  Use of NewRevisionFromEditComplete hook (used in onNewRevisionFromEditComplete) was deprecated in MediaWiki 1.35. [Called from MediaWiki\HookContainer\HookContainer::run in /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php at line 131] in /srv/mediawiki/workdir/includes/debug/MWDebug.php on line 427

We have LocalSettings.php:$wgDeprecationReleaseLimit = '1.29'; so these warnings should not happen.

We had to work around by setting $wgDevelopmentWarnings = false; to suppress all warnings.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 25 2020, 7:18 AM
AMooney triaged this task as Medium priority.Jun 30 2020, 8:41 PM
AMooney added subscribers: Krinkle, AMooney.

@Krinkle is the related to what u are working on?

Krinkle claimed this task.Jul 3 2020, 4:17 PM

Yes. This is an unintended side-effect. I will look into it.

Krinkle moved this task from Inbox to Doing on the Performance-Team board.Jul 6 2020, 8:05 PM
Krinkle removed Krinkle as the assignee of this task.EditedJul 7 2020, 7:22 PM
Krinkle removed a project: Performance-Team.

This change in question I was working on is from T252923:

@gerritbot wrote:

Change 599148 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] debug: Use native E_USER_DEPRECATED instead of custom channel

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

Upon closer review, I observe that:

  1. This commit does not make any change to when the deprecation is logged and does not involve wgDeprecationReleaseLimit.
  2. This commit has in fact not yet been merged and thus cannot be causing the issue @Nikerabbit is observing.

Since I am currently working on this area, I'll remain subscribed as I'd be happy to review a patch for this if someone finds the root cause.

Can you be more specific - if you know the specific root cause already?

Ammarpad added a comment.EditedJul 8 2020, 4:51 PM

The logic to respect this flag is wrapped in

if ( $wgDeprecationReleaseLimit && $component === false ) {}

Before the above-mentioned change 605054, the $component in the above comparison refers to the value set in wfDeprecated(). Since most deprecation don't set it, it defaults to its default value which is false. Therefore the expression will evaluates to true and that will enable us to compare versions and possibly set $sendToLog = false inside the block.

After change 605054, the above expression will always evaluates to false because the patch moved $component definition up and made it to be defined even before we reach the expression.

$component = $component ?: 'MediaWiki';

And since the expression will not evaluate to true, we cannot enter the block to change the value of $sendToLog, therefore the default value $sendToLog = true will be used

This can be seen at glance in the patch diff

Thank you. Would you like to write a patch for this one?

Yes, I will do.

Ammarpad claimed this task.Jul 8 2020, 5:08 PM

Change 610337 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Fix Deprecation Release Limit detection

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

Change 610337 merged by jenkins-bot:
[mediawiki/core@master] MWDebug: Restore wgDeprecationReleaseLimit filtering

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