Commit graph

36 commits

Author SHA1 Message Date
mhutti1
476f55fe0a registration: Allow setting $wgFeedClasses in extension.json
Bug: T122770
Change-Id: I5362ec4c6ea01f4d49d576d5767e9cce4f421046
2016-01-03 22:03:17 +00:00
Kunal Mehta
2d534f3ea6 registration: Allow setting $wgCentralIdLookupProviders
Follows up d032bb52cd.

Change-Id: I43f4fb3d7b2fafc437abcfda73bf865aa8600ba2
2016-01-02 16:09:23 +00:00
victorbarbu
7489cdfc05 registration: Allow loading composer's autoloader if it exists
Extensions that have composer dependencies can set
 "load_composer_autoloader": true
to load "$dir/vendor/autoload.php" if it exists.

While it is recommended to use composer-merge-plugin to manage
composer dependencies for extensions, using a local autoloader
can be easier for development and is used by ExtensionDistributor.

Bug: T119766
Change-Id: Ib031bef17c8a7d708a5c7878e74967d19217bbc8
2015-12-29 23:20:17 +00:00
Kunal Mehta
585c0398af registration: Remove type validation for "config" items
The type list was missing "number" for doubles, but since we allow *all*
types of variables, don't even bother checking types.

Bug: T120507
Change-Id: I10626f5764f49d4f96a3cc35a27c890905a71bfe
2015-12-04 21:04:51 -08:00
Kunal Mehta
7014e432cf registration: Support custom classes in "ResourceModules" schema
Instead of expecting everything to be a ResourceLoaderFileModule, use
the "anyOf" property to validate against multiple schemas. The following
schemas are now allowed:
* The ResourceLoaderFileModule schema, now with the "targets" property
* A schema for ResourceLoaderImageModule
* A generic schema that requires the "class" property is set, but not to
"ResourceLoaderFileModule" or "ResourceLoaderImageModule".

The last schema will allow for any custom ResourceLoaderModule class to
be set in extension.json with arbitrary parameters.

One downside of this is that the error messages shown when a file does
not validate get a little more confusing, as it shows the error messages
for each schema it does not match.

Bug: T105236
Change-Id: I5e4bfa69c733187c7b27294c159cac05b3b92e81
2015-10-27 04:45:27 +00:00
jenkins-bot
35f61c7c4b Merge "registration: Allow extensions to specify which MW core versions they require" 2015-09-22 04:57:47 +00:00
Kunal Mehta
cef1f31167 registration: Allow extensions to specify which MW core versions they require
This adds a "requires" property to extension.json, which extensions and
skins can use to indicate which versions of MediaWiki core they support.
The hacky wfUseMW() is now deprecated in favor of this.

Rather than writing our own version constraint and parser library, we
can re-use composer's, which was recently split out into a separate
library named "composer/semver" for this patch.

Any syntax accepted by composer[1] is available for usage here. Test
cases have been provided to demonstrate how versions are parsed. For now
it is recommended that people stick to expressing compatability with
stable versions (e.g. ">= 1.26").

This patch does not support requiring specific MediaWiki core WMF
branches, since those do not follow the standard semver format that
composer parses. If we are unable to parse $wgVersion, all checking will
be skipped and reported as compatible.

[1] https://getcomposer.org/doc/01-basic-usage.md#package-versions

Bug: T99084
Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10
2015-09-21 09:56:53 -07:00
Ori Livneh
e176c76da2 resourceloader: Fully remove ResourceLoaderLESSFunctions
Deprecated in 1.24, for reasons explained in a0c41ae39d. I don't see any
usage in core or extensions.

Change-Id: I46f9e04ae633e7ff1ee112b652e1865731172f1f
2015-09-04 01:41:40 +00:00
Kunal Mehta
17a41f9277 registration: Allow custom prefixes for configuration settings
Allow extensions which are using "$eg" or any other prefix to migrate.

Extensions can override the default of "wg" by setting a magic "_prefix"
key in the "config" object.

Note that the migration helper script will not be able to automatically
migrate custom-prefixed configuration settings.

Bug: T97186
Change-Id: I79203cd5e3a2405b92ad01da869de3bd3d359d19
2015-09-03 12:44:46 +00:00
Kunal Mehta
cc88d02e8e registration: Document 'templates' property of ResourceModules objects
Bug: T107008
Change-Id: Iaac805969460ef114f9e87afe8f6e9f442728670
2015-08-03 18:37:41 +00:00
Kunal Mehta
c402600732 registration: Allow setting $wgCapitalLinkOverrides
Change-Id: Iaf8b44d02adf94ac7f7cb6a8a090b4069b98a88c
2015-08-02 20:29:54 +00:00
Kunal Mehta
f979d1bfce registration: Allow setting $wgNamespaceProtection
Change-Id: Id071eeeb3e734f7833d36610a6b4e786f2d26fa6
2015-08-02 20:29:44 +00:00
Kunal Mehta
1ebb0f5659 registration: Overhaul merging of globals
Instead of hardcoding specific global settings in ExtensionRegistry,
create specific "merge strategies" that are used to merge globals.

Merge strategies are set for core properties in the ExtensionProcessor,
and extensions can set them for their own configuration settings using
the magic "_merge_strategy" key.

The following merge strategies are included:
* array_merge_recursive - call `array_merge_recursive` on the two arrays
* array_plus - use the "+" operator to combine arrays, preserving
               integer keys
* array_plus_2d - A version of array_plus that works on 2d arrays, used
                  for merging arrays like $wgGroupPermissions
* array_merge - call `array_merge` (default)

This changes the merging of various namespaces related settings to use
array_plus so they actually work.

Bug: T107646
Change-Id: I64cb0553864e3b78b0f203333f58bb73b86a6434
2015-08-02 12:04:25 -07:00
Kunal Mehta
b1aa840761 registration: Fix "namespaces" schema to match code
The "namespaces" property is supposed to be an array of objects, not an
object. Document the properties of the individual objects, and mark the
actually required ones as required.

Change-Id: Ie3cee3e720b962073a1ff098659faa9f11d44fe3
2015-07-31 23:01:59 -07:00
Kunal Mehta
f48b504915 registration: 'FilterLogTypes' is a JSON object
Change-Id: I01eb28b9d01db8e500e376db9296b4eee85854c1
2015-06-25 17:29:33 -07:00
jenkins-bot
6ffdc1cdca Merge "OOUI theme support" 2015-06-02 17:28:09 +00:00
Kunal Mehta
75fc0f1661 registration: Remove "additionalitems" property from array (authors)
It doesn't make sense for arrays which can't have items to begin with.

Follows up bfe4ddd810

Change-Id: I851b70782fa8210802fe576fee771ddf1bdd7fec
2015-06-01 18:50:51 -07:00
Bartosz Dziewoński
1fc57830e2 OOUI theme support
* Split off OOjs UI's module definitions to a separate file from
  Resources.php.
* Extend ResourceLoaderImageModule to support per-skin images and
  variants.
* Allow skins to specify their preferred OOjs UI theme using new
  skin registry attribute 'SkinOOUIThemes'. The default remains the
  'mediawiki' theme, 'apex' can also be chosen now.
* Implement custom ResourceLoaderOOUIImageModule which implements some
  special sauce required to shoehorn OOjs UI image set definitions into
  ResourceLoaderImageModule with skin-specific styles support.

Bug: T100895
Change-Id: I3fbacbce95126a4cc29221352f3ef846f41e7b1b
2015-05-31 22:55:13 +00:00
Kunal Mehta
0c04667cac registration: Don't hardcode list of extension types in schema
Extension types can be added via a hook, so don't try and validate
against a hardcoded list.

Change-Id: I0bc6fbcedc0b582b81c7037724ad01441ae415f6
2015-05-30 00:34:57 +00:00
Kunal Mehta
066d1ef940 registration: Improve ResourceModules schema definition
* "-" is a valid character in module names
* debugScripts, loaderScripts, dependencies, and messages can all be
strings in addition to arrays.

Change-Id: I76570ebf1cb02ca51c5185d4b0c48a553a0e7d2f
2015-05-30 00:14:08 +00:00
Kunal Mehta
1998993685 registration: Fix types of ResourceModules properties
styles and scripts can both be strings, and that is treated as if that was
the first value in the array.

style can be used as an object, the filename is the key, and value can be an
object that states what media type the stylesheet is for. An example of this
can be seen in the MonoBook skin.

Change-Id: If7d3a220cdccbb1ce096d776592535fe5782a954
2015-05-28 17:54:33 -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
Kunal Mehta
34537805fc registration: Fix 'ResourceModules' in schema
Change-Id: I6fb833133a6d6bde42cb40eb8fd7e02f7ca9797a
2015-05-25 12:05:05 +02:00
jenkins-bot
aaef99cbb6 Merge "Do not allow setting deprecated $wgSpecialPageGroups over extension.json" 2015-05-20 04:48:59 +00:00
Kunal Mehta
aa2e12c172 registration: Remove duplicate "ParserTestFiles" key from schema
Bug: T99493
Change-Id: I43ea510162d01424171e738310b0519c85d28f68
2015-05-17 22:50:37 -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
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
2702c1f473 Make "name" a required value of extension.json in the schema
The code considers it to be required, so indicate that in the schema as well.

Change-Id: I9c1a279d5675eb10210a3dba5a15fe169619d719
2015-03-02 16:38:39 -08: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
a969555c2d registration: Sync extension.schema.json with reality
* info-files was never implemented
* path is no longer needed since we already know it

Change-Id: I0212620cb3a32e506717bd39a2fff4c9589f11cd
2015-01-13 11:37:17 -08:00
Kunal Mehta
e1425750fa registration: Add ConfigRegistry to the extension.json schema
Change-Id: I6918215e3b5b2dd4c993d8a8767dc3ce998bd5ed
2015-01-13 01:25:09 +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