Page MenuHomePhabricator

Cleanup forgotten usages of Revision
Closed, ResolvedPublic

Description

From the production logs, we have 3 usages so far that were forgotten:

Use of MediaWiki\Storage\PageUpdater::doModify status get 'revision' was deprecated in MediaWiki 1.35. [Called from SpecialPageTranslation::markForTranslation in /srv/mediawiki/php-1.35.0-wmf.40/extensions/Translate/tag/SpecialPageTranslation.php at line
23

Use of Revision::__construct was deprecated in MediaWiki 1.31. [Called from MediaWiki\Storage\PageUpdater::MediaWiki\Storage\{closure} in /srv/mediawiki/php-1.35.0-wmf.40/includes/Storage/PageUpdater.php at line 1122]
3

Use of Revision::getRevisionRecord was deprecated in MediaWiki 1.31. [Called from SpecialPageTranslation::markForTranslation in /srv/mediawiki/php-1.35.0-wmf.40/extensions/Translate/tag/SpecialPageTranslation.php at line 887]

Event Timeline

The three uses are all the same. Hmm,

		if ( array_key_exists( 'revision-record', $status->value ) ) {
			// MW 1.35+
			// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
			$newRevisionRecord = $status->value['revision-record'];
		} else {
			// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
			$newRevision = $status->value['revision'];
			if ( $newRevision instanceof Revision ) {
				$newRevisionRecord = $newRevision->getRevisionRecord();
			} else {
				$newRevisionRecord = null;
			}
		}

Apparently isn't working? Access revision -> callback to create Revision (use of __construct) -> ::getRevisionRecord.

$status->value is the DeprecatablePropertyArray from T254952: PageUpdater: set DeprecatablePropertyArray to hard deprecate Revision. Does array_key_exists not work with DeprecatablePropertyArray?

Does array_key_exists not work with DeprecatablePropertyArray?

It certainly seems so. I've tried it out in a unit test. isset will do the trick.

Change 610102 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/Translate@master] DeprecatablePropertyArray: Use isset instead of array_key_exists

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

Does array_key_exists not work with DeprecatablePropertyArray?

It certainly seems so. I've tried it out in a unit test. isset will do the trick.

Though the value can be null, so isset might not be the best idea

Change 610102 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] DeprecatablePropertyArray: Use MW_VERSION instead of array_key_exists

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

Change 610103 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/Translate@wmf/1.35.0-wmf.40] DeprecatablePropertyArray: Use MW_VERSION instead of array_key_exists

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

Change 610103 merged by jenkins-bot:
[mediawiki/extensions/Translate@wmf/1.35.0-wmf.40] DeprecatablePropertyArray: Use MW_VERSION instead of array_key_exists

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

Mentioned in SAL (#wikimedia-operations) [2020-07-09T11:42:24Z] <urbanecm@deploy1001> Synchronized php-1.35.0-wmf.40/extensions/Translate/tag/SpecialPageTranslation.php: 6541d3ff51f52fe8a1bdbfa86022f8d97d6c7680: DeprecatablePropertyArray: Use MW_VERSION instead of array_key_exists (T257531) (duration: 01m 05s)