Commit graph

68 commits

Author SHA1 Message Date
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
jenkins-bot
9e8355c87d Merge "Allow namespaces defined in extension.json to be overwritten locally." 2017-05-21 08:02:22 +00:00
Kunal Mehta
fdb7e94104 registration: Move attributes out of the top level
This moves attributes out of the top level, and namespaces them under
each extension. If the extension that it belongs to is not installed,
the attribute is not exported and dropped.

The full name of the attribute is the name of the extension plus the
name of the attribute key. This enforces the recommendation that the
attribute name start with the extension's name.

Add test coverage for attributes under manifest_version 1 and 2.

Bug: T133627
Depends-On: I5a148763f68989c8da313a4fb1d0213658ee4495
Depends-On: I5a148763f68989c8da313a4fb1d0213658ee4459
Change-Id: I8613a027c56e2c9d2c6a83ca14749eb1c8fc23be
2017-05-15 20:09:50 -07:00
daniel
e4fc1ffec3 Allow namespaces defined in extension.json to be overwritten locally.
This allows extension namespaces to be assigned a custom ID, e.g. in case
the namespace pre-defined by the extension is already taken on the local
wiki.

This is done by defining the respective namespace constant in
LocalSettings.php.

Bug: T160462
Change-Id: If648d6e218847e6632d643ea724cd3da3945db70
2017-05-11 12:16:24 +02:00
Florian Schmidt
5f11f7818c registration: Generalize CoreVersionChecker to VersionChecker
This allows us to put other requirements more easily into extension
registration, such as skins and/or extensions.

Bug: T117277
Change-Id: I3ec1b28b6af380621585cd61b38e5ebb8be9f9c7
2016-12-14 19:18:09 +01:00
Kunal Mehta
b54acaf847 registration: Provide credits information to callbacks
Registration callbacks now provide basic credits information (name,
path, type, authors, license-name, version, etc.) as the first argument.
The main use case right now for this is to support extension VERSION
constants for backwards-compatibility.

In addition, callbacks now run *after* attributes are exposed, so
callbacks could use data from them if they wanted to.

Bug: T151136
Change-Id: Ic5965dd4e259e1f46222ac92b8e78750e67b51d6
2016-12-04 02:15:01 +00:00
Reedy
ad86dda42f registration: Set "FileExtensions" to $GLOBALS
Change-Id: Ie52004d25ebc06c81cd7d8d7de60479ff365ccea
2016-11-17 23:24:42 +00:00
Reedy
34e549ff61 registration: Support setting $wgPasswordPolicy in extension.json
Bug: T149597
Change-Id: I56c0b8932fcd42ec9b748529daa32a998fb19bf8
2016-11-17 22:46:32 +00:00
Reedy
154b4383fe Alphasort lists
Change-Id: Ibcc3541d5bd97eeda3b43a3f9acc2e90644b36b9
2016-11-09 21:29:18 +00:00
Yuri Astrakhan
25fd321ac2 registration: Fix ignoring 'merge_strategy' key in manifest_version 2
Bug: T148493
Change-Id: Ibd88c4dc98f36d7d8336691884bbaa9a4864da83
2016-10-18 06:47:50 +00:00
Kunal Mehta
64692bfd36 registration: Support 'ServiceWiringFiles' in extension.json
Change-Id: Ib413a14cb8e21207264fa1c45d84550b3eab7a4e
2016-08-25 23:08:28 -07:00
Kunal Mehta
93aed1e7eb registration: Support conditionally registered namespaces
Some extensions (e.g. EventLogging) conditionally register a namespace
depending upon the wiki's configuration using the CanonicalNamespaces
hook. Since the "namespaces" key automatically registers the namespace,
we need an option to not register it and let the extension take care of
that manually using the hook.

All of the other namespace related settings are safe to unconditionally
set since they won't do anything if the namespace doesn't actually
exist.

Bug: T141604
Change-Id: Ie8c217fdc8bd783b30f98210309ea56fef39c0da
2016-07-29 01:09:24 -07:00
Kunal Mehta
9ffc40235b registration: Support config setings that are relative paths
Add support for configuration settings that are relative paths to the
extension directory. The most common use-case for this is where the
extension ships a generic default file, but sysadmins or packagers may
want to override it. Setting `"path": true` on the config definition
will make the value be interpreted as a relative path.

And add tests!

Bug: T100956
Change-Id: Ia87ced25b35be7a314ee2937e0ccc63f9acc5bb5
2016-07-24 14:49:57 +00:00
Kunal Mehta
d68ea7ce6d registration: Fix merge_strategy in manifest_version 2
merge_strategy is set in $data, which is the definition of the config
setting, not the default value of it ($value).

Change-Id: I12ee95892b2c157bb0beb97cf2cd5ef920b7d52e
2016-07-24 11:47:40 +00:00
jenkins-bot
41269d28db Merge "registration: Convert "config" into an object with metadata" 2016-07-14 13:12:27 +00:00
Kunal Mehta
83ec5909d4 registration: Convert "config" into an object with metadata
To add extra metadata for "config" options without constantly adding
hacky underscore prefixed keys, convert "config" items into an object,
where the value is under a "value" key.

"_merge_strategy" is now just "merge_strategy", but still has the
underscore prefix for the cache structure, to avoid changing it.

Since this is a fully breaking change, it only applies to files with
manifest_version: 2 set. A conversion script has been added to assist
with automated conversion.

Bug: T133626
Change-Id: Id1071fc0647892438e5cd0e3ee621fbdaaa64014
2016-07-13 14:58:00 -07:00
jenkins-bot
fe922d470f Merge "registration: Remove broken ResourceLoaderLESSImportPaths support" 2016-07-06 02:23:46 +00:00
Kunal Mehta
0625f4e161 registration: Remove broken ResourceLoaderLESSImportPaths support
It never worked to begin with since it did not prefix paths, and the
documentation for it says it should not be used by extensions, so
let's stop pretending it works.

Bug: T108271
Change-Id: I665d4439d14406038f2ac767ee5ec6eb5b67fca6
2016-07-02 14:38:05 -07:00
jenkins-bot
771d4b49bc Merge "registration: Support Change/RemoveCredentialsBlacklist in extension.json" 2016-06-24 14:34:06 +00:00
Gergő Tisza
b86dd2dafe registration: Support Change/RemoveCredentialsBlacklist in extension.json
Change-Id: I4d796a46d99daa8841fcdcbe76dddf9db46af9ed
2016-06-24 13:25:19 +00:00
Kunal Mehta
78a7c5745a registration: Add support for $wgGrantPermissions & $wgGrantPermissionGroups
Change-Id: If336aa351ee5dc4dc07f63cfac2a5d236e501718
2016-06-20 20:45:51 +00:00
Brad Jorsch
d245bd25ae Add AuthManager
This implements the AuthManager class and its needed interfaces and
subclasses, and integrates them into the backend portion of MediaWiki.
Integration with frontend portions of MediaWiki (e.g. ApiLogin,
Special:Login) is left for a followup.

Bug: T91699
Bug: T71589
Bug: T111299
Co-Authored-By: Gergő Tisza <gtisza@wikimedia.org>
Change-Id: If89d24838e326fe25fe867d02181eebcfbb0e196
2016-05-16 15:11:02 +00:00
Gergő Tisza
055ec8817e registration: Handle $wgSessionProviders in ExtensionProcessor
See https://www.mediawiki.org/wiki/Manual:$wgSessionProviders

Change-Id: Ic9daf9898a0c044d1e2611ca0276d7904a3372ce
2016-05-12 19:09:34 +00:00
Florian
5d2df74a46 registration: Fix mode of files (755 -> 644)
Follows up 7c4d73183c.

Change-Id: I779534561ccb38b4c0f2ca5771dcb0aa810f930a
2016-05-06 18:26:07 +00:00
Florian
7c4d73183c registration: Allow string value for Hooks
Instead of forcing an object even for single-hook-listeners, allow
string values, too (one hook listener for one hook, only). Also:
use it as default for the conversion script, if only one listener
is added to a hook (which is usually the case). This leads into a
much cleaner output of the Hooks section of extension.json.

Bug: T133628
Change-Id: Ie9e54f0931c41706eb8d82d00256698992ec41cc
2016-05-03 13:23:07 -07:00
Glaisher
2093748e07 registration: Allow ActionFilteredLogs to be modified by extensions
Needed by Ibe628d9d08352

Change-Id: I7788fedc934b7c93facead796af30c89c335a513
2016-04-24 23:10:44 -07:00
Kunal Mehta
79a86afccf registration: Improve error message for non-array attributes
Change-Id: I7cbf7353ebbbbbbf36500f86164e3b32d7723cca
2016-03-12 19:03:29 +00:00
Timo Tijhof
04362aa613 registration: Avoid double slashes in localBasePath
Noticed it in APC usage for ResourceLoader that various keys from
FileContentsHasher contain double slashes. All from extensions that
use the `"localBasePath": ""` trick in extension.json (e.g. Citoid).

Change-Id: I5bac1e2e05e063aa7ff251ce7ffaa965a3451db9
2016-02-18 10:25:02 -08:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Kunal Mehta
f27f087fa7 registration: $wgRateLimits should be merged using array_plus_2d
Change-Id: I0d1abbb251f4a6d126d58668d1281a6f1550b459
2016-01-07 18:56:21 +00:00
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
Kunal Mehta
9db32681e4 registration: Handle $wgExtensionCredits inside the ExtensionProcessor
Bug: T108269
Change-Id: I92675dac5cca52448e24902d0a5c865fd6df46d9
2016-01-02 15:43:52 +00:00
Kunal Mehta
8e61ed3507 registration: Prevent loading the same thing twice
Normally the registry load queue should filter out duplicates, but if
people do weird things with symlinks, throw a useful error message if
the double-loading makes it all the way to the processor.

Bug: T121493
Change-Id: I47f5cd754e5f3c91e6b83a6d0ab542404347a421
2015-12-29 17:52:11 -08: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
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +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
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
c0b7236caa registration: Remove unused 'wgExtraNamespaces' merge strategy
As of 9df0672255, this is no longer used.

Change-Id: I7e40096cb5173626ba7f2cd3d2be121c8a04768a
2015-08-27 16:13:42 -07:00
Kunal Mehta
9df0672255 registration: Fix namespaces added through the ExtensionProcessor
Using $wgExtraNamespaces overrides any localized namespaces with the
canonical form, which is not ideal.

Namespaces added through extension.json will now store the canonical
form and numerical id in a 'ExtensionNamespaces' attribute that is read
by MWNamespace::getCanonicalNamespaces().

Also fix the documentation on $wgExtraNamespaces, as using
$wgCanonicalNamespaceNames has not been possible since r85327.

Bug: T110389
Change-Id: I5bd9a7258f59d8c4a7ad0543d2115960fbea9b3a
2015-08-27 03:03:43 +00:00
Kunal Mehta
8cc0de98dd registration: Actually set the merge strategy for $wgExtensionCredits
$wgExtensionCredits is special and needs to be set in the
ExtensionRegistry. Also change the cache key so any bad cache entries
will be ignored.

Follows up 1ebb0f5659.

Change-Id: Iec08ab8d9ef7fe7cccde979530839ef553779658
2015-08-02 14:56:44 -07: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
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