Page MenuHomePhabricator

[Task] Make the Wikibase.git code base PSR-4 compatible
Open, LowPublic

Description

Being "PSR-4 compatible" means that the full qualified name of a class is equal to its directory and file name. For example, the file …/Wikibase/client/includes/Api/ApiClientInfo.php contains the class \Wikibase\Client\Api\ApiClientInfo. The mapping for this can be found in Wikibase.git's extension-*-wip.json files in the "AutoloadNamespaces" section: "Wikibase\\Client\\Api\\": "client/includes/Api/" and so on.

Even if most classes in the Wikibase.git code base are already PSR-4 compatible, some are not, which is the reason why there are still such long autoload.php files.

The goal of this ticket is to get rid of the autoload.php files and the build/generateAutoload.php script generating them.

  • This ticket is not about the components in the vendor directory (DataValues, Wikibase-DataModel and so on). Changing these is more troublesome because it usually means a breaking release of the component must be made. This is barely worth the trouble.
  • It might not be possible to make the maintenance directories PSR-4 compatible, because the file names must follow the naming scheme of maintenance scripts, and can not be made equal to the class name in these file.
  • I suggest to create a chain of small patches, each one only touching a single directory, or even a single class if it happens to be used a lot. This makes reviewing much easier.
  • You must make sure other code repositories that use Wikibase.git classes are updated when you change the namespace of a class. Use MediaWiki code search for this.

Details

Related Gerrit Patches:
mediawiki/extensions/Wikibase : masterMove most client and repo init to extension callback
mediawiki/extensions/Wikibase : masterAutoload as much as possible of lib, repo, client
mediawiki/extensions/Wikibase : masterFix namespace of MockClientStore
mediawiki/extensions/Wikibase : masterMove all classes in lib/includes/Formatters into \Wikibase\Lib\Formatters
mediawiki/extensions/Wikibase : masterAdjust namespace of several classes in repo to make them follow PSR-4
mediawiki/extensions/Wikibase : masterRemove some more PSR-4 classes from autoload.php
mediawiki/extensions/Wikibase : masterMake SqlSubscriptionLookup and SqlChangeDispatchCoordinator follow PSR-4
mediawiki/extensions/Wikibase : masterMake UpsertSqlIdGenerator follow PSR-4
mediawiki/extensions/Wikibase : masterAdd test directories to client+lib AutoloadNamespaces
mediawiki/extensions/Wikibase : masterMove classes in Elastic/ subdirectory to \Elastic subnamespace
mediawiki/extensions/Wikibase : masterFix namespaces of Fake{LoadBalancer,LBFactory}
mediawiki/extensions/Wikibase : masterRemove compatibility class aliases
mediawiki/extensions/Wikibase : masterRemove PSR-4-compliant parts from repo and client
mediawiki/extensions/Wikibase : masterRemove PSR-4-compliant parts from lib/autoload.php
mediawiki/extensions/Wikibase : master[WIP] Make the entire lib/includes/Store folder PSR-4 compatible
mediawiki/extensions/Wikibase : masterMake trivial classes in the lib/includes/Store folder PSR-4 compatible
mediawiki/extensions/Wikibase : masterMake the namespace of the EntityRevision class PSR-4 compatible

Event Timeline

Restricted Application added subscribers: PokestarFan, Aklapper. · View Herald TranscriptAug 3 2017, 9:30 AM
thiemowmde triaged this task as Low priority.Aug 3 2017, 9:32 AM
thiemowmde moved this task from incoming to ready to go on the Wikidata board.
Ricordisamoa updated the task description. (Show Details)Aug 3 2017, 10:49 AM
Ricordisamoa added a subscriber: Ricordisamoa.

Change 370157 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Make the namespace of the EntityRevision class PSR-4 compatible

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

Change 370157 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make the namespace of the EntityRevision class PSR-4 compatible

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

We took a look at the patch submitted against this issue & tried to look at the PSR-4 spec & couldn't find reference to the way in which the word 'includes' in the file path was not part of the namespace - do you have a link for that?

@Eileenmcnaughton, I assume you are talking about the patch https://gerrit.wikimedia.org/r/356646. The key is this line in Wikibase' composer.json that does the mapping:

"Wikibase\\Lib\\": "lib/includes"

This line already exists. Thats why you don't see it being touched in the patch. Does this help with your question?

Change 371059 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Make trivial classes in the lib/includes/Store folder PSR-4 compatible

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

Change 356646 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] [WIP] Make the entire lib/includes/Store folder PSR-4 compatible

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

thiemowmde updated the task description. (Show Details)Aug 10 2017, 3:40 PM

Change 371059 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make trivial classes in the lib/includes/Store folder PSR-4 compatible

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

Change 356646 abandoned by Thiemo Kreuz (WMDE):
[WIP] Make the entire lib/includes/Store folder PSR-4 compatible

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

Change 515093 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move all classes in lib/includes/Formatters into \Wikibase\Lib\Formatters

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

Change 515101 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove compatibility class aliases

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

Change 515093 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move all classes in lib/includes/Formatters into \Wikibase\Lib\Formatters

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

Change 521968 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Remove parts of PSR-4-complient from lib/autoload.php

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

Change 521968 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove PSR-4-compliant parts from lib/autoload.php

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

Change 522145 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Remove PSR-4-compliant parts from repo and client

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

Change 522145 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove PSR-4-compliant parts from repo and client

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

Change 522505 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] WIP: Autoload as much as possible of lib, repo, client

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

Change 515101 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove compatibility class aliases

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

Change 522517 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move most client and repo init to extension callback

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

Change 522519 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add test directories to client+lib AutoloadNamespaces

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

Change 523203 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Fix namespaces of Fake{LoadBalancer,LBFactory}

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

Change 523204 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move classes in Elastic/ subdirectory to \Elastic subnamespace

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

Change 523203 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix namespaces of Fake{LoadBalancer,LBFactory}

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

Change 523204 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move classes in Elastic/ subdirectory to \Elastic subnamespace

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

Change 522519 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add test directories to client+lib AutoloadNamespaces

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

Change 523237 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Fix namespace of MockClientStore

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

Change 530333 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Make UpsertSqlIdGenerator follow PSR-4

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

Change 530333 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make UpsertSqlIdGenerator follow PSR-4

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

Change 530387 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Make SqlSubscriptionLookup and SqlChangeDispatchCoordinator follow PSR-4

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

Change 530387 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make SqlSubscriptionLookup and SqlChangeDispatchCoordinator follow PSR-4

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

Change 532085 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Remove some more PSR-4 classes from autoload.php

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

Change 532088 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Adjust namespace of several classes in repo to make them follow PSR-4

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

Change 532085 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove some more PSR-4 classes from autoload.php

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

Change 532088 merged by Ladsgroup:
[mediawiki/extensions/Wikibase@master] Adjust namespace of several classes in repo to make them follow PSR-4

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

Change 523237 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix namespace of MockClientStore

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