Page MenuHomePhabricator

Convert Translate to use extension registration
Open, LowPublic

Description

The Translate extension needs to be converted to use the new extension registration system. More details are available on T87875. From the duplicate task:

Most extensions have been converted to use extension.json by now. Translate, with it's lengthy setup file has eluded this conversion despite multiple attempts. I think the reasons for this are:

  • Fully automatic conversion is not possible with Translate
  • The patch is huge and difficult to review manually
  • The patch gets stale because it doesn't get reviewed in time

And the cycle repeats. My proposal to stop this cycle is to do it in smaller steps:

  1. Add a minimal extension-wip.json with extension info, add an unconditional wfLoadExtension( 'Translate', __DIR__ . /extension-wip.json' ) to Translate.php.
  2. Move data to extension.json in smaller steps: e.g. one patch for resource loader modules, one patch for autoload and so on.

Special notes:

  • extension.json name cannot be used before it is ready (Jenkins test fails)
  • i18n things cannot be removed from Translate.php before extension.json is ready

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 29 2015, 7:33 PM
Nikerabbit triaged this task as Low priority.Jan 30 2015, 3:24 AM
Nikerabbit added a subscriber: Nikerabbit.

Translate extension has many third party users and targets MW 1.23+ compatibility, so please be extra careful that that is not broken.

Liuxinyu970226 set Security to None.

Change 237739 had a related patch set uploaded (by Paladox):
Add extension.json, empty php entry point

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

Change 237739 abandoned by Nikerabbit:
Add extension.json, empty php entry point

Reason:
This patch is now stale. It will be easier to re-do it when we are ready rather than trying to rebase this.

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

OK, @Krinkle and I talked about this and, iirc, one objection was the wfAddNamespace function, which is called by many third parties? So, one solution would be:

In the resulting PHP entry point (which should only call wfLoadExtension) you could define the function. For the ExtensionRegistration part you could require the users to migrate to an array of namespaces that should be added (an array which contains all information requested by the wfAddNamespace function). In an extension callback, you register these namespaces.

This should keep backwards compatibility (even if it has some (acceptable?) code duplication.

I'm not sure how the Translate extension is versions, but if you use the release branches which are created with every core release, you should be save :)

OK, @Krinkle and I talked about this and, iirc, one objection was the wfAddNamespace function, which is called by many third parties? So, one solution would be:

In the resulting PHP entry point (which should only call wfLoadExtension) you could define the function. For the ExtensionRegistration part you could require the users to migrate to an array of namespaces that should be added (an array which contains all information requested by the wfAddNamespace function). In an extension callback, you register these namespaces.

I was actually planning for a simpler solution: move the function to separate php file, include that in the current entry point. Advice people that when they move to extension registration, they need to include this file in their localsettings.php or copy the function. It's just a helper, not essential functionality of Translate.

I'm not sure how the Translate extension is versions, but if you use the release branches which are created with every core release, you should be save :)

Not possible, Translate is part of MLEB with strict compatibility policy for master branch.

That would be possible, too. However, for the time between migrating to the new extension registration, you could still include this separate file with the function in your PHP entry point.

Krinkle removed a subscriber: Krinkle.Oct 23 2017, 5:54 PM

Change 391645 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/Translate@master] [WIP] Convert to static extension loading

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

Reedy added a subscriber: Reedy.Apr 26 2018, 2:42 PM

^ is done against master...

(I tried to search for this task but failed, I guess I should have looked at the patch instead, hence the new task)

Izno updated the task description. (Show Details)Sep 11 2018, 9:48 PM

I wonder if we could get away with doing the minimal support structure in extension.json, probably with AutoloadClasses...

Then just do the rest of the PHP loading in the callback?

Krinkle removed a subscriber: Krinkle.Sep 12 2018, 4:20 AM

The plan suggested in T204019 sounds good to me.

Change 471703 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] Add minimal extension.json

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

Change 471704 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] Move i18n files to extension.json

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

Change 471703 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Add minimal extension.json

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

Change 471704 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Move i18n files to extension.json

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

Nikerabbit updated the task description. (Show Details)

Change 472112 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] extension.json: Remove $wgParserTestFiles

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

Change 472114 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] extension.json: port jobs

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

Change 472116 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] extension.json: port rights and grants

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

Change 472112 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] extension.json: Remove $wgParserTestFiles

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

Change 472114 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] extension.json: port jobs

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

Change 472116 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] extension.json: port rights and grants

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

awight added a subscriber: awight.Jan 16 2019, 5:22 PM

Change 484818 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] Autoload using extension registration

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

Change 484819 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] Load ResourceLoader modules using extension registration

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

Change 484821 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] Register hooks using extension.json

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

Change 484826 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] Extension registration for special pages

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

Change 484827 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] extension registration for API modules

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

Change 484829 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] extension registration for default user options

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

Change 484830 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] extension registration for default configuration

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

Change 484833 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Translate@master] Registration for translation message dirs

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

Change 484821 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Register hooks using extension.json

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

@Nikerabbit Hi, are we unblocked now that MLEB 2019.01 is released?

Change 484818 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Autoload using extension registration

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

Change 484826 merged by Nikerabbit:
[mediawiki/extensions/Translate@master] Extension registration for special pages

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

Change 484827 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Extension registration for API modules

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

Change 484819 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Load ResourceLoader modules using extension registration

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

Change 484829 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Extension registration for default user options

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

Change 391645 abandoned by Jforrester:
Convert to static extension loading

Reason:
Finalised with I3b90a9d587.

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

Change 490117 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/Translate@master] Hard-deprecate loading the extension via Translate.php

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

Change 490118 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/Translate@master] Remove PHP entry point

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

awight removed a subscriber: awight.Mar 21 2019, 4:07 PM

Change 484830 had a related patch set uploaded (by Jforrester; owner: Adam Wight):
[mediawiki/extensions/Translate@master] extension registration for default configuration

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

Change 484833 had a related patch set uploaded (by Jforrester; owner: Adam Wight):
[mediawiki/extensions/Translate@master] Cleanups for extension registration work

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

Change 490117 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/Translate@master] Hard-deprecate loading the extension via Translate.php

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

Change 490118 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/Translate@master] Remove PHP entry point

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