Commit graph

77 commits

Author SHA1 Message Date
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Kunal Mehta
5490b1270a registration: Improve duplicate config setting exception
We don't keep track of what set a specific global, so at least mention
the name of the extension that is setting a duplicate for easier
debugging.

Also, fix the case where if the first extension to be loaded was setting
a core setting, it would not throw an exception since config was being
processed before the rest of extension.json. Now we process config after
all core settings, going only before attributes.

Bug: T194319
Change-Id: I4fd96e7d167cf0652ee3e8e66167c86f2b91b992
2018-05-15 10:32:22 -07:00
Kunal Mehta
d3b580977d registration: Simplify extracting path based globals
The code for ParserTestFiles and ServiceWiringFiles was identical, so
unify it into one function. For most extensions, this should save two
unnecessary function calls as a bonus.

Change-Id: If5ed189f97b7d3b9cd7b550f3ad2e90abe30005d
2018-02-09 22:33:10 -08:00
Yifei He
b3840b25b3 Avoid using array_map in ExtensionRegistry and ExtensionProcessor for simple operations
Bug: T182645
Change-Id: Ia98b1d798b1f93ca30686c009d479668616229ae
2017-12-14 15:51:33 +00:00
jenkins-bot
5fa4cdf860 Merge "registration: Only allow one extension to set a specific config setting" 2017-10-24 17:52:23 +00:00
Kunal Mehta
72d92f6fe3 registration: Fix caching of load_composer_autoloader
Move the file_exists() check out of the extension processor and into the
extension registry so that it is evaluated at run time instead of during
caching. The prior way is problematic since we don't invalidate the
cache if the existence of the file were to change.

Bug: T176534
Change-Id: I98e4ffdfac9f98397a103966824519afe1375356
2017-09-22 22:20:16 -07:00
Florianschmidtwelzow
29a5fc72e3 registration: Only allow one extension to set a specific config setting
ExtensionProcessor would previously just blindly overwrite duplicate
config settings, which ends up depending upon load order.

It's relatively hard to debug since it is silently overwritten. This now
throws exceptions in case of duplicate config settings.

This will also have some side-effects of catching people putting things
like "ResourceModules" in their "config" section when it should be a
top-level item.

Bug: T152929
Depends-On: I4c5eaf87657f5dc07787480a2f1a56a1db8c714f
Change-Id: Ieeb26011e42c741041d2c3252238ca0823b99eb4
2017-08-28 15:03:47 +00:00
Thcipriani
236456777b Revert "registration: Only allow one extension to set a specific config setting"
Breaks mergeMessageFileList which means scap can't run in beta.

This reverts commit 50d7546057.

Change-Id: Idb65f1098abce28d49ebbcc8254c0976b6861c59
2017-08-22 20:40:15 +00:00
Florian Schmidt
50d7546057 registration: Only allow one extension to set a specific config setting
ExtensionProcessor would previously just blindly overwrite duplicate
config settings, which ends up depending upon load order.

It's relatively hard to debug since it is silently overwritten. This now
throws exceptions in case of duplicate config settings.

This will also have some side-effects of catching people putting things
like "ResourceModules" in their "config" section when it should be a
top-level item.

Bug: T152929
Change-Id: Iaef32efab397e82ff70ddca8ac79c545c5b7d2bb
2017-08-22 02:45:24 -07:00
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