Page MenuHomePhabricator

CI build failing for some ext repos due to PhanUndeclaredClassMethod "undeclared class \Block"
Closed, ResolvedPublic

Description

For all PageTriage commits, and possibly other extensions as well. Currently blocking ability to merge masters in those master branches.

<file name="includes/Hooks.php">
  <error line="518" severity="warning" message="Parameter $block has undeclared type \Block" source="PhanUndeclaredTypeParameter"/>
</file>
<file name="includes/PageTriageUtil.php">
  <error line="361" severity="warning" message="Parameter $block has undeclared type \Block" source="PhanUndeclaredTypeParameter"/>
  <error line="376" severity="error" message="Call to method getTarget from undeclared class \Block" source="PhanUndeclaredClassMethod"/>

It seems for some reason Phan isn't understanding the class alias for Block.

Wikimedia production calls to fix: https://codesearch.wmflabs.org/deployed/?q=(new%20Block%5C(%7C%5CbBlock%3A%3ATYPE_%7C%40(param%7Cvar%7Creturn)%20Block%5Cb)&i=nope&files=&repos=

Details

Related Gerrit Patches:
mediawiki/extensions/EventBus : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/WikibaseLexeme : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/Wikibase : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/LdapAuthentication : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/GlobalBlocking : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/UserMerge : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/EntitySchema : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/TorBlock : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/PageTriage : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/CheckUser : masterUse MediaWiki\Block\DatabaseBlock instead of Block
mediawiki/extensions/Flow : masterUse MediaWiki\Block\DatabaseBlock instead of Block

Event Timeline

Krinkle created this task.May 30 2019, 10:13 PM
Restricted Application added a project: Growth-Team. · View Herald TranscriptMay 30 2019, 10:13 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Restricted Application added a subscriber: MGChecker. · View Herald TranscriptMay 30 2019, 10:15 PM

Change 513527 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/PageTriage@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

The Block class is only defined as an alias:

class_alias( DatabaseBlock::class, 'Block' );

My guess is that because Phan is a static analyser it can't guarantee it will be able to read the second argument as a class name, so it doesn't try. I'm guessing updating Block to DatabaseBlock (or AbstractBlock) in the affected extensions will fix this.

We can update the affected extensions.

Is this the first class alias Phan has had to deal with?

Change 513533 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/Flow@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513533 merged by jenkins-bot:
[mediawiki/extensions/Flow@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513536 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/CheckUser@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Apparently we can use enable_class_alias_support in Phan config somehow, but there are only thirteen prod repos creating a Block class, so…

Change 513540 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/EventBus@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513536 merged by jenkins-bot:
[mediawiki/extensions/CheckUser@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513527 merged by jenkins-bot:
[mediawiki/extensions/PageTriage@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513542 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/GlobalBlocking@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513540 merged by jenkins-bot:
[mediawiki/extensions/EventBus@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513599 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/LdapAuthentication@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513600 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/TorBlock@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513601 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/UserMerge@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513602 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/EntitySchema@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513603 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/Wikibase@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513604 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/extensions/WikibaseLexeme@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Thanks @Jdforrester-WMF and @Umherirrender. The extensions that document @param Block, @var Block and @return Block should now have patches updating all their references to Block, tagged with this task.

We'll update the extensions that aren't causing Phan to fail too, but won't tag them here.

We can update the affected extensions.
Is this the first class alias Phan has had to deal with?

We've been doing this for the Wikimedia\Rdbms classes for a while which Phan seems to be fine with. (e.g. ResultWrapper, IDatabase and Database, are global aliases.) I took a quick look at how those are set up and it seems identical to the way you've done it for Block, so I'm not sure why Phan complained about these but not the others.

It's possible that something has regressed in newer Phan versions and/or our configuration of it, and that it might now be broken for IDatabase as well. However, we're not likely to find out about that because we've since fixed it in most of the active repos. It's possible that the older repos still using IDatabase are also broken, in which case we'd find out next time someone proposes a commit for those repos.

Change 513600 merged by jenkins-bot:
[mediawiki/extensions/TorBlock@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513601 merged by jenkins-bot:
[mediawiki/extensions/UserMerge@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513602 merged by jenkins-bot:
[mediawiki/extensions/EntitySchema@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513542 merged by jenkins-bot:
[mediawiki/extensions/GlobalBlocking@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513604 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513599 merged by jenkins-bot:
[mediawiki/extensions/LdapAuthentication@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Change 513603 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use MediaWiki\Block\DatabaseBlock instead of Block

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

Niharika closed this task as Resolved.Jun 5 2019, 10:42 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:06 PM