Commit graph

59 commits

Author SHA1 Message Date
jenkins-bot
f1fe87e2b0 Merge "Add extension.json merge strategy "provide_default"" 2021-05-13 23:20:47 +00:00
Tim Starling
076b93fba0 Add extension.json merge strategy "provide_default"
Add a merge strategy which sets the whole value only if the global
has not previously been set. This can be used to allow LocalSettings.php
to remove elements from an array created by extension.json.

Bug: T142663
Change-Id: Id250f9c349ee4eafbc759452ca6ea2a918baeb11
2021-05-04 16:02:55 +10:00
Timo Tijhof
39e2abd886 registration: Allow multi-line strings in "@" note keys
Change-Id: Ifb1a0f04cc22b122ed99308c096d0ce4296e9097
2021-04-29 02:47:47 +01:00
Ammarpad
ba17c42a79 registry: Allow specifying immovable namespaces in extension.json
In most cases this will alleviate the need to use the
ImmovableNamespaces hook.

Bug: T277520
Change-Id: If1e1063a597ebdb39343a356cc381a6ceafaebcc
2021-03-17 06:10:35 +00:00
Roan Kattouw
b267f7aa90 resourceloader: Allow modules to mark themselves as ES6-only
Modules that set "es6": true in their module definition will error when
a non-ES6 client tries to load them.

To detect ES6 support, this looks for native Promise support,
RegExp.prototype.flags, and non-BMP characters in variable names. All
browsers that lack full ES6 support fail at least one of those checks.

To flag modules as requiring ES6, this adds a ! to the end of their
version string. This takes up much less space than adding another
register() parameter (which would have to be at the end). It's hacky,
but we expect this feature to be relatively temporary, until we require
ES6 for running any JS at all (probably in about a year).

For distinguishing different types of errors thrown from
sortDependencies(), use e.name. We can't subclass Error properly because
that requires ES6.

Bug: T272104
Change-Id: I45670c910ff12eb422ae54c9fcf372e45c7b2bf1
2021-03-04 14:53:36 -05:00
DannyS712
6a03737104 Update for object-factory v.3
Bug: T267074
Change-Id: Iff9b46c9e78e87d32c8f75d26b284ce01bccb63d
2020-11-17 06:20:23 +00:00
Timo Tijhof
0c01d8cc52 resourceloader: Add skin-based 'mediawiki.skin.variables.less' import
Add the SkinLessImportPaths attribute for skin-specific LESS import
paths, which skins can use to override the mediawiki.skin.variables.less
file.

As a starting point, add the following 5 variables:

* device widths (3x)
  To help phase out 'mediawiki.ui/variables'. These are
  commonly used by MobileFrontend.

* @font-family-sans
  Recommended by Volker. Used by multiple skins.

* @border-radius-base
  Recommended by Volker as example of something that we currently
  hardcode in MediaWiki core for Vector and OOUI/WikimediaUI
  in 'mediawiki.widgets.datetime' but should instead be allowed
  to vary by skin and OOUI theme.

  Remove the hardcoded value for '@border-radius-base' in
  various places in favour of importing from mediawiki.skin.
  The default is a bare default of 0 (as border-radius is off
  by default in the browser).

  The value for Vector is restored there by I47da304667811.
  The value for MonoBook is improved by I000f319ab31b.

Bug: T112747
Change-Id: Icf86c930a3b5524254bb549624737d3b9dccb032
2020-09-15 10:05:53 +00:00
jenkins-bot
6c90c2758b Merge "registration: Restrict properties in "config" in manifest_version 2" 2020-07-14 09:40:15 +00:00
kalle
3177547540 registration: Fix string "true" in extension v2 schema
Extension tags required value was the string value "true",
but really should be the boolean value true.

Bug: T257898
Change-Id: I6372fc55b864e898268c6df3f7cdead03b37d53f
2020-07-14 08:50:03 +00:00
Tim Starling
d1363015b7 Introduce soft deprecation of hooks
Add a "silent" flag to DeprecatedHooks which causes relevant deprecation
warnings to be suppressed, but still allows call filtering to be used.

Add existing hooks that are documented as deprecated to the array.

Change-Id: Ieeb5e1840fd06d2b7979ef7827ba82bd2a35a2ba
2020-06-04 10:00:55 +10:00
jenkins-bot
ca6ec5a4ee Merge "Add 'ParsoidModules' as a top-level core attribute in extension.json" 2020-05-29 00:16:01 +00:00
C. Scott Ananian
e71e025aba Add 'ParsoidModules' as a top-level core attribute in extension.json
See also I20f641a1ff032a6da3549b01dfaf8f4cf1eb5071, which uses this
attribute, and the earlier discussion in the (abandoned)
Ia251d631febf5be7fcad21cd8b73a68ec2785137.

Bug: T133320
Change-Id: I6c74938883376ec17f3790678b435585083a440f
2020-05-22 18:19:00 +00:00
Tim Starling
7abd828ea3 Extension schema updates for HookContainer
* Updated the extension schema for the new hook system
* Fixed the lack of "services" from RestRoutes ObjectFactory specs,
  since RestRoutes and HookHandlers is supposed to be the same.

Bug: T240307
Change-Id: I1a8657ff9fd14618c6709dbab62c3b4ee9f659a5
2020-05-18 14:18:35 +10:00
Reedy
1b1a17bcef skins: Allow $wgValidSkinNames to take ObjectFactory spec
Bug: T252760
Change-Id: I189de448c3b2c56dfe6bf49170d7746943cf2417
2020-05-16 01:57:25 +00:00
Kunal Mehta
e3d8971bef registration: Restrict properties in "config" in manifest_version 2
This allows for the schema to spot typos because there's now a whitelist of
properties. The main thing that might get caught by this is documentation
using "@something" keys, but all of that should be under "description"
now.

I sent patches to all extensions/skins in Gerrit so they'll pass validation
with the new schema: <https://gerrit.wikimedia.org/r/q/topic:%22fix-config-validation%22>.

Bug: T252589
Change-Id: I94d96b8a66b9209fa32726c2a2166308536f6c8a
2020-05-12 13:02:06 -07:00
Reedy
eeb8cb1342 search: Add 'SearchMappings' attribute to map canonical name to PHP class
This allows indirection between the values in $wgSearchType and
$wgSearchTypeAlternatives where the underlying class name
doesn't match the actual class name that subclasses
SearchEngine.

Bug: T250977
Change-Id: Ib9634128f07d428276e80a6f2f492b850eef17e8
2020-04-30 04:29:17 +00:00
Reedy
b0ef0b3717 Clarifiy that (extension|skin).json requires properties can be for skins too
Change-Id: I61f92dee4092ea2644f1d93eeaf7b03a6ef2308d
2020-04-22 15:50:30 +01:00
Timo Tijhof
e456b68651 resourceloader: Allow 'localBasePath' for ImageModule to extension.json
This wasn't yet part of the schema, hereby added.
Being used for TemplateData in Ic8975d7ba349.

Change-Id: If661c68bea069e99cfff35711efdde7805a12851
2020-03-15 14:54:56 +00:00
Bartosz Dziewoński
ee1f4f8ea3 extension.schema.v2: Fix schemas for 'templates'
Synchronize the definitions for ResourceModules and QUnitTestModule.

I previously had to fix a similar problem with 'packageFiles':
I6c3d186de1877f73d4a4e3fec7d6d632a5d5fa83. And there are many other
differences. I don't have the time right now to compare them all
and decide which ones are right.

Change-Id: I9153851fe162c012967fda00d3e1f81964a8dce9
2020-02-25 01:18:26 +01:00
mainframe98
ac48c84224 Allow specifying autoloaded classes for tests
This introduces two new keys to the extension schema, analogous to
the existing autoloader keys: TestAutoloadNamespaces and
TestAutoloadClasses.

The classes and namespaces defined by these keys are only loaded by
the registry when ExtensionRegistry::setLoadTestClassesAndNamespaces
is called. The phpunit wrapper does this in PHPUnitMaintClass::setup.
The unit test bootstrap file calls
ExtensionRegistry::exportTestAutoloadClassesAndNamespaces instead,
similar to how it loads the regular classes and namespaces.

Bug: T196090
Change-Id: I88cf69663362fd599c20649b1df641907a02678d
2019-12-10 21:39:30 +00:00
Bartosz Dziewoński
d50c7f5b56 extension.schema.v2: Fix schemas for 'packageFiles'
The PHP code handling 'packageFiles' looks like it only expects
numeric arrays, and not associative arrays. Therefore in JSON the
value for the 'packageFiles' key should be arrays and not objects.
(And a special case of a string, handled the same as single-element
array, is also accepted.)

Individual items in the array can be not only strings, but also
objects, describing data which is pulled from other sources than a
file.

* ResourceLoaderFileModule: Remove unused variable and tweak docs.

Change-Id: I6c3d186de1877f73d4a4e3fec7d6d632a5d5fa83
2019-10-24 22:30:10 +02:00
Timo Tijhof
34bff221ba mediawiki.messagePoster: Introduce 'MessagePosterModule' extension attribute
This allows extensions to add additional files or dependencies to
the 'mediawiki.messagePoster' module bundle.

Bug: T235315
Change-Id: I17c34cbb26e786328d3d99beb0c0fa65e15ea084
2019-10-17 18:00:10 +00:00
jdlrobson
e97f2943f2 registration: QUnitTestModule should support packageFiles and templates
Change-Id: I1a66939d2b596094b419de40b370e79f09c85581
2019-10-04 17:09:39 +00:00
mainframe98
b7b490e46d Support the creation of special pages with services injected
Now that the ObjectFactory library supports object creation with
services (T222409), the special page factory can use the object
factory to create special pages based off a spec, allowing the
creation of special pages that need services injected.

The object factory now also handles constructing from class name
and from callable.

This also deprecates providing the special page list with an
instance of SpecialPage, which hasn't been necessary since
r15031.

Bug: T222388
Change-Id: Iabb78ce5c98cfb3b586644be35d984871cb750cb
2019-09-08 12:57:54 +02:00
Bartosz Dziewoński
77f4bab8b7 Allow skins/extensions to define custom OOUI themes
This change follows I39cc2a735d9625c87bf4ede6f5fb0ec441d47dcc.

docs/extension.schema.v1.json
docs/extension.schema.v2.json
includes/registration/ExtensionProcessor.php
* The new extension attribute 'OOUIThemePaths' can be used to define
  custom OOUI themes. See I9187a63e509b601b8558ea82850fa828e5c8cc0a
  for an example usage.

includes/resourceloader/ResourceLoaderOOUIModule.php
* Add support for 'OOUIThemePaths'.
* Defining 'images' is now optional. I figure custom themes are
  unlikely to have or need them.
* Use ResourceLoaderFilePath objects to allow skin-/extension-defined
  OOUI module files to use skin/extension's base paths.
  This was previously used to support $wgResourceModuleSkinStyles,
  but only for 'skinStyles' - now ResourceLoaderFileModule needs
  to also handle it for 'skinScripts', and ResourceLoaderImageModule
  for 'images').

includes/resourceloader/ResourceLoaderFilePath.php
* Add getters for local/remote base paths, for when we need to
  construct a new ResourceLoaderFilePath based on existing one.

includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderImageModule.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
* Add or improve handling of ResourceLoaderFilePaths:
  * Replace `(array)` casts with explicit array wrapping, to avoid
    casting objects into associative arrays.
  * Use getLocalPath() instead of string concatenation.

tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php
* Some basic checks for the above.

Bug: T100896
Change-Id: I74362f0fc215b26f1f104ce7bdbbac1e106736ad
2019-07-10 22:08:14 +02:00
jenkins-bot
7c966af21a Merge "REST API initial commit" 2019-06-13 22:18:21 +00:00
Tim Starling
3f0056a252 REST API initial commit
Add some of the basic REST API class hierarchies:

* EntryPoint
* Router
* Request
* Response
* Handler

The actual entry point file rest.php has been moved to a separate
commit, so this is just an unused library and service.

Bug: T221177
Change-Id: Ifca6bcb8a304e8e8b7f52b79c607bdcebf805cd1
2019-06-12 10:22:28 +10:00
Kunal Mehta
286a2a1852 registration: Deprecate ParserTestFiles in extension.json
Warnings will be emitted whenever validation is checked or unit tests are
run.

Bug: T192154
Change-Id: Ib968f696890667841d850ef5562e05989cb4f431
2019-06-02 21:53:31 -04:00
Kunal Mehta
1aa819513b registration: Add development requirements to extension.json
Extensions can specify development dependencies in extension.json under
the "dev-requires" key. It's identical to the "requires" field.

Any requirement that is needed to pass tests, including but not limited
to, PHPUnit, QUnit, structure, phan, should be documented in this new
field. The main intention is that CI will ensure that all of these
dependencies are satisfied before running tests.

At standard runtime, the development requirements will be ignored by
MediaWiki, since it only checks for real requirements. Scripts can
manually check development requirements by calling
ExtensionRegistry::setCheckDevRequires( true ) before trying to load
things.

If both "requires" and "dev-requires" are present, MediaWiki will merge
the two together, so the environment will need to satisfy both before
proceeding.

Bug: T193824
Change-Id: I9b2936666ee3c96f5c976c7a17f11c437c2c7f48
2019-05-22 01:59:33 -07:00
Kunal Mehta
cfd5d33da2 registration: Fix validation of ext-foo values
Our json-schema library doesn't yet support "const" (at least not in a
released version), so use "enum" with one element, since it's functionally
equivalent per <https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values>.

Change-Id: Ib9ebb5c6b9d07903fa47603fbe54a148e9c00352
2019-05-22 01:57:32 -07:00
MGChecker
5e2c7466ad registration: Allow to require environment abilities
This patch adds the possibility for extensions and skins to require
certain environment abiltites that are not necessarily PHP extensions.

For now, the only ability introduced is the ability to shell out, but
the processing and testing is written in a more general way to allow
users to add more abilties later on by just changing getAbilities().

In theory, this allows using VersionChecker to check for random
abilities if they are specified in the constructor, as it is comletely
environment agnostic and not really bound to just be used for checking
extension compatibility.

Furthermore, it is possible to specify custom error messages for each of
these abilities in the constructor. Other parts of MediaWiki may use
these features to check for requirements while working with totally
different abilities.

Bug: T212472
Change-Id: Iff8512530b08ef509e7ac0b6ed8fe9578ef3e2a1
2019-04-13 08:14:44 -07:00
Kunal Mehta
0a8a4fe75e registration: Fix 'ResourceLoaderWikiModule' schema validation
There is a full schema for ResourceModules when the
class: ResourceLoaderWikiModule is used. Except it doesn't actually work,
since it it fails validating against that schema, it will continue to check
the other anyOf schemas, find the arbitrary class one, and pass that one.

Blacklisting ResourceLoaderWikiModule from the arbitrary class schema means
that it has to pass the specified schema for it, or fail validation.

I verified that all extensions and skins in Gerrit pass validation with this
patch.

Change-Id: Icb862088c0ca1f89ed5a57a4286dd9049d213021
2019-02-22 17:17:05 -08:00
Kunal Mehta
291fcff08e registration: Fix 'arbitrary ResourceLoaderModule definition' schema regex
We want this regex to match on everything that is not the literal string
'ResourceFileModule' or 'ResourceImageModule' (actually
'ResourceLoaderWikiModule' should be in this too, but I'll fix that in a
follow-up). But the current regex would not match if one of those was in a
substring.

The new regex should match everything that is *not* those two strings.

Bug: T216861
Change-Id: I7d888adfdc67b2075028e49432710308aa0125af
2019-02-22 17:03:01 -08:00
jenkins-bot
37ef56fadd Merge "registration: Allow @-prefixed keys in manifest_version 2" 2019-02-14 06:38:04 +00:00
Stanislav Malyshev
341bd5d6e9 registration: Allow @-prefixed keys in manifest_version 2
As specified in
<https://www.mediawiki.org/wiki/Manual:Extension_registration#Retaining_documentation>.

Bug: T215650
Change-Id: I2ff523828389fbec39cdf7c55046e7da901a2ecb
2019-02-12 18:50:14 -08:00
Gilles Dubuc
2996a9a0e4 Add ability to define packageFiles in extension.json
Bug: T215756
Change-Id: I97c3ccc13c54b424952ce15509b98a217b2670b1
2019-02-11 10:53:09 +01:00
Timo Tijhof
d1666a89ff resourceloader: Support TestModules registration via extension.json
Bug: T126091
Change-Id: I27ecebe27d7aaebe6d1317bc5eaea9cca368b45d
2019-02-05 15:27:37 -08:00
Bartosz Dziewoński
e3a736b42d registration: Fix typo in schemas
Change-Id: I8d39290904593c1ef962be2995a536028d0635bc
2019-01-22 02:30:48 +00:00
Gergő Tisza
265cb893cb Add $wgReauthenticateTime to extension.json
Change-Id: I9722c065d522e18b6bf488c721f48ee7b7b9e494
2018-11-15 15:41:50 -08:00
MGChecker
c7e45b6211 registration: Let extensions add PHP extension requirements
This change adds the possibility to specify ext-* keys under the 'platform'
key introduced in I6744cc0be2 to require given PHP extensions. Note that
it's impossible to add constraints different from '*', as there is no universal
way to retrieve PHP extension versions.

Bug: T197535
Change-Id: I510de1e6d80f5c1d92dc1d1665aaa6c25bf28bf7
2018-09-30 19:55:57 +02:00
MGChecker
8af76decf8 registration: Let extensions add PHP version requirements
While MediaWiki Core already sets requirements for PHP versions, it should be
possible for extensions to tighten these requirements. This mirrors the PHP
parameter of extension infoboxes as well.

This change introduces a new 'platform' key (in addition to 'MediaWiki', 'skins'
and 'extensions', where non-MediaWiki software requirements will be listed
in the future, starting with a PHP version constraint. Further keys are
supposed to be added to allow setting constraints against php extensions
and other abilities of the platform.

Bug: T197535
Change-Id: I6744cc0be2363b603331af9dc860eb8603a1a89a
2018-09-22 03:43:28 +02:00
Gergő Tisza
2ed7bdc46d
Require editsitecss/editsitejs for editing raw messages
Bug: T45646
Change-Id: Ib16db04e499ad28216ee08b8cccccf3f141e2bad
2018-08-26 23:56:06 +02:00
Timo Tijhof
ca510f742f resourceloader: Remove $wgResourceLoaderLESSVars support
The use of global variables was deprecated in favour of
ResourceLoaderModule::getLessVars() on a per-module basis.

Also moved testLessFileCompilation case to the appropiate file as it
covers ResourceLoaderFileModule.php, not ResourceLoader.php.

Bug: T140804
Depends-On: Ib1b2808df2384473bfac47f53a5d25d7c9bbca2b
Depends-On: I96047f69d01c4736306df2719267e6347daf556f
Change-Id: If708087c85c80355c7e78f1768529b5f2e16ed07
2018-08-14 18:57:45 +00:00
jdlrobson
89b2e1eb2c registration: Document ResourceLoaderImageModule's useDataURI option
Without these rules, validation will fail in any skin or
extension that tries to use it.

Follows-up 36252b7.

Bug: T198930
Change-Id: Iee77655d4868a7d921be8cc23776a7859d9acf0c
2018-07-10 00:23:33 +00:00
jdlrobson
8faba225fe ResourceLoaderImage module definitions can define a defaultColor
Bug: T197909
Change-Id: I0745e112d11026ed59d8daca990b313305cd094a
2018-06-27 20:36:47 +00:00
Kunal Mehta
bf9bc2ae49 registration: Validate AutoloadNamespaces keys have trailing \
The PSR-4 autoloader requires "AutoloadNamespaces" keys to have a
trailing \ (\\ in JSON), so add a validation check for that.

Unfortunately the validation error isn't great, since it checks to see
if the property matches patternProperties, and when it doesn't, it
claims the property isn't defined since additionalProperties is false.
But it's still better than not failing when they are missing.

Bug: T189136
Change-Id: If01bd06cdd767fb704a8ff85cdf1c143e53fa4ca
2018-05-20 12:13:05 -07:00
Volker E
21a36e8046 Hygiene: Use “OOUI” as unified name in build and code documentation
Bug: T182360
Change-Id: I981c574003fa505fe133be6da405e73330c4e9a1
2018-01-31 22:10:46 -08:00
James D. Forrester
2cbd34dc55 Follow-up 8a7fb8577: For deprecated RL modules, allow strings
So that more than just PHP code and MediaWiki core can use it, but
also JSON-based static extension registrations. :-)

Change-Id: If22fccbb43c5b05db2a666d61ae8864ee9815e7d
2018-01-08 16:05:05 -08:00
Kunal Mehta
036f5b47ef Enable using PSR-4 autoloader for MediaWiki core and extensions
This adds support for a PSR-4 (<http://www.php-fig.org/psr/psr-4/>)
autoloader, so instead of needing to manually list each class, just the
namespace prefix is needed.

Extensions can set a "AutoloadNamespaces" property in extension.json to
register PSR-4 compatible namespaces to be autoloaded.

The implementation is based off of the example implementation
(<http://www.php-fig.org/psr/psr-4/examples/>) with some modifications
for performance, notably cutting down on function calls, and only trying
to look up classes that are namespaced.

The generateLocalAutoload.php script will ignore any directory that is
registered as a PSR-4 namespace.

Bug: T99865
Bug: T173799
Change-Id: Id095dde37cbb40aa424fb628bd3c94e684ca2f65
2017-12-12 00:20:11 +00:00
Kunal Mehta
679589828c registration: Allow protocol-relative links in "url" field
Bug: T93010
Change-Id: I626fb5528b41910d859d8596a8ad350f94c1082e
2017-07-17 10:13:49 -07:00