Commit graph

23 commits

Author SHA1 Message Date
Kunal Mehta
9cdf419be5 registration: Improve error message if a non-array attribute is set
Otherwise array_merge_recursive() will trigger a confusing and unhelpful
warning.

Bug: T102523
Change-Id: I7e4778cb7552fe93a08f315c9888ec64322e2501
2015-06-16 16:08:44 -07: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
aaef99cbb6 Merge "Do not allow setting deprecated $wgSpecialPageGroups over extension.json" 2015-05-20 04:48:59 +00:00
Kunal Mehta
a3f47a5915 registration: Use a static whitelist of keys that are not attributes
Rather than continuously creating an array of keys that were used, just
hardcode a list of keys that aren't attributes. This also handles keys
like "AutoloadClasses" that is handled by the registry.

Bug: T98977
Change-Id: I35088a76ff4c58db71e8c9bc139fa0ccca738e3b
2015-05-17 23:32:33 -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
2fcd5d7909 registration: Fix having multiple callbacks for a single hook
Bug: T98975
Change-Id: I40ff36090d18344fabdb018519209671b7883fa1
2015-05-13 12:30:21 -07:00
Kunal Mehta
2b81c4ca36 registration: Add support for $wgParserTestFiles
Bug: T97921
Change-Id: I9a736a4c0ff739c4acf742b8f17792544851b28e
2015-05-02 23:16:54 -07:00
Kunal Mehta
e5aca92ebc registration: Support $wgMediaHandlers in ExtensionProcessor
Bug: T97908
Change-Id: I3bea9273f956d93aebc5176b83d375c574715382
2015-05-02 21:06:34 -07:00
Kunal Mehta
16b44c4146 registration: Support 'namemsg'
Change-Id: I0f446b31c1d36a492997ef31fae6d2d2bea36517
2015-04-07 08:43:39 -07: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
ade66c04e9 Add "ValidSkinNames" to extension.schema.json and ExtensionProcessor
skin.json goes through the same exact code as extension.json does, and needs
to be able to add skins.

Change-Id: Idd0acaf6735b4c308d3ab584c49da4e97448347f
2015-03-04 12:34:35 -08:00
Kunal Mehta
18aab5e395 registration: Apply ResourceFileModulePaths to all modules
Previously any module definition that specified a "class" was skipped. This
is problematic for custom modules that extend ResourceLoaderFileModule and
should be using the default paths.

Since we can't determine at initialization time whether a module class is a
ResourceLoaderFileModule or not, just add the default paths to all modules,
and leave it up to the individual classes to use the extra arguments or not.

Change-Id: Iee5d178343326030968755983f62629b81ef3c88
2015-02-11 01:46:11 +00:00
jenkins-bot
884ac54872 Merge "registration: Add resource template-like functionality to extension.json" 2015-02-09 23:21:09 +00: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
7067b6130d registration: Fix regression in ExtensionMessagesFiles handling
In f2daeaa749, the handling of MessageDirs was fixed to properly
handle arrays, except that broke ExtensionMessagesFiles which doesn't
support arrays. Since both settings are pretty much different, I split
them into separate functions.

Bug: T88858
Change-Id: I48765af2489d2ef1e30adb1d7c5a5a8f23bf522d
2015-02-06 15:02:26 -08:00
Kunal Mehta
f2daeaa749 registration: Fix handling of MessagesDirs array and add tests
Previously the code was designed to handle:
  "MessagesDirs": {
    "FooBar": "i18n"
  }

However, it can also be an array, and some extensions (VisualEditor)
use it like:

  "MessagesDirs": {
    "FooBar": [
      "i18n",
      "also-i18n"
    ]
  }

This properly handles both strings and arrays and adds tests to verify
the behavior.

Change-Id: Iff1523b86f754cac1f5b8d822d4324c5fbfc1a50
2015-01-30 13:00:22 -08:00
Kunal Mehta
920ef42ae0 registration: Ignore keys prefixed with @ in "config"
This will allow for documentation of individual configuration
options.

Change-Id: I180bc742c96985c2a8358aef814d993fca9aba84
2015-01-26 23:00:07 -08:00
Kunal Mehta
cd73babf22 Merge "SpecialTrackingCategories: Read from the extension registry" 2015-01-23 19:09:21 +00:00
Kunal Mehta
247ecab445 SpecialTrackingCategories: Read from the extension registry
This demonstrates how we can transition from extensions putting
things into the global scope ($wgTrackingCategories) to instead
storing them in the extension registry. This will increase the
overall performance of the extension registry since it no
longer needs to do an array_merge with $wgTrackingCategories.

For extensions already converted to using the registry
no change is needed as the schema is still the same.

Change-Id: Ie0df4c20b123dac784a1c02eb991edc609a911b6
2015-01-23 10:33:45 -08:00
Kunal Mehta
896b9b5c65 registration: Ignore attributes that start with @
Allow these to be used for fake comments or other information
that should not be loaded.

Change-Id: Id79cd8b18988b94db565b2ddbc31ee6f17a89fca
2015-01-13 11:49:09 -08:00
Kunal Mehta
e1425750fa registration: Add ConfigRegistry to the extension.json schema
Change-Id: I6918215e3b5b2dd4c993d8a8767dc3ce998bd5ed
2015-01-13 01:25:09 +00:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01: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