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.

Extensions concerned

  • extensions / examples (DataPages/extension.json)
  • extensions / AccountInfo
  • extensions / AddHTMLMetaAndTitle
  • extensions / Auth_remoteuser
  • extensions / AutoCategoriseUploads
  • extensions / BoilerPlate
  • extensions / Capiunto
  • extensions / CategoryWatch
  • extensions / Cognate
  • extensions / Description2
  • extensions / EducationProgram
  • extensions / EmailAuth
  • extensions / EUCopyrightCampaign
  • extensions / ExternalArticles
  • extensions / FileExporter
  • extensions / FundraisingTranslateWorkflow
  • extensions / Genealogy
  • extensions / GeoData
  • extensions / GettingStarted
  • extensions / GlobalCssJs
  • extensions / GlobalUserPage
  • extensions / GoogleAuthenticator
  • extensions / Graph
  • extensions / GraphViz
  • extensions / GWToolset
  • extensions / HitCounters
  • extensions / InterwikiSorting
  • extensions / JADE
  • extensions / JsonConfig
  • extensions / LdapGroups
  • extensions / Lingo
  • extensions / LocalisationUpdate
  • extensions / Lockdown
  • extensions / MassMessage
  • extensions / MediaWikiAuth
  • extensions / NewUserActions
  • extensions / OAuth
  • extensions / OAuthAuthentication
  • extensions / ORES
  • extensions / PageNameFormula
  • extensions / PageViewInfo
  • extensions / ParserMigration
  • extensions / PhpTags
  • extensions / PhpTagsFunctions
  • extensions / PhpTagsSMW
  • extensions / PhpTagsSPARQL
  • extensions / PhpTagsWidgets
  • extensions / PhpTagsWiki
  • extensions / PluggableSSO
  • extensions / Popups
  • extensions / StopForumSpam
  • extensions / TemplateWizard
  • extensions / TextExtracts
  • extensions / UILangCode
  • extensions / UnCaptcha
  • extensions / VEForAll
  • extensions / WhoIsWatching
  • extensions / WikibaseQualityExternalValidation
  • extensions / XenForoAuth
  • extensions / ZeroBanner
  • extensions / ZeroPortal

and more that are not in extension/*.

Event Timeline

Reedy created this task.Dec 15 2017, 2:02 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 15 2017, 2:02 AM
Reedy updated the task description. (Show Details)Dec 15 2017, 2:04 AM
Reedy updated the task description. (Show Details)
Aklapper updated the task description. (Show Details)Dec 15 2017, 4:11 PM
Aklapper updated the task description. (Show Details)Dec 18 2017, 11:08 AM

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

Aklapper updated the task description. (Show Details)Dec 19 2017, 10:26 AM

@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

Aklapper edited projects, added Epic; removed Patch-For-Review.Feb 11 2018, 10:07 PM

@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=

xSavitar updated the task description. (Show Details)Sep 21 2018, 9:55 PM
xSavitar updated the task description. (Show Details)Sep 21 2018, 9:57 PM
xSavitar added a project: Google-Code-in-2018.
xSavitar moved this task from Proposed tasks to Missing mentors on the Google-Code-in-2018 board.