Commit graph

6927 commits

Author SHA1 Message Date
Timo Tijhof
7929d190b4 WebRequest: Change getFullRequestURL() to use local getProtocol()
Previously it relied on wfGetServerUrl to decide the url,
which passed PROTO_CURRENT on to wfExpandUrl(), when then uses
global $wgRequest and checks getProtocol() on that.

For typical web requests, these would be the same object by
reference, but the needless indirection makes the code harder
to reason about and harder to test.

Instead, check this locally and pass on an explicit HTTP or HTTPS
to wfGetServerUrl/wfExpandUrl.

Change-Id: I797bd2f909625536c3af36f015fb2e94bf922ba9
2019-04-20 00:58:17 +01:00
Timo Tijhof
9d225ee603 FauxRequest: Remove influence from $wgRequest on getFullRequestURL()
It inherited the method from WebRequest, which in turn uses
PROTO_CURRENT, which indirectly makes it then look up $wgRequest->protocol
to decide how to expand the url.

This global state isn't expected from FauxRequest and makes its
result less than predictable.

Change-Id: Ia616e0bfa00c35f78d27db55f26b336a7d0c7606
2019-04-20 00:57:49 +01:00
Roan Kattouw
5ce1e2b743 Linker: Use parentheses by default in userToolLinksRedContribs()
This function had been changed to unconditionally disable parentheses,
but none of its callers load the CSS needed to make that work.

Bug: T220767
Change-Id: I566d65e155258d3bd1a1a06bca9aa2b3a2d417ee
Follows-Up: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
2019-04-19 15:09:36 -07:00
jenkins-bot
fdb67e1d40 Merge "resourceloader: Omit non-existent messages in MessageBlobStore" 2019-04-19 00:47:45 +00:00
Timo Tijhof
429c5acbfd resourceloader: Omit non-existent messages in MessageBlobStore
Previously, it was exporting the result of $msg->plain() regardless
of $msg->exists(). This meant that, client-side, via mw.message
the message would always make mw.Message#exists return true, even
if in fact it did not exist.

Bug: T221294
Change-Id: I77122777ddaaa2d43f8385df9292540a8d21b328
2019-04-19 00:28:17 +00:00
jenkins-bot
c9bcca9a48 Merge "Refactor edit stashing into a PageEditStash service" 2019-04-17 22:14:02 +00:00
Aaron Schulz
2859306684 Refactor edit stashing into a PageEditStash service
Additional code cleanup:
* Call setCacheTime() in parseAndStash instead of relying
  on the one in DerivedPageDataUpdater.
* Improve the SPI logging by adding more extra fields.
* Treat requests in CLI/job mode (aside from tests) like
  those from bots with regard to checking the stash.
  This should avoid stats/logging pollution.

Change-Id: I8c6be919e399378e401a60502add0ecec7764d2d
2019-04-17 12:53:03 -07:00
Timo Tijhof
a259a2ed0d resourceloader: Move remaining module registrations to ServiceWiring
Also restore the order of registrations as it was before
last week with 47422fabe2. (That is, core modules are registered
before extension modules, in case of conflicts with a warning, the
core one wins).

Bug: T32956
Change-Id: I3a50508178159dfc8e5db1e218a5e6d10e2d4b2a
2019-04-17 19:01:29 +00:00
jenkins-bot
da89b88536 Merge "Add ability to override mb_strtoupper in Language::ucfirst" 2019-04-17 16:44:47 +00:00
Giuseppe Lavagetto
d46835ef4f Add ability to override mb_strtoupper in Language::ucfirst
Different PHP versions treat unicode differently, and specifically some
wiki resources become unreachable if mb_strtoupper's behavior has changed.
This patch allows to introduce an override table that allows to smooth
the transition period.

It also provides maintenance scripts to generate such an override table.

Bug: T219279
Change-Id: I0503ff4207fded4648c58c7b50e67c55422a4849
2019-04-17 15:18:44 +00:00
Aryeh Gregor
e6df285854 Remove all $wgParser use from core
Bug: T160811

Change-Id: I0556c04d33386d0339e02e2bf7a1ee74d97c2abd
2019-04-17 15:16:50 +03:00
Bill Pirkle
b92e5101c5 Remove usages of 'text' flag in revision-related getQueryInfo() calls
Field rev_text_id will no longer be populated once the legacy
schema is disabled, so joins against it will not work.
Remove all usages of the 'text' flag in calls to both
Revision::getQueryInfo() and RevisionStore::getQueryInfo()
so that these joins are no longer attempted.

Bug: T198342
Change-Id: I9be6a544c6f68555d4ea856f949f0040d05eac0f
2019-04-16 15:23:14 -05:00
jenkins-bot
9ec91e66ea Merge "Allow fragment-only TitleValues" 2019-04-15 22:15:06 +00:00
jenkins-bot
ba2e623917 Merge "Normalize input to TitleParser::parseTitle()" 2019-04-15 22:14:59 +00:00
jenkins-bot
1139a444ee Merge "New Title::castFromLinkTarget/TitleValue" 2019-04-15 22:13:38 +00:00
jenkins-bot
f767f2a48d Merge "Update MediaWikiTitleCodec to use NamespaceInfo" 2019-04-15 21:40:16 +00:00
jenkins-bot
34d6ebf4f3 Merge "resourceloader: Use 'fallback' as default for ResourceLoaderTestCase" 2019-04-15 20:28:15 +00:00
jenkins-bot
4d75fbf357 Merge "Set global config for test to avoid failure" 2019-04-15 20:17:30 +00:00
Timo Tijhof
b54a1e709e resourceloader: Use 'fallback' as default for ResourceLoaderTestCase
Follows-up fa05976f5f. This broke the Travis CI tests because
the Vector skin is not installed there (unlike in Wikimedia CI).

Make the test no longer reliant on that detail.

* Fix ResourceLoaderTestCase to use a default that actually
  works in plain core (previously 'vector' would be rejected
  as being an unknown skin, but then be re-normalised back to
  'vector' thanks to wgDefaultSkin. This was fixed in fa05976f5f,
  and the unknown skin now produces 'fallback' which is better.

* Update ResourceLoaderOOUIImageModuleTest to match this
  new default and also fix the test message while at it
  to mention 'skin', not 'image'.

Change-Id: I5fb69a6a38a42b1a5f325c0134e01ad880f65087
2019-04-15 20:21:00 +01:00
Timo Tijhof
fa05976f5f resourceloader: Remove needless MW-specific fallback
This is never used by the mw.loader client code. For any
manually crafted requests or fringe usage where the load.php
might be used to fetch some raw JS code that doesn't vary by
language or skin, proceed with qqx/fallback.

In the future load.php might deny these requests and then we
could make this a constructor parameter to ResourceLoaderContext.

Bug: T32956
Change-Id: I4e4ee758cd22278cea9592d4745b4f7fc00e0add
2019-04-15 17:46:41 +00:00
jenkins-bot
de374ac282 Merge "JsonContent: Add missing prefix to selector" 2019-04-15 15:25:52 +00:00
Aryeh Gregor
34582db81c Allow fragment-only TitleValues
This matches behavior of Title, and is meaningful for creating links.
However, in other contexts such a TitleValue doesn't make sense, so
perhaps we want to write special cases in linking code instead.

Change-Id: I812ad9090463766f38ef677de318c006912b4cca
2019-04-15 17:15:01 +03:00
Aryeh Gregor
29bfd8b39b Normalize input to TitleParser::parseTitle()
This matches behavior of Title::newFromText(), which assists porting old
code to TitleParser.

Change-Id: I50e9af09df843ea575250e276c7cfce660c00efd
2019-04-15 17:08:59 +03:00
Aryeh Gregor
37fcedbb3f New Title::castFromLinkTarget/TitleValue
These behave the same as newFromLinkTarget/TitleValue, but accept null
as well (and then just return null). This makes things much easier when
converting code from using Title to LinkTarget, because you can wrap in
castFromLinkTarget without adding null checks.

Change-Id: Id61f91d40b81ad226532917c43e51f0b69af712c
2019-04-15 16:56:47 +03:00
Ed Sanders
3535a5f327 JsonContent: Add missing prefix to selector
Change-Id: I977f6c565b93949a310d1207411f893cf83af996
2019-04-15 02:49:47 +00:00
Thalia
2f426f06f1 Set global config for test to avoid failure
Change-Id: I4f883b0ecec5378e29625a8940a0c247967f3e71
2019-04-14 14:31:23 +01:00
Aryeh Gregor
69ef837f41 Update MediaWikiTitleCodec to use NamespaceInfo
Depends-On: I759cde50e42020699138d32431c27428737f700f
Change-Id: I57d77754288449ec54b039802adae05d56fa5563
2019-04-14 14:55:58 +03:00
jenkins-bot
65dc405007 Merge "title: Allow passing MessageLocalizer to newMainPage()" 2019-04-14 02:52:22 +00:00
Timo Tijhof
821505367e title: Allow passing MessageLocalizer to newMainPage()
The method could not be used in session-less endpoints. This was
worked around once in the Startup module.

I plan to use this method in an extension module as well,
and would prefer not to duplicate core's logic for determining
the main page, outside this repository.

As general dependency-injection pattern, it seems desirable
to allow injecting a MessageLocalizer here.

Change-Id: I76cd02b2f489882e9404b93270f76aad9f0a4d9d
2019-04-14 03:26:17 +01:00
Aaron Schulz
fdbb64f354 Avoid extra parse/save delay for users with non-canonical parser options
If {{REVISIONID}} results in a re-parse, that re-parse will be post-send
unless the user has canonical parser options and will need the output for
page views anyway (e.g. the refresh after editing).

Also make getPreparedEdit() allow lazy-loading of the parser output via
a callback. A magic __get() method handles objects created the new way
but accessed by other code the old way.

Bug: T216306
Change-Id: I2012437c45dd605a6c0868dea47cf43dc67061d8
2019-04-14 02:00:16 +00:00
Reedy
571a44a4be Replace PreferencesFormLegacy usages with PreferencesFormOOUI
Change-Id: I4fc2a609ebb0f93b0767dddc343c3ff93ca8a39c
2019-04-14 00:51:05 +00:00
MGChecker
5e2c7466ad registration: Allow to require environment abilities
This patch adds the possibility for extensions and skins to require
certain environment abiltites that are not necessarily PHP extensions.

For now, the only ability introduced is the ability to shell out, but
the processing and testing is written in a more general way to allow
users to add more abilties later on by just changing getAbilities().

In theory, this allows using VersionChecker to check for random
abilities if they are specified in the constructor, as it is comletely
environment agnostic and not really bound to just be used for checking
extension compatibility.

Furthermore, it is possible to specify custom error messages for each of
these abilities in the constructor. Other parts of MediaWiki may use
these features to check for requirements while working with totally
different abilities.

Bug: T212472
Change-Id: Iff8512530b08ef509e7ac0b6ed8fe9578ef3e2a1
2019-04-13 08:14:44 -07:00
Aryeh Gregor
7b4489e019 Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints.  This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases).  As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User.  If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args().  Some of the changes are definitely safe, like
functions and test classes.

In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:

* Forwarding all arguments to another function. It's useful to keep
  func_get_args() here where we want to keep the list of expected
  arguments and their meanings in the function signature line for
  documentation purposes, but don't want to copy-paste a long line of
  argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
  arguments individually but want to use them as an array as well for
  some reason.

Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2019-04-12 20:17:01 +00:00
Reedy
3ecbd79ebe Add test to check action- messages exist
Bug: T220779
Change-Id: Ide681e1f03957a8024f538ea6cac4e4396fef23e
2019-04-12 17:44:33 +00:00
jenkins-bot
6497541c9c Merge "Fix order of @var parameter in PHP" 2019-04-12 15:17:23 +00:00
Fomafix
9cbb8f104d Use https://www.php.net/ instead of https://secure.php.net/
Change-Id: I0acca592c6909e91b28b904da49dcbd6a43cd2a5
2019-04-12 06:44:48 +02:00
jenkins-bot
1f20098a8d Merge "resourceloader: Move expandModuleNames() to ResourceLoader.php" 2019-04-11 22:31:25 +00:00
Timo Tijhof
f2bf73a4c4 resourceloader: Move expandModuleNames() to ResourceLoader.php
This has always been an odd case, as indicicated by the cross-class
comment references, and the fact that its test cases are already
in ResourceLoaderTest.php, for convenience, as that's also where
the creation of 'module name strings' is done and tested.

Actually move it there instead of pretending it is there.

Change-Id: Ied9569436cc78704a5c1b75eeebb73f8631350f6
2019-04-11 21:06:53 +00:00
Max Semenik
20865b4a6f Remove CryptRand and related stuff
Deprecated in 1.31 and not used anywhere.

Change-Id: Idc2e9cec907e39cacc391fdd7e2718bd880081ae
2019-04-11 18:20:09 +01:00
jenkins-bot
3af4b19908 Merge "tests: Mock the time in NameTableStoreTest to avoid failures if they run slowly" 2019-04-10 17:31:42 +00:00
Aaron Schulz
e4e7b650ef tests: Mock the time in NameTableStoreTest to avoid failures if they run slowly
Bug: T220626
Change-Id: I4f8e0321f540b9ff48f3297a1ca0c6196c99ecf8
2019-04-10 17:18:05 +00:00
jenkins-bot
b014d77a48 Merge "Drop clearCache() from (Configured)ReadOnlyMode" 2019-04-10 17:07:37 +00:00
Aryeh Gregor
9d5e3ad0f5 Drop clearCache() from (Configured)ReadOnlyMode
These are services, so tests should just override services to reset
them.

Change-Id: Icb1a041f8fac1ea0b7421e69b7b31b24171d868b
2019-04-10 19:39:34 +03:00
jenkins-bot
0d58c1ddda Merge "jobqueue: add GenericParameterJob and RunnableJob interface" 2019-04-10 16:07:09 +00:00
Tim Starling
421b4258b5 Sort MediaWikiServices and ServiceWiring alphabetically
Don't sort them asciibetically, which is a weird sort order people only
use by accident.

Change-Id: I69be64dab104130841855f2ce58bf94667c0c300
2019-04-10 20:59:49 +10:00
jenkins-bot
013b6fac88 Merge "NamespaceInfo service to replace MWNamespace" 2019-04-10 05:46:24 +00:00
Aryeh Gregor
76661cf129 NamespaceInfo service to replace MWNamespace
MWNamespace::clearCaches() has been removed entirely, along with the
$rebuild parameter to MWNamespace::getCanonicalNamespaces(). The rest of
MWNamespace is deprecated.

Diff best viewed with -C1 so git notices that NamespaceInfo is a copy of
MWNamespace.

Depends-On: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d
Depends-On: Ib3c914fc99394e4876ac9fe27317a1eafa2ff69e
Change-Id: I1a03d4e146f5414ae73c7d1a5807c873323e8abc
2019-04-10 02:07:36 +00:00
jenkins-bot
1f46e0e6dc Merge "Default $wgActorTableSchemaMigrationStage to READ_NEW" 2019-04-09 20:26:30 +00:00
Brad Jorsch
0301c8e03a Default $wgActorTableSchemaMigrationStage to READ_NEW
Probably good to start testing this in CI sometime soon.

The unit tests being changed here are:
* Hacky importing of a revision in MessageCacheTest, changed to use an
  interwiki username.
* WikiPageDbTestBase will get null rather than 0 for ar_user.
* DumpTestCase was using a custom IP $wgUser when creating its test
  revisions, which was winding up referring to an actor_id that had been
  deleted from the database. Fixed by having it use a registered user
  instead.

Also this has MediaWikiTestCase reset the $wgUser User object when the
actor table is truncated, as various tests were otherwise failing because
it was caching a later-deleted actor ID for User:127.0.0.1.

Bug: T188327
Change-Id: Ic483d0fda931810ac639b9de1cc5e5a4ef8161cc
Depends-On: I1bd0288cc132627d75b4001219522ec5e952eda7
2019-04-09 13:50:41 -04:00
jenkins-bot
3f134f0834 Merge "MediaWikiTestCase: Fix schema restoration" 2019-04-09 15:17:45 +00:00