Page MenuHomePhabricator

Move namespaced extensions to use PSR-4 autoloading
Open, Needs TriagePublic

Description

Some, but not all extensions use their own PHP namespacing.
http://www.php-fig.org/psr/psr-4/ explains the idea behind this task.

Basic process. See https://gerrit.wikimedia.org/r/#/c/398320/ for an example of some of these steps

  • Swap extension.json to use AutoloadNamespaces instead of AutoloadClasses
  • Under "requires", set the "MediaWiki" version requirement to >= 1.31.0
  • Move any PHP files deemed necessary
  • PHPCodeSniffer helps us stick to same coding standards across MediaWiki and it's extensions. This is still work in progress, and some sniffs are still excluded in the file .phpcs.xml (and those exclusions should get removed, in the long run). Disable MediaWiki.Files.ClassMatchesFilename.NotMatch, MediaWiki.Files.ClassMatchesFilename.WrongCase and MediaWiki.Files.OneClassPerFile.MultipleFound in the file .phpcs.xml if these entries exist as exclusions.
  • Fix any resultant test failures from any of the changes above.

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedNone
OpenNone
OpenNone
ResolvedReedy
OpenNone
Resolvedabi_
Resolvedabi_
Resolvedabi_
ResolvedWangombe
ResolvedWangombe
ResolvedPRODUCTION ERRORabi_
ResolvedBUG REPORTabi_
ResolvedPRODUCTION ERRORUrbanecm
ResolvedPRODUCTION ERRORUmherirrender
ResolvedBUG REPORTNikerabbit
Resolvedabi_
ResolvedWangombe
ResolvedPRODUCTION ERRORabi_
ResolvedPRODUCTION ERRORabi_
ResolvedBUG REPORTabi_
ResolvedWangombe
ResolvedNone
ResolvedWangombe
ResolvedWangombe
ResolvedWangombe
ResolvedWangombe
OpenNone
ResolvedWangombe
Resolvedori

Event Timeline

Reedy updated the task description. (Show Details)

Help with improving the task description is welcome, so a new contributor can understand what they are doing and don't only blindly try to copy the example Gerrit change. :) PHP namespaces = http://php.net/manual/en/language.namespaces.php ?
What's the reason that all extensions should use their own PHP namespacing?

This documentation will definitely help students understand why we are doing this: http://www.php-fig.org/psr/psr-4/

Change 398829 had a related patch set uploaded (by Ladsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/ORES@master] Follow up for PSR-4 work

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

Change 398829 merged by jenkins-bot:
[mediawiki/extensions/ORES@master] Follow up for PSR-4 work

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

@Reedy: How can a contributor identify such an extension? Any list to gather somehow?
What's a good chunk (number of extensions) for one GCI task?

Change 401082 had a related patch set uploaded (by Tpt; owner: Tpt):
[mediawiki/extensions/ProofreadPage@master] Uses PSR-4 autoloader

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

Change 401082 merged by jenkins-bot:
[mediawiki/extensions/ProofreadPage@master] Uses PSR-4 autoloader

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

@Reedy: How can a contributor identify such an extension? Any list to gather somehow?
What's a good chunk (number of extensions) for one GCI task?

Yes, using the awesome code search tool, there are some extensions still doing this: https://codesearch.wmflabs.org/search/?q=%22AutoloadClasses%22%3A%20%7B&i=nope&files=&repos=

Change 881064 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/extensions/Translate@master] Move Languageeditstats to Statistics namespace

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