Commit graph

163 commits

Author SHA1 Message Date
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
Reedy
a8b006426e Fix tests/ PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I0beed1a35e046705fb84c9d1f63cf92afd009bb4
2020-05-16 04:30:21 +01:00
Dave Pifke
0a3aa08b72 OutputPage: Add experimental preconnect resource hint for thumbnails
Adds <link rel="preconnect"> for the first valid foreign or local file
repo, on pages containing images.

This is a hint to the browser that it should open a connection to the
other host (e.g. upload.wikimedia.org), if it doesn't have one
already.  Doing so allows the connection setup to happen before page
parsing is complete, and should result in faster image loading,
especially on slow connections.

Bug: T123582
Change-Id: I2dcc14f05012570a3e41ed8c7064969a4cbfb6db
2020-04-07 21:04:47 +00:00
Brian Wolff
89be2c5820 Allow storing additional CSP sources in ParserOutput
This adds methods to ParserOutput ::addExtraCSPStyleSrc,
::addExtraCSPDefaultSrc, and ::addExtraCSPScriptSrc, to easily
allow parser tags/functions to add additional CSP sources if their
tag needs it. Previously such an extension would need to use
and OutputPage hook. This is modeled on how addModules() works.

The immediate use case is for Kartographer (T240960), although
its expected that lots of extensions might do something like this,
especially extensions used outside of Wikimedia.

Change-Id: I24e5f0b4edff58025a0c2a3e1a9aa3f62eb7db7b
2020-03-12 17:39:51 -07:00
Thiemo Kreuz
e1dd371e11 Make use of PHPUnit's assertCount feature where possible
… and avoid assertEmpty() on arrays, in favor of a much more strict
assertSame( [] ).

Change-Id: I20266b0b1fc38a3a87666ba1b0793cb2b37d94a9
2020-03-02 15:58:41 +00:00
Aaron Schulz
5282a02961 resourceloader: support tracking indirect module dependency paths via BagOStuff
This can be enabled via a configuration flag. Otherwise, SqlModuleDependencyStore
will be used in order to keep using the module_deps table.

Create a dependency store class, wrapping BagOStuff, that stores known module
dependencies. Inject it into ResourceLoader and inject the path lists into
ResourceLoaderModule directly and via callback.

Bug: T113916
Change-Id: I6da55e78d5554e30e5df6b4bc45d84817f5bea15
2020-02-13 17:26:36 +00:00
jdlrobson
8cd2e13363 Deprecate access of logos directly from config, introduce wgLogos
Add getAvailableLogos static method and wgLogos config variable

Longterm we'll phase out wgLogo and wgLogoHD for this more extendable
config.

wgLogoHD is marked as deprecated. wgLogo continues to function as before
when wgLogos doesn't exist to cause minimum disruption.

From now on all logos should be accessed via getAvailableLogos. Patches
in Minerva and Vector follow. See I00899c16c0325f36b671baf17e88c2b5187b3526,
I569e0d800e147eabc7852567acd140108613f074 and
I013bd0904fe8c55efa49d14e84cf06ec1412896f.

Bug: T232140
Change-Id: I66a971631c623cc94b58eb0e5e5bad804789bf1c
2020-02-04 01:56:20 +00:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
C. Scott Ananian
1aef5d72d9 Remove deprecated non-tidy OutputPage::parse/parseInline methods
The non-tidy parsing modes were deprecated in 1.32.  Remove the
deprecated parse/parseInline methods which use them, as part of a
general clean up of nontidy parsing modes.

Bug: T198214
Change-Id: I04ea82dd20eac8b0ce07a8d0e6b0bf2c4b03dbe8
2020-01-15 16:22:19 -05:00
jenkins-bot
ec34c3a340 Merge "Add get{Robot,Index,Follow}Policy methods to OutputPage" 2019-12-29 01:16:03 +00:00
Daimona Eaytoy
7b946ffb4b Fixes for PHPUnit 8 compat in DB suite
Once again, this fixes all issues aside from assertArraySubset.

Bug: T192167
Change-Id: I45c91dc1cf23f04140576dc66233558bb6021324
2019-12-15 00:27:54 +00:00
Daimona Eaytoy
f5529400cc Stop using assertContains with string haystack
This was done automatically by replacing every assertContains with
string *needle*. Then verifying the results.

Bug: T192167
Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
2019-12-15 00:22:44 +00:00
Jack Phoenix
730f7b5917 Add get{Robot,Index,Follow}Policy methods to OutputPage
Inspired by wikiHow's RobotPolicy extension, which depends on the existence of OutputPage#getRobotPolicy, as the extension needs to know the current robot policy state.

Change-Id: I764f5584a9f04a6b66c53193e9118dd1a5248284
2019-12-11 14:23:51 +02:00
Umherirrender
a1f0be1c21 Use nullable type in function signature
Enable the sniff

Change-Id: I9fff860706b0ffb99bb9e78ff26d15bc7c87bdb4
2019-11-20 19:20:38 +01:00
David Barratt
441ff2003e
Add tests to OutputPage::sendCacheControl()
Before making improvements to OutputPage::sendCacheControl() the test coverage
should be increased.

Bug: T236862
Change-Id: I4a76b0894e2d574688e1cbd30f32ee7504801082
2019-11-06 12:58:29 -05:00
jenkins-bot
169e21e921 Merge "tests: Add type hints to OutputPageTest" 2019-11-01 03:07:57 +00:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
jenkins-bot
17b931caf6 Merge "Remove Language::factory and getParentLanguage use" 2019-10-29 09:25:29 +00:00
Brian Wolff
67ea4f5747 Mild refactoring of ContentSecurityPolicy
This is to make it behave in a more object orientied way. The
goal is to make it be easier to allow extensions to mark certain
pages as requiring a different policy (For example, CodeEditor
extension uses a blob: url with a WebWorker. We don't want to
include that on the policy of every page, but allow the extension
to mark it as required whenever needed).

This commit does not change code behaviour in any way.

Change-Id: I4bf53dabb6e6c5446cea99a64db68b300cef2fd4
2019-10-28 09:02:14 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Aryeh Gregor
e787246ce8 LanguageFactory to replace Language::factory()
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().

Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
2019-10-23 10:48:23 -07:00
Umherirrender
5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00
Daimona Eaytoy
8545ce131a Kill the remaining usages of PHPUnit4And6Compat methods
Bug: T192167
Change-Id: I1ea19e9b53683b7d32ff9836990ee73ab3e11104
2019-10-06 10:12:54 +00:00
jenkins-bot
889f683035 Merge "Clean up most of b/c for phpunit4" 2019-10-06 02:17:39 +00:00
Amir Sarabadani
440297fa3a Clean up most of b/c for phpunit4
We don't support phpunit4 anymore:
https://w.wiki/9UT

Change-Id: Ia7c932998f1a49af1e322ab9e1dc249b7bd2e8b2
2019-10-06 00:14:35 +02:00
Daimona Eaytoy
ef5ab69629 Replace setExpectedException with two args
Find: ^(\t*)(\$this->)setExpectedException\(\s+(\\?[a-z\\]+::class),\s+('(?:[^'\\]|\\')+'|"(?:[^"\\]|\\")+")\s+\);

Replace: $1$2expectException( $3 );\n$1\$this->expectExceptionMessage( $4 );

+broke long lines manually.

Bug: T192167
Change-Id: I5557b4372625def55a53ac637c2f980f51f12933
2019-10-05 16:14:05 +00:00
Thiemo Kreuz
5719b28cee tests: Add type hints to OutputPageTest
… to make my PHPStorm IDE complain less about unknown types. The moment
the tests go green this should proof itself, because there is no other
code that depends on this test than the test itself. ;-)

Note the removed options array was broken. The comparison checked the
*values*, not the keys.

Change-Id: I1929cd694808d5b924933fc7033c05eaceda7e34
2019-10-01 14:50:57 +02:00
Thiemo Kreuz
32a429e8c4 tests: Prefer assertSame() when comparing the integer 0
assertSame() is guaranteed to not do any type conversion. This can be
critical when acciden tially comparing, for example, 0 to 0.0.

Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525
2019-09-19 15:35:23 +00:00
Timo Tijhof
9f516f1d3b resourceloader: Reduce width of module hash from 7 chars to 5
In a nut shell:

* We very often (52% of modules on enwiki) pad the hash with a zero,
  which means the amount of bits we currently compute already fit in
  6 characters already for most modules. For some modules (3%) we
  even padded two zeroes.

* For the (now documented) use cases, the space of 78 Giga
  (78 billion, or 78 milliard) seems more than we need. The space of
  60 million should be enough.

  This follows-up dfd046412f from 2016, which previously shortened the hash
  down from 8 chars of base 64 (or 12 chars of hex) to 7 chars of base 32.
  Before that change, the space was 281 Tera (64^8, or 16^12).

For more details see the added inline comment for ResourceLoader::makeHash,
and also the data at <https://phabricator.wikimedia.org/T229245>.

Bug: T229245
Change-Id: I9ad11772a33b3a44cb625275b1d7353e1393ee49
2019-09-02 01:25:48 +00:00
Piotr Miazga
b7204566d2 Deprecate skin functions that are not skin responsibilities
Skin shouldn't be responsible for providing requested revisionId
nor if that revision is the current revision.
The OutputPage object has all required information (both the
currentRevisionID and the current Title object).

Change-Id: I2dbae4c6968a2b3b3cea3e09977e9579609b4cc5
2019-08-23 13:21:11 +00:00
Timo Tijhof
6778f737c1 resourceloader: Remove register() 'object' use in OutputPageTest
Follows-up d6dd6e4d72, missed one :)

Bug: T222637
Change-Id: I105772d655ce1b64e3eb1d6222b57adfb69ec51d
2019-07-14 19:19:46 +00:00
Timo Tijhof
a69880e05c resourceloader: Only output ResourceLoaderDynamicStyles when needed
In mediawiki.js, this marker has always been optional, falling back to
appending to <head>. When no stylesheets need to be after the marker
(e.g. no site styles on the wiki, and user is not logged-in), then
there is no need for the marker to exist.

In a previous refactor, I was going to do this and created an
"$append" variable in the function to do what this commit does,
but I forgot to actually use it for anything.

Test Plan:
* Local wiki, with no MediaWiki:Common/{Skinname}.css pages existing.
* When logged-out, before this change, there is a marker, now there is not.
* When creating "MediaWiki:Group-user.css" and logging in, there is still
  a marker, and it is still above the <link> for that user styles request
  in the <head>.

Bug: T219342
Change-Id: I2e9657f318088860916823efeb96ae4f1532974c
2019-07-04 19:14:39 +00:00
James D. Forrester
5cbb90cf67 OutputPage::addScriptFile: Drop silencing invalid paths, deprecated in 1.24
Change-Id: Ia65c70366ab67324ef2a02f9b0e81a6fb7a081cb
2019-06-27 17:22:52 +00:00
C. Scott Ananian
73ec2a1836 Follow up to 'Remove support for the deprecated Key header'
Clean up a few more code paths and documentation bits left behind by
Ia53d07cd8ce8ab1497294ea244c13c7499f632c7.

Change-Id: I2bb1749c45bb79b27c5a3b2e1b8ed3395e8c11e0
2019-06-20 15:01:51 -04:00
C. Scott Ananian
ce1bd86a4b Remove $wgUseKeyHeader and OutputPage::getKeyHeader(), deprecated in 1.32
These implemented a since-abandoned draft IETF spec, and the code was
broken due to (1) case-(in)sensitivity issues with the Accept-Language
header and (2) the BCP47 language code compatibility workaround we use.

Change-Id: Ia53d07cd8ce8ab1497294ea244c13c7499f632c7
2019-06-19 15:14:54 -04:00
C. Scott Ananian
8a80f58cef Remove OutputPage::addWikitext()* functions, hard-deprecated in 1.32
This starts cleaning up the programmer-visible API for OutputPage
and removed some deprecated untidy parser modes.

Change-Id: Ib464b57248f114b68424ec1175d36ad86d1319ad
2019-06-19 15:14:54 -04:00
Fomafix
63fc0a8cc7 resourceloader: Omit default 'lang' and 'skin' params from load.php urls
lang=qqx and skin=fallback are the default values.

This change removes the default values from the load request of the
html5shiv module.

Before this change
 <script src="/w/load.php?lang=qqx&amp;modules=html5shiv&amp;only=scripts&amp;skin=fallback&amp;sync=1"></script>
With this change
 <script src="/w/load.php?modules=html5shiv&amp;only=scripts&amp;sync=1"></script>

Change-Id: Ie384ce0f7ab1bd0b6c2d3f0ca4a990c3cf3a7f15
2019-06-13 17:22:07 +00:00
Kunal Mehta
01541db36b Remove usage of deprecated SkinFactory::getDefaultInstance()
Change-Id: I3bd50f8ca5baabd34dbc0e3bbc2f97e94650a17a
2019-06-02 21:08:07 -04:00
James D. Forrester
f9f8dff40f Rename CDN config variables to be generic, deprecating the old names
Hook, methods, classes still to rename where appropriate.

Bug: T104148
Depends-On: Id34339dff88bc6d1863378ac94b96b2d590b891d
Depends-On: I4e2938395bcbf7956b83fff00978f09c61dcfa36
Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756
2019-05-24 21:09:22 +00:00
Reedy
9f2ffdfbd4 Remove "Squiz.WhiteSpace.FunctionSpacing" from phpcs exclusions
Change-Id: I78b3315f26ab91b6b443f5b028a635552f82f5a3
2019-05-11 02:44:26 +01:00
Timo Tijhof
df010dd284 resourceloader: Remove redundant 'window' indirection
Use global variables directly as globals, except for the specific
case of accessing it when it may not exist. In those cases we
use the fact that undefined properties of an object yield the
`undefined` value which we can cast to false. Accessing an undefined
variable would yield a ReferenceError exception.

Change-Id: I1d9e9aa5845ba3c756ad6e31358d8594e003b04b
2019-05-08 21:24:30 +00:00
jenkins-bot
da42dd58e7 Merge "parser: Omit outputting newline after final line" 2019-03-19 14:37:16 +00:00
jenkins-bot
76e1adc554 Merge "parser: Remove trailing newline after prefixes have been cleared" 2019-03-19 14:18:30 +00:00
saper
d46fbd1a71 Advertise feeds only if $wgFeed is enabled
Wikis with $wgFeed=false should not present an Atom icon on the RecentChanges/Watchlist.

Bug: T116145
Change-Id: Ic64f7f5115a77c42ed2b336f6996fe711b3822ba
2019-03-17 02:22:20 +00:00
Arlo Breault
a91757523a parser: Omit outputting newline after final line
Bug: T208070
Depends-On: I47d1d9620031036b9497cacf70b34a45c3e5f409
Depends-On: I6119b4af9632496dbda81c3a3951c55217e7c2d5
Depends-On: I584f74e2ba0d14c2975fb43cc53c5e26080e6fc7
Depends-On: Ie70e1915c172d2d67b3b8b90eb35f753b800f61e
Change-Id: I120ca25a77b7b933de4afddd1d458e36a95e26da
2019-03-15 14:22:45 -04:00
Arlo Breault
8384d48ae0 parser: Remove trailing newline after prefixes have been cleared
Bug: T208070
Depends-On: I74953d5de765a2245a2999f17c7ae1cf49376bd1
Change-Id: I05511aee275238954f22db78616b19ce10cd6490
2019-03-15 14:22:42 -04:00
Timo Tijhof
3dc6b84a31 resourceloader: Omit default 'debug=false' from load.php urls
Change-Id: I2a2f92b0f0438420105e6a4e4d97eb5f8c480917
2019-03-08 21:29:18 +00:00
Timo Tijhof
c6f3440832 resourceloader: Remove addModuleScripts, and deprecate getModuleScripts.
The addModuleScripts() methods were deprecated in 1.31 and 1.32,
these are now removed.

The getModuleScripts() are now deprecated as well, always returning
an empty array. To be removed in 1.34.

Depends on commits for bundled/wmf-deployed extensions that
remove the last few remaining callers to the deprecated functions
in: 3D, Collection, Flow, GlobalUserPage, and Wikibase.

Bug: T188689
Depends-On: If9f0bc6aef85117587fa1929f34f8861c8d80314
Depends-On: Ia8d41b97fbf6822f5f8f7ac889408acce1ac9a3a
Depends-On: I503b919739ea474ff33726815b0da55e2f7e2724
Depends-On: I236ef637fd03b810a46eb361e25067a037e9d183
Depends-On: I62e17779753b977a452cc0c9694947941e999cc3
Change-Id: I5a19b8f164ccf666485d2971202194b747f882df
2019-03-05 16:54:08 +00:00
Timo Tijhof
3edaa0b37c resourceloader: Make $rl parameter mandatory for MessageBlobStore
Change-Id: I851b2417b7e495a1d0c7ee1aa8be2b2e970840bb
2019-02-19 17:16:57 +00:00
Fomafix
cff7dac346 Fix @param tags
* Use 'callable' instead of 'callback'.
* Remove '$' as part of a type name.
* Add missing type.

Change-Id: Ic1b39a7d8cbbee000d8fb2f3a1f71a621bd01993
2019-02-03 16:49:10 +01:00