Commit graph

9826 commits

Author SHA1 Message Date
Aaron Schulz
218b68ed4c rdbms: add $fname parameter to LBFactory::closeAll() for better logging
Change-Id: I2f4b6466c22c89d7515290324e8e2e2f720ada61
2022-04-05 21:39:21 +00:00
jenkins-bot
6676662df9 Merge "[Skins] Add test and fix edge cases for Skin methods" 2022-04-05 14:02:41 +00:00
jenkins-bot
661746fc16 Merge "Emit warnings when accessing deprecated public properties of Parser" 2022-04-05 05:06:05 +00:00
Aaron Schulz
c96dec041e objectcache: make "multiPrimaryMode" work with LB-based SqlBagOStuff
This avoids the previous database type exception in the constructor.

Bug: T212129
Change-Id: I43c6a86883f4122f7395b022bdc6ed7a0cf88121
2022-04-05 01:43:53 +00:00
Jon Robson
c5d16eb519 [Skins] Add test and fix edge cases for Skin methods
While writing an upgrade patch for Femiwiki I noticed 2 bugs in
the existing code. I've added test cases for them both and added
fixes.

Bugs were:
* Skin::makeLink renders empty span when no text
* link-html is not copied to personal menu items

Bug: T305270
Change-Id: I70f1bcff57761bd7af50dbe74e5bfdaa3ae2d6a5
2022-04-01 19:23:26 +00:00
daniel
5fcedc88c9 Add wiki-farm support
Added support for an easy to configure multi-tenant ("wiki farm") mode:
Settings for each site can be placed in a directory specified by
$wgWikiFarmSettingsDirectory. Site detection is controlled by
$wgWikiFarmSiteDetector and defaults to the requested host name.

Instructions for manual testing: https://etherpad.wikimedia.org/p/T221535

Bug: T221535
Change-Id: I7581921b7d99ba1fe7e25523fde691d76b67a99c
2022-04-01 14:29:22 +02:00
jenkins-bot
a6736f063e Merge "phpunit: Fix slow testBotPasswordThrottled by lowering limits" 2022-04-01 03:00:19 +00:00
Aaron Schulz
ff1d05f7ba phpunit: Fix slow testBotPasswordThrottled by lowering limits
Follows-up Ief9e724c84755248, which increased this
from 5 to 1000 API requests.

Bug: T298735
Bug: T225730
Change-Id: I567712f167a7264c22dd86f6005e5fa60939c752
2022-04-01 02:44:57 +00:00
C. Scott Ananian
c1a326f44e Emit warnings when accessing deprecated public properties of Parser
Code search:
 https://codesearch.wmcloud.org/deployed/?q=-%3E%28mLinkID%7CmIncludeSizes%7CmDoubleUnderscores%7CmShowToc%7CmRevisionId%7CmRevisionTimestamp%7CmRevisionUser%7CmRevisionSize%7CmInputSize%7CmInParse%7CmFirstCall%7CmGeneratedPPNodeCount%29&i=nope&files=&excludeFiles=&repos=

The following @deprecated properties are not included in this patch in
order to keep it conservative:

* Hard to code search because of generic name:
  $mTitle, $ot, $mOptions
* Should be @internal, not @deprecated, because they are used internally:
  $mPPNodeCount, $mHighestExpansionDepth
* Used by SyntaxHighlight_GeSHi and TemplateStyles extensions (even though
  they could/should use their own independent unique ID):
  $mMarkerIndex
* Used by test cases for Wikibase:
  $mExpensiveFunctionCount

Change-Id: I1dadff934ead767cbd25615c08768e8e935d6b2e
2022-03-31 19:25:33 -04:00
Kunal Mehta
5498663e0e SECURITY: Add recursion guard to Title::newMainPage()
If the on-wiki "mainpage" message is a bare local interwiki
(`localiw:`), MediaWiki will try to normalize it to the main page,
causing an infinite recursive loop. Once in this state, there's no way
to fix it short of editing the database (or applying this patch).

The easiest way out of this is to add a recursion guard to fall back to
the hardcoded "Main Page" default.

Bug: T297571
Change-Id: I91316ecbdbe7c4ad1b7594643aef29a8e1f8fb26
2022-03-31 22:58:38 +01:00
jenkins-bot
3a23ad3f83 Merge "Remove misleading test in SerializationTestTrain::validateObjectEquality()" 2022-03-31 20:18:36 +00:00
jenkins-bot
d5dbca4b11 Merge "Remove deprecated global function wfWikiID()" 2022-03-31 19:49:58 +00:00
C. Scott Ananian
ea4bedee9d Remove misleading test in SerializationTestTrain::validateObjectEquality()
The initial object comparison using `==` compares all the property values
using `==` as well.  This causes (for example) the string "1" to compare
as equal to the number `1`, the empty string `""` to compare as equal
to the number `0` and other surprising things.

It appears that this comparison was done at an attempt at performance
optimization, but that has little place in a test suite.  Use the full
recursive strict comparison instead.

This requires updating one ParserCache test case which was apparently
created incorrectly (or not properly updated) and relied on the
previous behavior (numbers comparing as equal to strings) to pass.

Change-Id: Ife0e9ccc7be0f4933975bb326203693bc15a9658
2022-03-31 09:50:51 -04:00
jdlrobson
0acc0b5151 Introduce SkinComponentSearch
Changes:
* Internal SkinTemplate::getSearchInputAttributes method is removed
* Skin::makeSearchInput and Skin::makeSearchButton are hard deprecated.
Methods moved to SkinTemplate to support skins using BaseTemplate
(this avoids deprecation warnings in Timeless)
* Correct the function signature for Skin::getRelevantTitle and the
caller in Linker to take into account the use of getTitle and the
possibility of a null return.

Bug: T301723
Change-Id: I0906cd1582b93c741b93503562ec0fe37d80d948
2022-03-31 06:54:42 +00:00
jenkins-bot
71c65e05e0 Merge "Apply logo variant override in ResourceLoaderSkinModule" 2022-03-30 23:42:20 +00:00
jenkins-bot
1137bbf439 Merge "UndeletePage: Undelete associated talk page" 2022-03-30 20:31:33 +00:00
jenkins-bot
535bc0a9e0 Merge "phpunit: Fallback to global default user options" 2022-03-30 18:56:23 +00:00
Daimona Eaytoy
4ce0b39043 UndeletePage: Undelete associated talk page
* Adds option to undelete associated talk page in the context of a
  subject page
* If subject page undeletion fails, talk page undeletion is aborted
* If restoring the associated talk page fails, a status with a
  warning message is returned

Bug: T304962
Change-Id: I7b30863060974d4079639f57178062d359956c2e
2022-03-30 14:08:08 -04:00
Jdlrobson
4a0cbbc0f8 Revert "WatchedStore requires PageIdentity"
This reverts commit c9c6bab379.

Reason for revert: This broke VisualEditor editing.
Not sure why but will repost in different format.
(https://phabricator.wikimedia.org/F35030276)

Change-Id: I7f21a2c756d06f488766896086e5b3488a366c19
2022-03-30 16:18:10 +00:00
Func
983b16d092 phpunit: Fallback to global default user options
The real option manager would do such fallback, this behavior should
be kept in tests.
(Depends-On I814050cfa86ec1e86291d380843eb319fddc924a)

Bug: T297082
Change-Id: I55f7d1e17bde904f2245b31df2df853cf0ca803f
2022-03-30 13:17:10 +00:00
Jon Robson
c9c6bab379 WatchedStore requires PageIdentity
According to the function signature of WatchedItemStoreInterface
a PageIdentity must provided. Any other parameter is deprecated.

The test is updated as it's trying to watch a special page and it's
not possible to watch special pages.

Change-Id: Ia97e497fbae922e46a1098bca32ad3d8d62070fa
2022-03-29 13:44:44 -07:00
Alexander Vorwerk
0bbc238919 Remove deprecated global function wfWikiID()
deprecated since 1.35 and unused

Bug: T298059
Change-Id: I0c601b67beaf8218b7fd7ca46a8caeb1452f4d76
2022-03-29 18:11:05 +02:00
Func
fbe6443942 Apply logo variant override in ResourceLoaderSkinModule
Logo variant override is available for 'wordmark' and 'tagline' in
the new Vector skin and has been used for a while, but the 'logo'
feature built in the core didn't take variants into account.
The logic should be pushed down to ResourceLoaderSkinModule so that
behavior can be consistent between skins and core.

Also, old code use $title->getPageViewLanguage() to determine the
variant of logo, which is a wrong behavior. Logos should be in the
interface language instead of the content variant.

Bug: T273578
Change-Id: Ifb3cc45600d57cf9c72757016148684cd7ab1400
2022-03-28 13:22:07 +08:00
Bartosz Dziewoński
912338452f mediawiki.Title: Treat U+FFFD (replacement character) as invalid
This matches the behavior of PHP Title (added tests to confirm),
and supports a common case of obtaining the title text using the `URL`
API, when the 'title' parameter is using a legacy 8-bit encoding.

Change-Id: I04464c17369ffb0dd4e7c33d2bd4db7b2d050bf4
2022-03-27 20:53:42 +00:00
Func
4204480f13 ResourceLoaderSkinModuleTest: Simplify logo tests input
Share commom config values.

Change-Id: I0a86ac8c45b5df769f92079680ed54758beaacf7
2022-03-27 00:09:43 +08:00
jenkins-bot
7b8c77c207 Merge "context: Add a cached RequestContext::getActionName method" 2022-03-25 13:30:00 +00:00
Timo Tijhof
3fdfef96e4 context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.

The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.

In change I61d66211bd (22f9a32853) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.

This change takes this approach further by making it a stable public
method on RequestContext.

To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.

Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2022-03-25 12:12:48 +00:00
jenkins-bot
a9bae3a83f Merge "resourceloader: Add Module::getSkins to skip irrelevant modules from startup" 2022-03-25 01:17:51 +00:00
Siddharth VP
92372d3786 resourceloader: Add Module::getSkins to skip irrelevant modules from startup
Registering fewer modules reduces the size of the startup module.

The current skin is read from the skin parameter to the load.php
request. Modules can opt-in by specifying skins in which they are
relevant, by overriding getSkins() of ResourceLoaderModule.

Bug: T253582
Bug: T236603
Change-Id: I08a1a59b4eab90d380ca8f874bb6dbba2f399590
2022-03-24 23:38:51 +00:00
Tim Starling
97b8262d1f Use UserRigorOptions directly
Conventionally, public constants are accessed via their declaring
class, except for self:: which is an acceptable shortcut.

Change-Id: If05eab72140267e6ef54736710d751d7f24a7860
2022-03-25 10:06:34 +11:00
Taavi Väänänen
caa8a2c3f0
Allow managing upload-by-url allowlist as a system message
This patch introduces a new system message,
MediaWiki:copyupload-allowed-domains, which lets sysops to define which
domains can be used with the upload-by-url tool. This feature is behind
an off-by-default feature flag, which lets system administrators
disable this feature if it is not wanted.

Bug: T300407
Change-Id: Iae7dafbd71182695444210409d550e5b6d10928b
2022-03-23 11:11:41 +02:00
jenkins-bot
04426c6a05 Merge "rdbms: rename wasKnownStatementRollbackError() to isKnownStatementRollbackError()" 2022-03-22 23:16:04 +00:00
jenkins-bot
259d5133f4 Merge "Fix core newtalk 304 suppression and update deferral" 2022-03-22 23:00:56 +00:00
Aaron Schulz
e0a53cba15 rdbms: rename wasKnownStatementRollbackError() to isKnownStatementRollbackError()
Pass the error number as an argument, similar to isConnectionError()

Fix related mysql documentation links

Change-Id: Id32ef2fd27de65376960de3f5138ffdf7654ff71
2022-03-22 22:59:09 +00:00
jenkins-bot
2f7da6037a Merge "Fix uses of (error|warning|success)box in core" 2022-03-21 20:16:57 +00:00
jenkins-bot
50938694e5 Merge "ApiParse: Ignore 'contentformat' param when the query is based on page" 2022-03-21 17:36:04 +00:00
stang
9c70df0cf6 Fix uses of (error|warning|success)box in core
Replace HTML class for boxes with "mw-message-box-" style.

Bug: T300358
Change-Id: Iddb0fd3ae859714fb03d3a6d4586f8525becaac6
2022-03-20 21:15:26 +00:00
Timo Tijhof
6522ff4ae2 resourceloader: Set class-wide @covers and ignore coverage of HookRunner
Change-Id: I49379986f0e7c05fb3442f0de9f496f151c4bed5
2022-03-20 15:17:21 +00:00
Func
845bf42aa9 ApiParse: Ignore 'contentformat' param when the query is based on page
The 'contentformat' param should only have effects when the parsing
is based on the 'text' param, as what the document described.

Bug: T206253
Change-Id: Ia12b8697e515c6ba89ea81f085292d1ef018bf58
2022-03-20 20:33:20 +08:00
Func
5339aa645b ApiParse: Fail gracefully when the requested format is not supported
Format like 'application/json' is not supported for content model
wikitext, don't fail as internal exception.

This fix the case when providing text/title parameter.

Bug: T206253
Change-Id: I20ef52aa961143b7c50283c0d06acea9f220619c
2022-03-19 19:29:28 +00:00
Alexander Vorwerk
82739980fd parser: change 'level' in parse api back to string
We changed to operate on an int internally in I92daeb0f7be8a0.
Let's cast it back to a string for the api in order to prevent
a breaking change, which is not really necessary.

Bug: T304171
Change-Id: I5f5a9203b4dd085cb5defba72c6650532bc9e8d1
2022-03-18 19:52:24 +01:00
jenkins-bot
4d236a74ee Merge "LoadBalancerTest: Avoid using hard-coded table prefix" 2022-03-18 13:39:05 +00:00
Tim Starling
1155648ecf Fix core newtalk 304 suppression and update deferral
Deferring newtalk updates caused the skin to show the notification on
the same user talk page view request in which it is cleared. Even if the
user refreshed the page, it would still show the notification since a
304 response was given.

So, move the newtalk part of WatchlistManager
::clearTitleUserNotifications down to TalkPageNotificationManager, so
that the in-process updates can be done immediately, with the DB updates
being deferred. TalkPageNotificationManager is now responsible for
deferring the relevant parts.

Originally (2002) the newtalk status was set by calling
User::saveSettings(), which had the side-effect of updating
user_touched. Restore this behaviour, which is fast now due to the
"quick touched" cache. Also update the touched timestamp when the
notification is cleared.

Change-Id: Ic3c14bca7bed04f46afffa971fa0a57224c666ce
2022-03-18 16:52:12 +11:00
jenkins-bot
14564ef874 Merge "WatchedItemStoreIntegrationTest: Call setMwGlobals without $ on name" 2022-03-17 20:28:21 +00:00
Ladsgroup
31c1ca8658 Revert "rdbms: make automatic connection recovery apply to more cases"
This reverts commit 4cac31de4e.

Reason for revert: Blocking the train, reverting the chain.

Change-Id: I7f275b3a25379c6f3256e90947c8eed4b232c0f4
2022-03-17 20:11:10 +01:00
jenkins-bot
13332fbb8f Merge "Revert "rdbms: fix owner id and RELEASE_ALL_LOCKS query in session flushing methods"" 2022-03-17 18:44:40 +00:00
Umherirrender
928f9d5384 WatchedItemStoreIntegrationTest: Call setMwGlobals without $ on name
Follow-Up: I811c444c36c1da1470f2d6e185404b6121a263eb
Change-Id: Id354bb0b9a6795d2b0321112e34e370a680bd2ff
2022-03-17 19:28:08 +01:00
Ladsgroup
a8c5232702 Revert "rdbms: fix owner id and RELEASE_ALL_LOCKS query in session flushing methods"
This reverts commit eed58f2f61.

Reason for revert: Blocking the train, going to revert the whole chain

Change-Id: I64f9e5a9dde106671783f958a686ca697182077b
2022-03-17 18:25:48 +00:00
Func
53afd761b0 tests: Make sure deferred updates are done and re-enable TemplateCategoriesTest
LinksUpdate is a group of deferrable updates, not jobs till now.
See HtmlCacheUpdater::purgeTitleUrls().

Bug: T165099
Change-Id: Icf40c4ff9e14ee06d48600bcbfdc39e2baf68b23
2022-03-17 13:01:08 +00:00
Func
42c0a6ecd0 LoadBalancerTest: Avoid using hard-coded table prefix
Change-Id: I79da2f61c95292701eb9050561f19d04fc52e89c
2022-03-17 13:14:08 +08:00