Page MenuHomePhabricator

CI tests for ContentTranslation fails due to a core change
Closed, ResolvedPublicBUG REPORT

Description

All of the ContentTranslation changes are failing due to a change in MW core: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/670570/42/includes/user/User.php#1940

Error example (from https://integration.wikimedia.org/ci/job/mwext-php72-phan-docker/122001/console)

09:02:00 api/ApiContentTranslationDelete.php:23 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $user->getBlock() of type ?\MediaWiki\Block\AbstractBlock|?\MediaWiki\Block\Block but \ContentTranslation\ActionApi\ApiContentTranslationDelete::dieBlocked() takes \MediaWiki\Block\Block defined at ../../includes/api/ApiBase.php:1405 (expected type to be non-nullable)
09:02:00 api/ApiContentTranslationPublish.php:174 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $this->getUser()->getBlock() of type ?\MediaWiki\Block\AbstractBlock|?\MediaWiki\Block\Block but \ContentTranslation\ActionApi\ApiContentTranslationPublish::dieBlocked() takes \MediaWiki\Block\Block defined at ../../includes/api/ApiBase.php:1405 (expected type to be non-nullable)
09:02:00 api/ApiContentTranslationSave.php:41 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $user->getBlock() of type ?\MediaWiki\Block\AbstractBlock|?\MediaWiki\Block\Block but \ContentTranslation\ActionApi\ApiContentTranslationSave::dieBlocked() takes \MediaWiki\Block\Block defined at ../../includes/api/ApiBase.php:1405 (expected type to be non-nullable)
09:02:00 api/ApiContentTranslationToken.php:19 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $user->getBlock() of type ?\MediaWiki\Block\AbstractBlock|?\MediaWiki\Block\Block but \ContentTranslation\ActionApi\ApiContentTranslationToken::dieBlocked() takes \MediaWiki\Block\Block defined at ../../includes/api/ApiBase.php:1405 (expected type to be non-nullable)
09:02:00 api/ApiSectionTranslationPublish.php:108 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $this->getUser()->getBlock() of type ?\MediaWiki\Block\AbstractBlock|?\MediaWiki\Block\Block but \ContentTranslation\ActionApi\ApiSectionTranslationPublish::dieBlocked() takes \MediaWiki\Block\Block defined at ../../includes/api/ApiBase.php:1405 (expected type to be non-nullable)

Follow up fix https://gerrit.wikimedia.org/r/c/mediawiki/core/+/702686 does not seem to fix it though

Event Timeline

A temporary workaround could be to suppress the phan error or rewrite the code to:

		$block = $user->getBlock();
		if ( $block && $block->isSitewide() ) {
			$this->dieBlocked( $block );
		}

But there are multiple extensions with similar code that needs updating if this is the new pattern: https://codesearch.wmcloud.org/search/?q=-%3EdieBlocked&i=nope&files=&excludeFiles=&repos=

Change 704272 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Check site wide block instead of generic user's block

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

Change 704272 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Check site wide block instead of generic user's block

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

https://gerrit.wikimedia.org/r/704272 did a fix in CX codebase. But since there are other extensions that use this API, their CI could be failing.

Nikerabbit claimed this task.

Okay for me but tasks like T286680: UploadWizard phan is failing due to a core change indicate it's not fixed everywhere yet.