Page MenuHomePhabricator

maintenance/generateLocalAutoload.php ignores aliases for PSR4
Closed, ResolvedPublic

Description

PSR4 doesn't specify how to handle class aliases, as might be used for backwards compatibility when a class is renamed.

After much discussion in T166010: The Great Namespaceization and Reorg, we concluded that the best solution is to put the class_alias() call into the same file as the target class, to ensure that all aliases are known whenever the target class is loaded.

However, rMW036f5b47efc9: Enable using PSR-4 autoloader for MediaWiki core and extensions which added support for skipping listing of PSR4-compliant classes did not consider the possibility of aliases, nor did it consider the possibility that a directory might contain a mixture of PSR4-compliant and old non-compliant classes.

Instead of skipping all files in directories intended for PSR4-compliant classes, AutoloadGenerator should process the files and filter out only those classes that are actually PSR4 compliant.

Event Timeline

Change 461696 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] AutoloadGenerator: Filter PSR4-compliant classes instead of ignoring directories

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

Change 461696 merged by jenkins-bot:
[mediawiki/core@master] AutoloadGenerator: Filter PSR4-compliant classes instead of ignoring directories

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