Commit graph

24 commits

Author SHA1 Message Date
victorbarbu
3a7d5067c7 convertExtensionToRegistration.php: die on global functions
Bug: T122952
Change-Id: I0fca5457aba3a7237ad7aeb96f3f6636d73863d3
2016-01-09 21:50:11 +00:00
Florian
9dec78d4c0 convertExtensionToRegistration: Detect if composer autoloader is needed
If an extension specifies a require section in its composer.json, which contains
some dependencies, we can assume that this extension needs to load the composer
autoloader.

The maintenance script convertExtensionToRegistration.php will now check if the
extension has such a composer.json and, if so, adds the load_composer_autoloader
property in extension.json, which will try to load the autoloader of composer
is it is present.

Also add a check for existence of a require section in ComposerJson library
(ComposerJson::getRequiredDependencies()). 

Bug: T119766
Change-Id: Icdbc37abc44e642afee2aab4c0e9298d3471124d
2016-01-07 17:23:34 +00:00
Paladox
318546d6b8 registration: When converting, place 'namemsg' under 'name'
Currently when converting from PHP to extension.json, 'namemsg' isn't
underneath 'name', it is halfway down instead.

Change-Id: I1be42a818bda6908643702cc5f7c959d2d2fdfba
2015-12-14 16:55:38 +00:00
Mark A. Hershberger
89282735ff Add error checking for file argument
If the user ignorantly passes in ".", this will fail.

Change-Id: I1128945b7277ce7b3da27eb30b2dfbbf644c9d38
2015-11-12 17:15:07 -05:00
umherirrender
c81540d725 Remove deprecated $wgSpecialPageGroups
$wgSpecialPageGroups is deprecated since 1.21
override SpecialPage::getGroupName instead

Remove also SpecialPageFactory::setGroup because it no long can set $wgSpecialPageGroups.
Also remove SpecialPageFactory::getGroup along with its setter.

All replaces in extensions can be found under:
https://gerrit.wikimedia.org/r/#/q/status:open+branch:master+topic:wgSpecialPageGroups,n,z
https://gerrit.wikimedia.org/r/#/q/status:merged+branch:master+topic:wgSpecialPageGroups,n,z

Change-Id: I1aa8f98bf326b2e54d7403efbb9f002a106cefc5
2015-06-26 19:19:17 -07:00
paladox
889f83dc9b Fix phpcs warnings
Change-Id: I2d7dbf7314257a3ad8f5f6b97a6949a2500d298f
2015-06-17 20:06:42 +00:00
Vivek Ghaisas
5132a68683 Remove multiple empty lines in functions
Functions must not contain multiple empty lines in a row
(Squiz.WhiteSpace.SuperfluousWhitespace sniff).

Bug: T102774
Change-Id: Ib706e4fc34b95c0d7c887e54af0ea61227767d8f
2015-06-17 13:30:57 +03:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Kunal Mehta
a1368a3d9b registration: Version the extension.json schema
Versioning the extension.json schema will allow us to make breaking changes
to the schema in a non-breaking manner.

Extensiosn and skins will set a 'manifest_version' value, stating which
version of the schema the file is written for. Processor::extractInfo() will
be  passed the version number, and can switch behavior depending upon it.

For backwards-compatability, a version number of 1 is assumed if none is set.
The validateRegistrationFile.php script will emit a warning if this is the
case.

Bug: T99344
Change-Id: I2086a1465ceaeedd1ccc6804fda2c304ad16ffa0
2015-05-28 22:20:59 +00:00
jenkins-bot
5bb693f6d4 Merge "registration: Don't ignore empty array config settings when converting" 2015-05-21 17:33:05 +00:00
Kunal Mehta
e66864878a registration: Don't ignore empty array config settings when converting
Remember which settings we set to an empty array and then only skip
those settings.
The weird variable name "$__settings" is used to avoid any conflicts
similar to what eval.php does.

Bug: T98739
Change-Id: Iefbf8a98fd433cfbe0087aca6821d90c2786b0cb
2015-05-21 10:22:05 -07:00
umherirrender
d06aaa9b20 Do not allow setting deprecated $wgSpecialPageGroups over extension.json
$wgSpecialPageGroups is deprecated since 1.21
The code should be migrated to override SpecialPage::getGroupName before
adding an extension.json to the extension, instead of allowing setting
this over extension.json

Also added a warning to convertExtensionToRegistration.php for the no
longer supported global

Change-Id: Idccbe41b649de93548c5b0fca03145da716bcc65
2015-05-16 22:26:33 +02:00
Kunal Mehta
2b81c4ca36 registration: Add support for $wgParserTestFiles
Bug: T97921
Change-Id: I9a736a4c0ff739c4acf742b8f17792544851b28e
2015-05-02 23:16:54 -07:00
Kevin Israel
c9b73a38bc convertExtensionToRegistration.php: Ignore i18n shims
Bug: T91350
Change-Id: I18b35db14a13f58909bce83fec11bf9e8f10672d
2015-04-30 23:32:44 -04:00
jenkins-bot
0cd36fec25 Merge "convertExtensionToRegistration: Still convert $wgTrackingCategories" 2015-04-07 16:18:19 +00:00
Kunal Mehta
77a813f21f registration: Support ResourceModuleSkinStyles
Structurally, it's set up exactly the same as ResourceModules, so we can
re-use the same code.

Bug: T91566
Change-Id: I7cd1330edc3e97b4658c81aac67071a90ac61fb6
2015-04-07 08:43:16 -07:00
Kunal Mehta
912a5e5ec3 registration: Add resource template-like functionality to extension.json
This allows for extensions to specify common arguments to ResourceLoader
module definitions by only specifying them once.

The only supported values are "localBasePath" (which is relative to the
current directory), "remoteSkinPath", and "remoteExtPath". If a module
is using a custom class or is already specifying paths, the default paths
will not be added.

Tests are included to cover existing functionality and newly added
functionality. The convertExtensionToRegistration.php script was also
extended to try and guess what the default paths should be.

Bug: T88786
Change-Id: I802461796e8d8584dacf3b0c811b5ba97a4a8f7f
2015-02-09 15:14:06 -08:00
Kunal Mehta
024ad10b45 convertExtensionToRegistration: Still convert $wgTrackingCategories
It's an attribute now rather than a global, but we still want
to convert it.

This follows up 247ecab445.

Change-Id: Ibb61b1689e3e6b454d7bf2f300ab465e30ca774a
2015-01-29 15:21:14 -08:00
Kunal Mehta
89c3ef0baf convertExtensionToRegistration: Add --skin option
To write to skin.json instead of extension.json

Change-Id: I0e7dfbd871b7f80958fe7033d4595a205bb34293
2015-01-29 12:24:49 -08:00
Kunal Mehta
76972de9ca convertExtensionToRegistration: Document parameters
Bug: T87620
Change-Id: I0326632c24bf429cd09f4e51f6e6990536d6c76f
2015-01-26 15:02:03 -08:00
Kunal Mehta
f777e4500d convertExtensionToRegistration: Move 'namemsg' to top as well
Change-Id: Ib2bac10980fee3bb2704219a80ec55a4b8c55607
2015-01-26 21:24:19 +00:00
Kunal Mehta
77d38f651f convertExtensionToRegistration: Put some keys (name, version, etc.) on top
Bug: T86608
Change-Id: I4b8e48e8d2d23c3b7e3f0b49bfa9c8941b5a3434
2015-01-13 11:31:45 -08:00
Kunal Mehta
f6cc92c74b Handle more cases in convertExtensionToRegistration.php
* Handle constructs like $wgResourceModules += array(...)
* Support $wgMessagesDirs['FooBar'] = array(...)
* Handle stripping paths where it is the current directory
* Use FormatJson::ALL_OK when writing the file

Bug: T86311
Change-Id: I9434f6634fd6e460a5c2f6dac95c9065da35a51a
2015-01-13 02:05:33 +00:00
Kunal Mehta
bfe4ddd810 Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.

Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.

The basic flow of loading an extension goes like:
 * Get the ExtensionRegistry singleton instance
 * ExtensionRegistry takes a filename, reads the file or tries
   to get the parsed JSON from APC if possible.
 * The JSON is run through a Processor instance,
   which registers things with the appropriate
   global settings.
 * The output of the processor is cached in APC if possible.
 * The extension/skin is marked as loaded in the
   ExtensionRegistry and a callback function is executed
   if one was specified.

For ideal performance, a batch loading method is also provided:
 * The absolute path name to the JSON file is queued
   in the ExtensionRegistry instance.
 * When loadFromQueue() is called, it constructs a hash
   unique to the members of the current queue, and sees
   if the queue has been cached in APC. If not, it processes
   each file individually, and combines the result of each
   Processor into one giant array, which is cached in APC.
 * The giant array then sets various global settings,
   defines constants, and calls callbacks.

To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.

Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2015-01-08 01:40:01 +00:00