Page MenuHomePhabricator

Cargo phan change is causing Page Forms validation to fail
Closed, ResolvedPublic

Description

This change to Cargo:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cargo/+/901699

...seems to be causing all Page Forms patches to fail validation. See here:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/902732

The issue seems to be that Cargo now defines stub versions of various Admin Links classes (ALSection, ALRow, etc.) - and Page Forms' validation is getting confused by the fact that each of these classes is now defined in two different places.

I'm sure there are workarounds to this - but does Cargo really need to re-declare these classes? I don't know of any other extensions that do that.

Event Timeline

Sorry about that.

I think the simplest fix is to conditionally include the stubs like so: https://github.com/wikimedia/mediawiki/blob/master/.phan/config.php#L30

Okay, that would work. And now I think I understand why Cargo has these class re-declarations: so that the validation will know that these classes exist, since Admin Links is not being loaded. But why do none of the other extensions that also hook in to Admin Links (https://www.mediawiki.org/wiki/Category:AdminLinks_extensions) need these class declarations? (I think.)

Okay, that would work. And now I think I understand why Cargo has these class re-declarations: so that the validation will know that these classes exist, since Admin Links is not being loaded. But why do none of the other extensions that also hook in to Admin Links (https://www.mediawiki.org/wiki/Category:AdminLinks_extensions) need these class declarations? (I think.)

I haven't checked all of them, but the stubs would only be needed if Phan is configured for these extensions - otherwise WMF CI won't try to run Phan and it won't complain about missing classes.

So, should I revert the Cargo change? It sounds extreme, but I need to be able to check in changes to Page Forms - and any other extension that is affected by this.

That should be fine for now. After that, we could either:

  • Configure PageForms to ignore Phan stubs in other extensions via a config stanza such as $cfg['exclude_file_regex'] = '@^../../extensions/Cargo/.phan/stubs/@';, or
  • Reimplement the hooks change in Cargo without stubs. This will require people to have a checkout of the AdminLinks extension to run phan locally and will also need a corresponding integration/config patch as noted by Sam.

Both are viable options.

@TK-999 - okay, thanks for your understanding. I reverted the change, and re-added your PageSaveComplete fix. I don't think the first of those suggested fixes makes sense - if only because there's a reasonable chance that such a fix would also be needed for some of the other 20 or so extensions that make use of Admin Links. So I guess that just leaves the second fix.

I'm closing this bug, although I'm looking forward to CargoUtils.php getting validated better, in one way or another.