So far, extensions can only define REST entry points by listing them
directly in extension.json. This is inconvenient and makes it impossible
to define proper modules.
Bug: T365754
Change-Id: Id35bdd55e00457ddbeaee72d0e9399bd43a0d07a
Refactoring:
* Break out the database access part of UserOptionsManager to a separate
class hierarchy implementing interface UserOptionsStore. It's
basically a key/key/string-value store, very simple. The complex
parts of user options storage remain in UserOptionsManager.
* Bundle the UserOptionsManager caches into a per-user cache object. I
was adding a couple more and it was getting tedious.
Start integrating GlobalPreferences with UserOptionsManager:
* Have an array of stores. There's always a local store, and extensions
can add stores via an attribute.
* Add $global parameter to UserOptionsManager::setOption(), allowing
this method to update or override global options.
* Rename loadOptionsFromDb to loadOptionsFromStore.
* Move the local override feature from GlobalPreferences to core.
Bug: T323076
Change-Id: Ib3623b723557c819bc0ffdf21a4ffcb070eb298b
Allow extensions with very special modules that can't be called in a
testing environment to skip ResourcesTest::testRespond().
Needed by If1186797fd047d4f for ext.wikisource.OCR.
Change-Id: Id02915d9633c2d8209d2ff2e60f6748095ec10fe
The TranslationAliasesDirs configuration allows defining translatable
aliases in JSON files. The value should be a name or names of folders
that contains files that have localized aliases. Each language should
have a separate file.
Currently, it supports defining special page aliases but in the
future can be extended to support magic words and namespace aliases.
The patch adds a script: ConvertExtensionsMessagesToTranslationAlias
that can be used to convert existing ExtensionMessagesFiles to the new
format.
Bug: T89947
Change-Id: Ief16a48a8dc8742854f67301791aa2a0b0531116
The array_merge_recursive merge strategy is not intuitive and not
recommended. It does not appear to be used in any of the extensions
or skins that codesearch is aware of. To prevent confusion and
accidental use of array_merge_recursive when the behavior of
array_replace_recursive is likely desired, the array_merge_recursive
merge strategy is deprecated by this patch.
Bug: T292602
Change-Id: Ia0b861c308e6c7b4d40994af4c535ffdfa2b9ff5
Why:
Sometimes, it is necessary to have different behavior
for newly registered and existing users. For example,
this happens in the Echo or GrowthExperiments extensions.
As of now, this behavior is implemented by inserting
user_properties rows in onLocalUserCreated.
Over time, this results in a singificant amount of rows
inserted, which contributes to the user_properties table bloat,
which is already overly large (cf. T54777). This patch makes it
possible to remove such rows by supporting conditional defaults
for user properties.
What:
Add support for conditional defaults of user properties. This can be
configured via `ConditionalUserOptions` config option.
Bug: T321527
Change-Id: I1549c3137e66801c85e03e46427e27da333d68e2
Follows-Up: I3d01ab5467d1cf496d144781ef57a221b1476347
doc: Make extension.schema.v2.json a valid JSON schema.
The following validation errors have been fixed:
* The required validation keyword must be an array.
* Remove trailing commas
* Remove improper use of "".
Change-Id: I5f0dc8b2ab51c999f7ad3a827c66dbdc08113313
Why:
Temporary accounts introduced as part of IP Masking are supposed
to expire 1 year after their registration. Accounts can have
multiple registration timestamps when in a wiki-farm setup,
depending on which wiki we consult.
To implement the account expiration logic, we need to know the global
(first) registration timestamp.
Similar to CentralIdLookup, a concept of a registration date
provider is introduced. Unlike IDs, users can have multiple
kinds of registration dates (Wikimedia recognizes local and global,
but third parties can have different needs). For that reason,
any number of registration providers can be registered at any
given time; caller determines which one is requested. The default
is `local`, which is the only provider that is guaranteed to exist.
What:
* Add UserRegistrationLookup
* Add UserRegistrationProviders config variable
Bug: T344694
Change-Id: If9fa12a392064dd504590a861a175e3604a34fab
To implement source maps, we want FileModule::getScript() to return
an array with path information, but that would break subclasses of
FileModule which concatenate to the return value of parent::getScript().
So allow scripts to be generated by a callback, eliminating the need for
concatenation in subclasses.
* Factor out most of the loop body of expandPackageFiles() into
expandFileInfo(). Add 'name' to the return value. Ensure 'filePath'
is always a FilePath object since we need that to safely return it
to ResourceLoader later. Document the return value.
* Make sure the base path is always set in FilePath objects returned by
expandFileInfo().
* Factor out the loop body of the final stage of file info expansion
into readFileInfo(). Retain filePath, do not unset it.
* Assert that $fileInfo['content'] is definitely set.
* Convert array_map() in getDefinitionSummary() to a loop.
* Migrate LanguageDataModule.
Bug: T47514
Change-Id: I97d61b5793159cea365740e0563f7b733e0f16de
Add an extension/skin attribute and a command line option for
manageForeignResources.php, for management of an extension's or
skin's foreign resources. This is less clumsy and more
introspectable than each extension/skin creating its own copy
of manageForeignResources.php.
Bug: T330508
Change-Id: I5df95ea4799d0efce60b58a35cb916c8e0f555b0
The UA sniffs that overrode the feature tests are no longer needed.
* MSIE 10: Fine, rejected by feature checks.
* UC Mini "Speed Mode": Redundant, the version that this sniff
matched is pre-ES6. Current versions of UC Mini don't appear to
support enabling "Speed Mode" on random websites nor does it offer
it for Wikipedia specifically.
Details at https://phabricator.wikimedia.org/T178356#8740573.
* Google Web Light: Redundant, shutdown as of 2022.
Any references or extensions that still reach the proxy, get
redirected to our online URLs
https://googleweblight.com/?lite_url=https://en.m.wikipedia.org/wiki/Bananahttps://phabricator.wikimedia.org/T152602https://en.wikipedia.org/wiki/Google_Web_Light
* MeeGo: Redundant, discontinued and presumed rejected.
Either way, unsupported.
* Opera Mini: Fine, rejected by checks.
Details at https://phabricator.wikimedia.org/T178356#8740573.
* Ovi Browser: Redundant, discontinued and presumed rejected.
Either way, unsupported.
* Google Glass: Improve UX (since 2013, T58008).
* NetFront: Redundant. Old versions are presumed rejected.
Current versions are Chromium-based and presumed fine.
The exclusion was not UX based, but due to jQuery explicitly not
supporting it in 2013. This is no longer the case, so we can let
the feature test lead the way here.
* PlayStation: Redundant, same story as NetFront.
The version that matched the sniff is presumed rejected.
Current versions probably fine, but even not, don't match
our sniff so are already enabled today.
Bug: T178356
Change-Id: Ib6263ce3ffd11af5e501de8857f3e48a248c6210
Add a "SkinCodexThemes" key to skin.json, that works just like
"SkinOOUIThemes". Based on the value the skin sets,
ResourceLoader\CodexModule loads the correct Codex theme for the skin.
The default theme is wikimedia-ui, meant for skins with a 16px base font
size. Skins with a 14px base font size (like Vector) should override
this to use wikimedia-ui-legacy.
Bug: T324367
Change-Id: I7435413928f2b8c5d43c34d9e2e7df470d710c93
Despite being documented, this seems to have never worked correctly,
causing confusing exceptions.
Rather than try to fix it in this scary legacy code, just document the
alternative that actually is supported: specifying a file that doesn't
exist.
Change-Id: I00b5e144350add475a8379ead62868ed21fefb81
JS config vars listed in the 'LateJSConfigVarNames' extension attribute
or in the OutputPage::CORE_LATE_JS_CONFIG_VAR_NAMES constant will now
be added to the end of the HTML response, instead of early in the HTML
head where it blocks rendering/painting.
Bug: T41813
Change-Id: I86d461756398780dc24949013f35b7730a481052
This global variable was replaced by auto-discovery of parser test
files in extensions and is no longer needed (or used).
Change-Id: Ib616e60f36db32ffd8bc69c71a096f23c0a27910
The doc folder contains (committed) json files with schema definition
for json files
That should be linted as well to spot syntax errors easier
Change-Id: I20ff7abf6b98d2247ee52e2d2b43af88c062f779
For now, this is not used by MediaWiki core itself, but in the future
we may add prompts in the installer and notes in update.php, amongst
other places.
The naming is taken from the `suggests` field as used by Composer.
Bug: T182472
Change-Id: Icc8c189812b231313e6d8b3e907a866c710bae24
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
This reverts commit e08ea8ccb9.
Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).
Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
Add services and utilities for automatic creation of temporary user
accounts on page save, in order to avoid exposing the user's IP
address.
* Add $wgAutoCreateTempUser, for configuring the system
* Add TempUserConfig service, which interprets the config.
* Add TempUserCreator service, which creates users during page save as
requested by EditPage. With proxy methods to TempUserConfig for
convenience.
* Add table user_autocreate_serial. Table creation is necessary before
the feature is enabled but is not necessary before deployment of this
commit.
Bug: T300263
Change-Id: Ib14a352490fc42039106523118e8d021844e3dfb
In order to allow extensions to wire services in Parsoid's ExtensionModule
implementation, the ParsoidModules schema should have the needed properties.
But rather than try to exhaustively list the properties allowed in an
object factory specification, rewrite the schema to be more permissive
about allowing unknown properties while still disambiguating the object
factory case from the "Parsoid extension configuration array" case.
In particular, the latter will never have a `class` or `factory`
property.
Change-Id: Id630912fde0d35628188988860832821142ca6ca
Trying to declare a Parsoid extension showed a couple of issues related
to the JSON specification (there was a possible confusion between both
object declarations) and in trying to declare an extension as a single
string. This patch fixes both these issues.
Change-Id: I8c2f901e9a7e51704f10c8d8754cc8738079fde6
Since 272e941b7f it has been possible for a while now to construct
ContentHandlers using ObjectFactory specifications. However, this
was neither reflected in the JSON Schema of extension.json, nor in
the documentation on mediawiki.org.
See example of this being used in the wild: Ieca72e60d39376.
That patch is currently stuck on extension.json schema validation
test. The ObjectFactory spec itself is fine and works as intended.
Bug: T243560
Change-Id: I5986e19f1780709cf7b3ed2f55d5f46a0a1deeb7
Extensions can now define namespaces as non-includable, corresponding to
$wgNonincludableNamespaces.
By default, namespaces are includable and need to explicitly be
specified as `"includable": false` to be added to
$wgNonincludableNamespaces.
Bug: T277210
Change-Id: I85dc7bf01e5af81673c745a21ac83168321d0fef
The `loaderScripts` feature of ResourceLoaderFileModule was removed
without replacement a while ago. Use of it would no longer work
correctly and should result in a test failure.
The `position` property was also removed, but made no functional change
to behaviour. Update its documentation to clarify that it is no longer
used (it is simply no longer needed).
Bug: T289108
Change-Id: If3dbbbe95d60803be8df3c9a4d5ee9e01c825ebb
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
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
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
Unless it's an intentional deviation, everything in v2 should also be in v1.
This copies over:
* e71e025aba: Add 'ParsoidModules' ...
* 7abd828ea3: Extension schema updates for HookContainer
* 34bff221ba: Introduce 'MessagePosterModule' extension attribute
* e97f2943f2: QUnitTestModule should support packageFiles and templates
** d50c7f5b56: Fix schemas for 'packageFiles'
** ee1f4f8ea3: Fix schemas for 'templates'
* 3f0056a252: REST API initial commit
Change-Id: I1ae6fed0261ad29ea5cb39b3511b8cde392ab612
Same as it will be or v2 when that patch merges
Change-Id: I64c3bbcda0f353fe9c14b0d5bea241e0304c0e2e
Follows-Up: I1a8657ff9fd14618c6709dbab62c3b4ee9f659a5