Commit graph

14052 commits

Author SHA1 Message Date
mainframe98
7299aed7a5 tests: Allow overridable data providers to be static
This uses some reflection to identify if the data provider is static or
not. If it isn't, a deprecation notice is emitted. This doesn't fail the
tests, but is still printed in the output.

To facilitate this, the relevant abstract method has been uncommented,
as PHP does not like it when function signatures do not match up.

This approach means that tests in extensions or skins do not immediately
break when making data providers static. Instead, they can do so at
their own pace.

Bug: T332865
Change-Id: I5ff35ad0e894f0a27beae00257dc1fc599ad518d
2023-05-16 16:28:43 +01:00
jenkins-bot
f7f572cc4b Merge "Remove the nativeGalleryEnabled parsoidSetting" 2023-03-31 03:06:55 +00:00
jenkins-bot
8bb1e60724 Merge "ResourceLoader: Raise MW JavaScript startup requirement to ES6" 2023-03-31 01:18:54 +00:00
Arlo Breault
bc1601f874 Remove the nativeGalleryEnabled parsoidSetting
This is now enabled in production (Ic5a4a9950d51f63b17f4c5e70516bec87b981aa5)
and not something we want to remain configurable.

It is removed from Parsoid in I52ddfd21ff2e72a34cb5eb68742e3dfb85c6ccf6

Change-Id: I6a4d7d33fb42270fc5da3a922aa0a959180fb33f
2023-03-30 17:52:56 -04:00
James D. Forrester
6c7177349b ResourceLoader: Raise MW JavaScript startup requirement to ES6
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/Banana
  https://phabricator.wikimedia.org/T152602
  https://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
2023-03-30 14:26:05 +01:00
jenkins-bot
10b17b5132 Merge "mediawiki.skin.defaults.less: Import all Codex mixins" 2023-03-30 10:07:45 +00:00
jenkins-bot
0b7ca90745 Merge "ResourceLoader: Fix typo in ResourcesTest" 2023-03-30 08:04:04 +00:00
jenkins-bot
a6880fe3a0 Merge "ResourceLoader: Move ForeignResourceStructureTest to integration/" 2023-03-30 07:36:04 +00:00
jenkins-bot
6fdeb63eb8 Merge "ResourceLoader: Add path remapping for Less imports" 2023-03-29 23:47:38 +00:00
jenkins-bot
93511c2e38 Merge "Make $wgHooks trigger deprecation warnings." 2023-03-29 22:20:08 +00:00
Timo Tijhof
a220a7c376 ResourceLoader: Fix typo in ResourcesTest
Follows-up Ia062ff2d8b (01aec63c21).

Change-Id: I3728a0a3c9484fa08caa60986c51770aeed00a96
2023-03-29 14:18:15 -07:00
Timo Tijhof
1911c8fc27 ResourceLoader: Move ForeignResourceStructureTest to integration/
Follows-up I071be5821711f (2cf45bc934) and I8aeffc1f2e81 (3270283abf).

Avoid use of `@standalone` in core, since that group is only
special-cased in WMF CI for extension and skin repos.

Core tests, unlike extension tests, are already skipped by default
when running PHPUnit in CI for extension and skin repos. The exception
is the structure/ directory which is for general system-wide checks
that may also cover installed skins and extentensions.

Given that this test only covers core, and that's why we want to
skip it, move it out of structure/.

Bug: T203694
Change-Id: I7431e5627861845f9d49afc4777b76052d3a6e77
2023-03-29 14:14:55 -07:00
jenkins-bot
a48b6ef657 Merge "Make ExtensionJsonTestBase more extendable" 2023-03-29 11:01:03 +00:00
daniel
2016418bc5 Make $wgHooks trigger deprecation warnings.
This will allow us to treat $wgHooks as a normal config
variable in 1.41.

Note: should be backported to 1.40

Bug: T331602
Change-Id: Iddcb760cf8961316d6527e81b9aa968657d8354c
2023-03-29 07:29:37 +00:00
Roan Kattouw
da432a5233 mediawiki.skin.defaults.less: Import all Codex mixins
This makes all Codex mixins available anywhere that the skin variables
are imported, so MediaWiki code doesn't need to import these mixins
separately. This also ensures that the tokens are present when the
mixins are used.

Bug: T328602
Change-Id: If2b4073115d9082829e4917c87c167d18f5431d9
2023-03-28 16:24:37 -07:00
Roan Kattouw
7492234847 ResourceLoader: Add path remapping for Less imports
This replaces the hacky wrapper files in
resources/src/mediawiki.less/mediawiki.skin.codex-design-tokens/ and
resources/src/medawiki.less/@wikimedia/codex-icons/dist/ with real
import path aliasing/remapping.

Bug: T328602
Change-Id: I2df266cde90d1b8dad8d1d1367b67001e2b2984d
2023-03-28 16:18:44 -07:00
Aaron Schulz
366a0afd63 parser: improve cache TTL accuracy for CURRENT*/LOCAL* magic words
Consolidate cache TTL handling within CoreMagicVariables.

Make the TTL account for how many seconds away the value is from changing.
For example, CURRENTHOUR should change soon after the next hour is reached.
There is a minimum adjustment TTL to avoid parser-after-save delays.

This allows for longer caching in most cases, as well as more up-to-date
rendering when the hour/day/week/year is about to change. Previously, there
were blind TTLs, which are either way too pessimistic or way too generous.

This commit does not change the CURRENTTIME, CURRENTTIMESTAMP, LOCALTIME,
and LOCALTIMESTAMP words, since there is no reasonable way to cache output
while keeping them up-to-date.

Bug: T320668
Change-Id: I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f
2023-03-28 22:35:17 +00:00
mainframe98
ffed58bcef Make ExtensionJsonTestBase more extendable
Extensions or skins might want to define their own tests and not
giving them access to the cached JSON is limiting. Because the
method was private for a reason, make it final to prevent overriding
it and breaking things in weird ways.

Also, now that we are on PHP 7.4, use JSON_THROW_ON_ERROR to allow
PHPUnit to have clearer error messages when extension.json/skin.json
is not valid JSON.

Follows-Up: I47757958e54d5e9d47a309b4037ff47dd9c1d382
Change-Id: I5819da9c59499d1752057f79b1855872064ff32e
2023-03-28 20:38:58 +02:00
jenkins-bot
5c573b3e3a Merge "Make ApiOptions unavailable to temporary users" 2023-03-28 15:52:55 +00:00
csimiyu
d3b508c2b0 Make ApiOptions unavailable to temporary users
Bug: T332414
Change-Id: I7646f8a80309b739e647558a971725b9e59f3b06
2023-03-28 16:45:19 +03:00
jenkins-bot
fb1b70467d Merge "mime: Add support for 'font/woff' and 'font/woff2' mime type" 2023-03-28 09:40:07 +00:00
jenkins-bot
63353a0fe7 Merge "mime: Add support for 'font/sfnt' mime type" 2023-03-28 09:39:58 +00:00
rrana-wmf
b8a3f02403 mime: Add support for 'font/woff' and 'font/woff2' mime type
This patch enable .woff files with 'font/woff' mime type
and .woff2 files with 'font/woff2' mime type for MediaWiki.

Bug: T309714
Change-Id: I7375ee87c865f22a5539af52fa7dae122d2644b9
2023-03-27 15:59:20 +05:30
rrana-wmf
e9f5698be7 mime: Add support for 'font/sfnt' mime type
This patch enable .ttf files with 'font/sfnt' mime types for MediaWiki.

Bug: T309714
Change-Id: If01d748bfd1ccce0cf49b1e9deeb5fd7ba9b3f73
2023-03-27 15:51:13 +05:30
jenkins-bot
18c0986895 Merge "ApiParse: Add 'parsoid' option" 2023-03-27 08:09:18 +00:00
jenkins-bot
7b98392676 Merge "ParserOutputAccess: Fork primary and secondary caches for parsoid" 2023-03-27 08:09:07 +00:00
jenkins-bot
6c32cc6698 Merge "Allow setting a ParserOption to generate Parsoid HTML" 2023-03-27 08:08:56 +00:00
jenkins-bot
63ed5bc95b Merge "tests: Fix @covers for MaintenanceParametersTest" 2023-03-27 06:36:12 +00:00
C. Scott Ananian
07a7ac0c88 ApiParse: Add 'parsoid' option
Allow requesting parsoid-format output from the action=parse API.

Change-Id: Iba9197491fd85e95b981206b63e43b470aac957c
2023-03-26 21:48:16 -04:00
C. Scott Ananian
2caf69797c ParserOutputAccess: Fork primary and secondary caches for parsoid
Uses flag to detect which cache instance to use based on ParserOptions
and sets the primary and secondary caches accordingly.  This ensures
that the ParserCacheMetadata cache used by the ParserCache is also
appropriately forked for Parsoid, as Parsoid may consult different
options in the ParserCache than core does.

A follow up patch will attempt to refactor this to be less
parsoid-specific.

Bug: T327769
Bug: T330677
Co-authored-by: Alangi Derick <alangiderick@gmail.com>
Change-Id: Id580b97ad9a0b90bbe56d4de3c2f999274fe329b
2023-03-26 21:46:07 -04:00
C. Scott Ananian
cfd9c516e1 Allow setting a ParserOption to generate Parsoid HTML
This is an initial quick-and-dirty implementation.  The
ParsoidParser class will eventually inherit from \Parser,
but this is an initial placeholder to unblock other Parsoid
read views work.

Currently Parsoid does not fully implement all the ParserOutput
metadata set by the legacy parser, but we're working on it.

This patch also addresses T300325 by ensuring the the Page HTML
APIs use ParserOutput::getRawText(), which will return the entire
Parsoid HTML document without post-processing.  This is what
the Parsoid team refers to as "edit mode" HTML. The
ParserOutput::getText() method returns only the <body> contents
of the HTML, and applies several transformations, including
inserting Table of Contents and style deduplication; this is
the "read views" flavor of the Parsoid HTML.

We need to be careful of the interaction of the `useParsoid` flag with
the ParserCacheMetadata.  Effectively `useParsoid` should *always* be
marked as "used" or else the ParserCache will assume its value doesn't
matter and will serve legacy content for parsoid requests and
vice-versa.  T330677 is a follow up to address this more thoroughly by
splitting the parser cache in ParserOutputAccess; the stop gap in this
patch is fragile and, because it doesn't fork the ParserCacheMetadata
cache, may corrupt the ParserCacheMetadata in the case when Parsoid
and the legacy parser consult different sets of options to render a
page.

Bug: T300191
Bug: T330677
Bug: T300325
Change-Id: Ica09a4284c00d7917f8b6249e946232b2fb38011
2023-03-26 21:46:05 -04:00
jenkins-bot
a838c9b598 Merge "Just another 80 or so PHPStorm inspection fixes (#4)" 2023-03-25 00:55:40 +00:00
jenkins-bot
0243c83cde Merge "Fix even more PHPStorm inspections (#3)" 2023-03-25 00:47:47 +00:00
jenkins-bot
c9cde5d88b Merge "Fix more PHPStorm inspections (#2)" 2023-03-25 00:39:19 +00:00
Tim Starling
be3018b268 Just another 80 or so PHPStorm inspection fixes (#4)
* Unnecessary regex modifier. I agree with this inspection which flags
  /s modifiers on regexes that don't use a dot.
* Property declared dynamically.
* Unused local variable. But it's acceptable for an unused local
  variable to take the return value of a method under test, when it is
  being tested for its side-effects. And it's acceptable for an unused
  local variable to document unused list expansion elements, or the
  nature of array keys in a foreach.

Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
2023-03-25 00:39:06 +00:00
jenkins-bot
ae0406a3fd Merge "Fix some PHPStorm inspections (#1)" 2023-03-25 00:35:04 +00:00
Tim Starling
317b460500 Fix even more PHPStorm inspections (#3)
* Inappropriate @inheritDoc usage. Arguably all @inheritDoc is
  inappropriate but these are the ones PHPStorm flags as misleading
  due to the method not being inherited.
* Doc comment type does not match actual argument/return type.
* I replaced "@return void|never" with "@return void" since never means
  never, it doesn't make sense for it to be conditional. If a method
  can return (even if that is unlikely) then @return contains the type
  that it returns. "@return never" means that there is no such type
  because the method never returns.
* Incomplete/partial/broken doc tags

Change-Id: Ide86bd6d2b44387f37d234c2b059d6fbc42ec962
2023-03-25 00:30:15 +00:00
Tim Starling
580ec48e5b Fix more PHPStorm inspections (#2)
* Illegal string offset and invalid argument supplied to foreach, due to incorrect type information
* Array internal pointer reset is unnecessary
* $hookData unused since MW 1.35 due to incomplete revert
* array_push() with single element
* Unnecessary sprintf()
* for loop can be replaced with str_repeat()
* preg_replace() can be replaced with rtrim()
* array_values() call is redundant
* Unnecessary cast to string
* Unnecessary ternary. Often the result relies on short-circuit evaluation, but I find it more readable nonetheless.

Change-Id: I4c45bdb59b51b243fa96286bec8b58deb097d707
2023-03-25 00:19:58 +00:00
Tim Starling
d36ea70309 Fix some PHPStorm inspections (#1)
* Triple backslash in regex should really be quadruple backslash
* Using the returned value of a void method
* Immediately overwritten array keys
* Duplicate array keys
* Foreach variable reuse
* sprintf() with too many params
* Incorrect reference usage

Change-Id: I3c649b543c9561a1614058c50f3847f663ff04df
2023-03-25 00:19:33 +00:00
Tim Starling
a784eae6d7 Clean up IDatabase::deleteJoin() return value assumptions
It was decided that deleteJoin() should continue to return void, so the
comment in BlockRestrictionStoreTest and the pass through in
BlockRestrictionStore were not correct.

Change-Id: I634e1e722d25d0cddeb27e051cb0d6da414ee393
2023-03-24 22:26:08 +00:00
Lucas Werkmeister
baedb38abd tests: Introduce ExtensionJsonTestBase
Based on GlobalStateFactoryMethodsResourceTest in Wikibase (repo and
client) and EntitySchema; hopefully also useful in other extensions.

Change-Id: I47757958e54d5e9d47a309b4037ff47dd9c1d382
2023-03-24 16:36:13 +01:00
Lucas Werkmeister
4f2933bb7f tests: Introduce ExtensionServicesTestBase
Based on WikibaseRepoTest and WikibaseClientTest in Wikibase; also to be
used in EntitySchema and hopefully other extensions.

Bug: T330628
Change-Id: I6530947aa7c79a7a6437fc09bca8a721285beb15
2023-03-24 12:24:34 +01:00
jenkins-bot
7715964706 Merge "tests: Make some PHPUnit data providers static" 2023-03-24 03:10:15 +00:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
jenkins-bot
a49ddc8965 Merge "ResourceLoader: Silence failure of encodeJson() for $modules param" 2023-03-24 01:53:17 +00:00
jenkins-bot
c5a05419ef Merge "HookContainer: test more cases" 2023-03-23 23:11:03 +00:00
Umherirrender
98af2ed7df tests: Fix @covers for MaintenanceParametersTest
Follow-Up: Ib67667fead8350e0a539323fb05b160f4c2d882e
Change-Id: Ib3f0dfb578a31c31d38023b5590cf2119a1fe57e
2023-03-23 23:52:41 +01:00
daniel
9ce48b91ba HookContainer: test more cases
Change-Id: I3ae2af6510b5310d2b2e49740126125d9f3defa7
2023-03-23 21:57:43 +01:00
Timo Tijhof
89c17acbf6 ResourceLoader: Silence failure of encodeJson() for $modules param
The $modules param is user controlled. We already catch invalid UTF-8
in server configurations. If something like that makes it here, the
only place it can come from is the client doing it intentionally,
such as the result of scanning tools.

Follows-up I89832142b, which silenced $modules formatting in a CSS
response. This patch also covers the case of a JS response, and adds a
test for both.

Bug: T331641
Change-Id: I03a0ec262203509f069654e7fa6fd8d8debd25d5
2023-03-23 11:20:59 -07:00
Jon Robson
37bd453af6 EditPage: Add capability of targeting editors of code in editor
Can also be used by projects for a policy/recommendations/
to advertise gadget community.

Bug: T311891
Change-Id: Ieee508409843561481da246cf26e0f1d93fea6ed
2023-03-23 17:31:47 +00:00