Page MenuHomePhabricator

Make the Wikibase.git code base PSR-4 compatible
Closed, ResolvedPublic

Description

As a Wikibase developer working on maintaining the PHP Codebase it would be good to know in which component code resides depending on the namespace therefore we can follow this common convention of PSR-4. We would also be able to remove our non-standard Autoload file (and autoload file generation scripts).

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.

Acceptance criteria:

  • All PHP classes inside Wikibase git repositories are PSR-4-compliant
    • client | Wikibase\Client
    • data-access | Wikibase\DataAccess
    • lib | Wikibase\Lib
    • repo | Wikibase\Repo
    • view | Wikibase\View
  • autoload.php files are no longer used and removed
  • build/generateAutoload.php script is removed

Note: There is no exhaustive list here to remove. If the code all still works with autoload.php removed we know we met our goal.

Details

ProjectBranchLines +/-Subject
mediawiki/extensions/Wikibasemaster+108 -0
mediawiki/extensions/Wikibasemaster+0 -3
mediawiki/extensions/Wikibasemaster+10 -15
mediawiki/extensions/Wikibasemaster+10 -0
mediawiki/extensions/Wikibasemaster+4 -2
mediawiki/extensions/Wikibasemaster+22 -121
mediawiki/extensions/Wikibasemaster+11 -117
mediawiki/extensions/Wikibasemaster+1 K -1 K
mediawiki/extensions/Wikibasemaster+146 -138
mediawiki/extensions/Wikibasemaster+100 -74
mediawiki/extensions/Wikibasemaster+7 -5
mediawiki/extensions/Wikibasemaster+32 -29
mediawiki/extensions/Wikibasemaster+15 -12
mediawiki/extensions/Wikibasemaster+25 -21
mediawiki/extensions/Wikibasemaster+15 -20
mediawiki/extensions/Wikibasemaster+41 -43
mediawiki/extensions/Wikibasemaster+6 -6
mediawiki/extensions/Wikibasemaster+11 -14
mediawiki/extensions/Wikibasemaster+80 -74
mediawiki/extensions/Wikibasemaster+48 -56
mediawiki/extensions/Wikibasemaster+1 -11
mediawiki/extensions/Wikibasemaster+42 -23
mediawiki/extensions/WikimediaMaintenancemaster+1 -1
mediawiki/extensions/Wikibasemaster+11 -12
mediawiki/extensions/Wikibasemaster+60 -72
mediawiki/extensions/Wikibasemaster+1 -67
mediawiki/extensions/Wikibasemaster+5 -196
mediawiki/extensions/Wikibasemaster+1 -82
mediawiki/extensions/Wikibasemaster+13 -9
mediawiki/extensions/Wikibasemaster+272 -257
mediawiki/extensions/Wikibasemaster+28 -25
mediawiki/extensions/Wikibasemaster+3 -59
mediawiki/extensions/Wikibasemaster+13 -14
mediawiki/extensions/Wikibasemaster+6 -5
mediawiki/extensions/Wikibasemaster+3 -24
mediawiki/extensions/Wikibasemaster+11 -8
mediawiki/extensions/Wikibasemaster+14 -16
mediawiki/extensions/Wikibasemaster+0 -28
mediawiki/extensions/Wikibasemaster+39 -376
mediawiki/extensions/Wikibasemaster+29 -47
mediawiki/extensions/Wikibasemaster+59 -66
mediawiki/extensions/Wikibasemaster+29 -29
mediawiki/extensions/Wikibasemaster+42 -44
Show related patches Customize query in gerrit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

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

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

Change 522505 abandoned by Lucas Werkmeister (WMDE):
Autoload as much as possible of lib, repo, client

Reason:
This approach didn’t work out, but we’ve made good progress in the meantime.

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

Change 574052 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Use PSR-4 for \Wikibase\Lib\Store namespace

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

Change 574052 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use PSR-4 for \Wikibase\Lib\Store namespace

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

Change 578982 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] PSR-4 autoload as much as possible of repo

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

Change 578982 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] PSR-4 autoload as much as possible of repo

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

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

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

Change 592400 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/WikimediaMaintenance@master] Fix namespace of PopulateSitesTable

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

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

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

Change 592405 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Make Wikibase\Rdf\Values namespace follow PSR-4

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

Change 592405 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make Wikibase\Rdf\Values namespace follow PSR-4

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

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

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

Change 592702 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move Action classes to right namespace

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

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

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

Change 592400 merged by jenkins-bot:
[mediawiki/extensions/WikimediaMaintenance@master] Fix namespace of PopulateSitesTable

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

Change 596699 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move Content classes to right namespace

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

Change 592702 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move Action classes to right namespace

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

Change 597107 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move repo maintenance tests to correct namespace

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

Change 597113 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add populateSitesTable.php back to lib/autoload.php

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

Change 597127 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move some Repo classes to the right namespace

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

Change 597113 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add populateSitesTable.php back to lib/autoload.php

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

Change 597127 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move some Repo classes to the right namespace

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

Change 596699 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move Content classes to right namespace

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

Change 597107 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move repo maintenance tests to correct namespace

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

Change 603406 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Move two maintenance script to the right namespace

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

Change 603406 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move two maintenance script to the right namespace

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

Change 603478 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move RepoHooks to \Wikibase\Repo + repo/includes/

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

Change 603478 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move RepoHooks to \Wikibase\Repo + repo/includes/

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

Change 603958 had a related patch set uploaded (by Itamar Givon; owner: Itamar Givon):
[mediawiki/extensions/Wikibase@master] Move Wikibase\Dump to Wikibase\Repo\Dump

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

Change 603958 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move Wikibase\Dumpers to Wikibase\Repo\Dumpers

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

Change 604029 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move CopyrightMessageBuilder to right namespace

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

Change 604039 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move Store to right namespace

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

WMDE-leszek updated the task description. (Show Details)Jun 9 2020, 3:02 PM
WMDE-leszek removed a project: patch-welcome.
WMDE-leszek removed a subscriber: Aleksey_WMDE.
Lucas_Werkmeister_WMDE raised the priority of this task from Low to Medium.Jun 9 2020, 3:27 PM

Change 604053 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move CopyrightMessageBuilder to right namespace

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

Change 604039 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move Store to right namespace

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

Change 604029 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move CopyrightMessageBuilder to right namespace

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

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

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

WMDE-leszek updated the task description. (Show Details)Jun 9 2020, 5:23 PM
WMDE-leszek updated the task description. (Show Details)
WMDE-leszek updated the task description. (Show Details)
WMDE-leszek updated the task description. (Show Details)Jun 9 2020, 5:27 PM

Change 604053 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move SummaryFormatter to right namespace

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

Change 604351 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move some \Wikibase\Rdf classes to \Wikibase\Repo\Rdf

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

Tarrow updated the task description. (Show Details)Jun 10 2020, 11:55 AM
WMDE-leszek updated the task description. (Show Details)Jun 10 2020, 1:32 PM
WMDE-leszek renamed this task from [Task] Make the Wikibase.git code base PSR-4 compatible to Make the Wikibase.git code base PSR-4 compatible.Jun 10 2020, 1:56 PM

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

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

Change 604351 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move some \Wikibase\Rdf classes to \Wikibase\Repo\Rdf

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

Change 604735 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move \Wikibase\Rdf classes to \Wikibase\Repo\Rdf

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

Change 604735 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move \Wikibase\Rdf classes to \Wikibase\Repo\Rdf

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

Change 522517 abandoned by Lucas Werkmeister (WMDE):
Move most client and repo init to extension callback

Reason:
not needed, see previous comment

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

Change 605215 had a related patch set uploaded (by Tarrow; owner: Tarrow):
[mediawiki/extensions/Wikibase@master] Remove Wikibase Repo autoload.php

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

Change 604784 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Tarrow):
[mediawiki/extensions/Wikibase@master] Remove the last autoload.php

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

Change 605215 abandoned by Tarrow:
Remove Wikibase Repo autoload.php

Reason:
basically duplicate of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/ /604784

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

Change 605566 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove \Wikibase\Repo\Maintenance from AutoloadNamespaces

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

Change 604784 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove the last autoload.php

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

Change 605566 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove \Wikibase\Repo\Maintenance from AutoloadNamespaces

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

Change 605624 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Move ViewHooks to \Wikibase\View + view/src/

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

Change 605646 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove AutoloadClasses for populateSitesTable.php

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

Change 605647 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add ADR for using PSR-4 and AutoloadNamespaces

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

Change 605624 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move ViewHooks to \Wikibase\View + view/src/

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

Change 605646 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove AutoloadClasses for populateSitesTable.php

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

Lucas_Werkmeister_WMDE closed this task as Resolved.Tue, Jun 16, 9:15 AM
Lucas_Werkmeister_WMDE updated the task description. (Show Details)
Lucas_Werkmeister_WMDE updated the task description. (Show Details)

DONE.

Change 605647 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add ADR about PSR-4 and maintenance scripts

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