Commit graph

7101 commits

Author SHA1 Message Date
Petr Pchelko
ebd35bdc85 Hard deprecate Revision::getParentLengths
As well hard-deprecate RevisionStore::listRevisionSizes.
It was marked as @deprecated, but the release for the
deprecation was not specified. Let's say it's 1.35.

Additionally, in order to avoid temporary code duplication,
listRevisionSizes now uses getRevisionSizes and ignores the
database object injected into it. This is ok since we're
hard-deprecating the method and all the usages have been
removed.

Bug: T246284
Change-Id: Ifad1c25a0af892b88fce492b2d34c8cf71279b70
2020-03-18 12:26:26 -07:00
Petr Pchelko
1e4beb3107 Hard deprecate Revision::newKnownCurrent
Bug: T246284
Change-Id: Iba93fdeb0a88e6fa4068f03367b23a1f670257c6
2020-03-18 11:52:44 -07:00
jenkins-bot
b53ac504c5 Merge "Stop accepting ApiMain instances in ApiResult::__construct" 2020-03-18 16:30:36 +00:00
Daimona Eaytoy
c1200325fc Stop accepting ApiMain instances in ApiResult::__construct
This was deprecated in 1.25, no code doing that:
https://codesearch.wmflabs.org/search/?q=new%20%5C%5C%3FApiResult%5C(%5Cs*(new%7C%5C%24)&i=nope&files=&repos=

Change-Id: I21fff4fa66478d2eada13e2ff801bcd6a58b865a
2020-03-18 15:57:05 +00:00
Ladsgroup
05e0582d86 Revert "Default to qqx in SpecialPageExecutor"
This reverts commit a2f186a968.

Reason for revert: Caused issues like https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php72-noselenium-docker/6614/console

Change-Id: I1266dc539eaa563564869f9bf3bb51588f0bc249
2020-03-17 15:11:17 +00:00
Lucas Werkmeister
a2f186a968 Default to qqx in SpecialPageExecutor
It doesn’t make sense to make the tests depend on the surrounding wiki’s
content language, so let’s use qqx unless the test specifies something
different. This also improves performance because translations no longer
have to be loaded.

The idea is stolen from I8ff715ac53, but this is a more aggressive
version that might improve performance for more tests.

Depends-On: Ica7547812716119e0d0ad504cf52b59358d3f0af
Depends-On: I2e36d7fb8eddc06053b4297213ef26df6b40e17d
Change-Id: I67632cc226c9344bfa5c1ea21d596f34f6b23fab
2020-03-17 13:17:33 +00:00
Thiemo Kreuz
7a4df9b019 Remove auto-generated and empty lines in comments
… and add the missing newline after the initial <?php.

Change-Id: I83bbbb1504e4b2bd97eec63c7626d34c655c3197
2020-03-17 09:55:24 +01:00
mainframe98
2619b261bb Support the creation of Skins with services injected
The old way of providing a callable to SkinFactory::register is
still supported. Those callables expected the skin name as their
first argument. Coincidentally, so does the constructor of Skin.
Some skins might not define any constructor parameters at all,
which is acceptable to PHP, as it will just discard the argument.

The registration using $wgValidSkinNames has not been changed,
and skins that want to define services to be injected will still
need to manually register their skin to the skin factory.

CodeSearch did not indicate any extensions or skins manually
constructing a SkinFactory in tests, but for posterity, the old
way of creating a SkinFactory for testing can be replaced with
  new SkinFactory( new ObjectFactory(
  	$this->createMock( ContainerInterface::class )
  ) );

Note that the constructor for SkinFactory for internal use only,
in accordance with the Stable interface policy.
You should use MediaWikiServices::getInstance()->getSkinFactory
instead.

Bug: T244466
Change-Id: I8ba9d869bddd9b6124e47697b789d752c0620b02
2020-03-16 23:25:42 +00:00
jenkins-bot
00e26b1563 Merge "WikiPageDbTestBase: Remove use of global $wgUser" 2020-03-15 22:34:20 +00:00
DannyS712
559cd0bfd9 WikiPageDbTestBase: Remove use of global $wgUser
Bug: T243708
Change-Id: Ibd3360f6fd859fc7f4ebfe453a90a81dd4e662df
2020-03-15 20:39:41 +00:00
Timo Tijhof
c036b6aa5b cache: Remove use of $wgContLanguageCode in MessageCacheTest
Has been an unconfigurable copy of $wgLanguageCode,
since 2006 (MW 1.8).

Bug: T247674
Change-Id: I35f03bfcbf416d8689ba7b42c2bc4b9b0f1376e3
2020-03-15 00:23:02 +00:00
jenkins-bot
18017b1af3 Merge "languages: Move default $wgNamespaceAliases to MessagesEn.php" 2020-03-15 00:14:08 +00:00
Timo Tijhof
75ccdc6147 languages: Move default $wgNamespaceAliases to MessagesEn.php
These are not configuration but business logic, similar to the
canonical names that are in NamespaceInfo.php, these must always
exist and cannot be altered or unset.

They were previously unconditionally assigned during all requests
in Setup.php and passed down as "site configuration".

Changes:

* Move them to MessagesEn.php where they can be cached and
  processed the same way as other core-provided aliases.

  Document and confirm with tests that this is a mergeable
  attribute that follows the language chain.

* Remove the duplicated code in a few places that was reading
  this variable + Language::getNamespaceAliases(), to instead
  just call the latter and move the logic there, centralised,
  and tested.

  In doing so I noticed that these were applied in an
  inconsistent order. Sometimes the config won, sometimes not.
  There's no obvious right or wrong way here, but I've chosen
  to standardise on the way that Language::getNamespaceIds() did
  it, which is that config wins. This because that method seems
  to be most widely used of the three (it decides how URLs and
  titles are parsed), and thus the one I least want to change
  the behaviour of.

* Document that $wgNamespaceAliases may only be used to
  define (extra) aliases, it is and never was a way to access
  the complete list of aliases.

Bug: T189966
Change-Id: Ibb14181aba8c1b509264ed40523e9ab4000fd71a
2020-03-14 19:27:40 +00:00
jenkins-bot
c6fab7b740 Merge "Use MediaWikiServices::getMessageCache" 2020-03-14 18:27:12 +00:00
jenkins-bot
e2ce391e72 Merge "Move contents of mediawiki.legacy.commonPrint into ResourceLoaderSkinModule" 2020-03-14 18:11:27 +00:00
jenkins-bot
208009082a Merge "Use MediaWikiServices::getRepoGroup in file related classes" 2020-03-14 18:11:21 +00:00
Umherirrender
3161311c5a Use MediaWikiServices::getMessageCache
Change-Id: I07fcc9529991adc634c10e5ed8498ac138a1c2b7
2020-03-14 14:25:03 +01:00
Umherirrender
e28b4bd8af Use MediaWikiServices::getRepoGroup in file related classes
Change-Id: Iceec961de4f0cc689f7d3b981afac923b46c98f6
2020-03-14 12:36:27 +00:00
jenkins-bot
216d109a84 Merge "Setup: Move wgSkipSkins appendix to Skin::getAllowedSkins" 2020-03-14 09:03:23 +00:00
jdlrobson
ecac8e1f96 Move contents of mediawiki.legacy.commonPrint into ResourceLoaderSkinModule
Use the existing `legacy` feature. It's assumed that this module was always
used with `mediawiki.legacy.shared` and minimizes disruptions given the
migration steps are identical to the approach taken in `mediawiki.legacy.shared`

The existing release notes are updated to reflect this.

Bug: T242177
Change-Id: I785321d86a5f26808eb83847a3dbbbe62c62698c
2020-03-14 00:16:16 +00:00
Timo Tijhof
50c3a47140 Setup: Move wgSkipSkins appendix to Skin::getAllowedSkins
This isn't a default setting or fallback, it's unconditional
business logic that can't be overidden. This doesn't need to
run on every web request in Setup.php.

Bug: T189966
Change-Id: I708131b111cd2ff0e34c3cc8a4b933eff260b3da
2020-03-13 23:45:12 +00:00
hmonroy
1426f6354c Enhance passwored reset message
Add a more general message for password reset request submissions.

Bug: T246844
Change-Id: I45e9db992ea113c44f7603081754ac9a575a5da6
2020-03-13 16:18:48 -07:00
jenkins-bot
c731a4501c Merge "API: Fix fetching login token from action=query&meta=tokens on private wikis" 2020-03-13 09:59:52 +00:00
jenkins-bot
c628e74b7f Merge "Tests: Remove unneeded uses of global $wgUser" 2020-03-13 04:46:01 +00:00
jenkins-bot
c7c82cb15f Merge "Allow storing additional CSP sources in ParserOutput" 2020-03-13 01:00:03 +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
jenkins-bot
1e98ecf1c3 Merge "resourceloader: Support single-file component .vue files" 2020-03-12 22:16:10 +00:00
Roan Kattouw
ca46126e98 resourceloader: Support single-file component .vue files
Allows .vue files to be used in package modules as if they were .js
files: they can be added to the 'packageFiles' array in module
definitions, and require()d from JS files.

In the load.php output, each .vue file is transformed to a function that
contains the JS from the <script> tag, then a line that sets
module.exports.template to the contents of the <template> tag (encoded
as a string). The contents of the <style> tag are added to the module's
styles.

Internally, the type of a .vue file is inferred as 'script-vue', and the
file is parsed with VueComponentParser, which extracts the three parts.
After the transformation, the file's type is set to 'script+style', and
files of this type contribute to both getScript() and getStyles().

This change also adds caching to getPackageFiles(), because it now needs
to be called twice (in getScript() and getStyles()).

Change-Id: Ic0a5c771901450a518eb7d24456053956507e1ed
2020-03-12 14:32:41 -07:00
jdlrobson
73c20062e0 mediawiki.legacy.shared is merged into existing skin modules and removed
Skins that are using ResourceLoaderSkinModule will need to update their
features to include `legacy`

Note that Ic7af947cfd5a5df4218f006232ede4ee7ed36c62 for Vector
and I6471bc169f3c2a1f51e17b8ee26ac245b0374c18 for Monobook should
be merged in the same release as this patch to ensure these styles
do not disappear from those skins. Minerva or Timeless will not be impacted.

Changes for other skins including Modern and CologneBlue to follow
where needed.

Bug: T242177
Change-Id: Icb910a563273bde92a09b1bb92857d5b6e348baa
2020-03-12 13:17:24 -07:00
jenkins-bot
43705de4f9 Merge "Add RefreshSecondaryDataUpdate and use it in DerivedPageDataUpdater" 2020-03-12 17:43:57 +00:00
DannyS712
3275ef7f5e Tests: Remove unneeded uses of global $wgUser
Tests still pass -> wgUser isn't needed

Bug: T243708
Change-Id: I931f01bc132a5777c27a4296a14fd734a23ca099
2020-03-12 00:52:43 +00:00
jenkins-bot
e005e08768 Merge "Add a ContentModelChange helper, and an api module that uses it" 2020-03-11 22:10:01 +00:00
jenkins-bot
486fcdb86d Merge "ApiEditPage: add baserevid parameter" 2020-03-11 21:54:10 +00:00
jenkins-bot
a88fca753a Merge "Allow SessionProviderInterface to say if it is safe against CSRF" 2020-03-11 16:04:33 +00:00
jenkins-bot
975fcb01f1 Merge "SqlBagOStuff: Add a limit to key length" 2020-03-11 16:04:26 +00:00
Bill Pirkle
8048429103 Allow SessionProviderInterface to say if it is safe against CSRF
Most SessionProviderInterface implementations require CSRF protection,
but some (notably MWOAuthSessionProvider from the OAuth extension)
do not. Add a function for the implementing class to indicate whether
or not the provider is safe against CSRF protection.

Bug: T237852
Change-Id: Ib452b6c75aa7d40dd211a6064f97509b664c3ffc
2020-03-11 10:39:54 -05:00
daniel
3ebd55ed47 ApiEditPage: add baserevid parameter
This adds a baserevid parameter for detecting edit conflicts, as an
alternative to the less precise basetimestamp parameter. This is
introduced for parity with and use by the new REST api.

Bug: T230843
Bug: T34037
Change-Id: Id7565018f66860b5c2ba688777508db1b88700ae
2020-03-11 13:29:09 +01:00
Aaron Schulz
1f4efc6c34 Add RefreshSecondaryDataUpdate and use it in DerivedPageDataUpdater
This class implements EnqueueableDataUpdate and can be pushed as a
job if it fails to run via DeferredUpdates.

Unlike a1f7fd3ada, make RefreshSecondaryDataUpdate skip failing
updates in doUpdate(). Instead of throwing the first exception from
any update, log any exceptions that occur and try all the other
updates. The first error will be re-thrown afterwards.

Also, make sure that each DataUpdate still has outer transaction
scope. This property is documented at mediawiki.org and should not
be changed.

Add integration tests for RefreshSecondaryDataUpdateTest.

Bug: T218456
Bug: T206283
Change-Id: I7c6554a4d4cd76dfe7cd2967afe30b3aa1069fcb
2020-03-11 00:42:48 -07:00
DannyS712
78bc3ae255 Hard deprecate Revision::userCan
Replace remaining uses outside of tests, hide deprecated in tests

Bug: T247259
Change-Id: I91dfb46ed6864ee89d968aea8ec93b5ea2f8389e
2020-03-11 02:10:52 +00:00
jenkins-bot
36c4f0622b Merge "watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest" 2020-03-10 23:06:27 +00:00
jenkins-bot
9827e086b4 Merge "PageProps: Minor clean up logic of PagePropsTest" 2020-03-10 22:58:23 +00:00
Aaron Schulz
13b11a946e rdbms: reduce duplication in Database via helper methods
Add several new internal methods to help with wrangling
the various formats that rows, conditions, options, and
unique key lists can come in. Remove now unused method
isMultiRowArray().

Add various sanity checks and logging for parameters to
upsert(), replace(), insert(), and insertSelect().

Move DatabasePostgresTest to the integration/ directory.

Change-Id: If5988a6f0816e8da2cbf2fd612e1a3e3a2e9c52f
2020-03-10 22:26:04 +00:00
Abbe98
0da37edd0b EnhancedChangesList: add screen reader support to live changes
Expose EnhancedChangesList content to assistive technology as it's updated.

Change-Id: I5b9744075bf7ab03388ed7f827a171b6c253de8d
2020-03-10 21:17:57 +00:00
Daimona Eaytoy
8b7127c5e6 tests: Remove BC code for PHP < 7.1
MediaWiki currently requires PHP 7.2+.

Change-Id: I3456998a8323ff1a5567d1b65db5a28ea550d9c8
2020-03-09 18:12:43 +01:00
Timo Tijhof
643b1fce03 watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
  Instead, explicitly ignore the keys we want to ignore,
  and then assert the array in full.

  This way, newly added properties are explicitly detected
  by the test, and it also automatically means that no bad
  properties can be added. For example, properties like 'new',
  'minor' and 'bot' express their meaning by sheer existence
  and must never be tolerated to exist.

  This was motivated by the many assertArraySubset() deprecation
  warnings that were making the CI build output very noisy,
  and thus it was difficult to quickly find real problems.

  - For testNamespaceParam() I added rcprop=title, as it was
    only asserting those keys. The alternative was to repeat
    all the assertions for the overall output, which other tests
    already did.

* Avoid using User::getName() or Title::getPrefixedText()
  in the asserted expected value. Be explicit. This also
  makes the test run considerably faster.

* Use 'tablesUsed' the way we normally do in MediaWiki unit
  tests, by declaring the class member. (We never use
  TestCase constructors.)

* Remove use of harcoded DB truncation for 'recentchanges'.
  MediaWikiIntegrationTestCase does this already, which is what
  `@group Database` and `tablesUsed` are for.

* Remove use of mutable TestUser, the user is never mutated.
  This allows the internal registry to re-use the same instance.

* Remove use of assertArrayHasKey() where it only checked
  something the test would immediately assert on the next line.
  We already have PHPUnit configured in general to assert and
  fail directly upon any undefined key access.

* Use sample names like Foo, Bar and Quux which are easier
  to remember and distinguish than overly long and similar
  titles with some word or number added at the end of them.

Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 18:24:22 +00:00
Timo Tijhof
b4c5529890 PageProps: Minor clean up logic of PagePropsTest
* Remove mention of the once-new-now-deprecated assertArraySubset()
  method of PHPUnit.

* Rename private "the_properties" to use camelCase and have a
  clearer name in relation to "$properties" (actual vs expected).

* Avoid dynamically computing the expected values at run time.
  In particular I found array_replace_recursive() making the
  test hard to review for correctness.

  Previously, it changed our expected properties to contain the
  additional properties from the actual return value, and then
  compared the two, which is somewhat confusing, since those
  values are not actually what we gave the test nor what we
  care about.

  Instead use the expectedProperties array unmodified, and
  run the assertion only on the subset of keys we want to assert.

Change-Id: I526d8a47296adcb84ed427639e149e69a83c8280
2020-03-06 20:34:02 +00:00
jenkins-bot
0bff82db03 Merge "Make id attributes not include ascii whitespace per spec" 2020-03-06 16:55:18 +00:00
jenkins-bot
fd5dde8b86 Merge "Fixes for batch watchlist deletion and relative expiries" 2020-03-06 02:04:34 +00:00
jenkins-bot
b7a16d85da Merge "Remove $wgEnablePartialBlocks config and always enable partial blocks" 2020-03-05 21:41:08 +00:00
MusikAnimal
4fddfb17df Fixes for batch watchlist deletion and relative expiries
Change-Id: I3902011b7c56cb0804754cc398a2b93778e73960
Follows-Up: Ifff5e56e0222bb325cf796e0aa3d88825820d1fd
Bug: T245213
2020-03-05 16:11:39 -05:00