Commit graph

7024 commits

Author SHA1 Message Date
daniel
49d20b5095 Add tests for HttpRequestFactoryTest.
This also moves several tests out of HttpTest, so they are not lost when
the deprecated Http class is removed.

Bug: T222935
Change-Id: Ib4aac96ba1a978e8b6738ed446663afc3cc8c792
2019-05-13 14:32:23 +02:00
jenkins-bot
ff3c76b87c Merge "Remove "Squiz.WhiteSpace.FunctionSpacing" from phpcs exclusions" 2019-05-11 19:06:42 +00:00
jenkins-bot
cb79b0207e Merge "Restore ApiQueryUserInfo::getBlockInfo() as a stub." 2019-05-11 09:42:28 +00:00
daniel
9f973228d5 Restore ApiQueryUserInfo::getBlockInfo() as a stub.
Fixes unintended breaking change made by I84ed21641c44b2f65ebe.
ApiQueryUserInfo::getBlockInfo() is restoed as a hard deprecated stub.

This renames the method in the new ApiBlockInfoTrait to
getBlockDetails.

Depends-On: I9f40666a31bd4af50762c197c2ce5bf089a5e68c
Change-Id: If47a93878f87d69800e5f305404c22528dac5e94
2019-05-11 07:33:25 +00:00
Reedy
9f2ffdfbd4 Remove "Squiz.WhiteSpace.FunctionSpacing" from phpcs exclusions
Change-Id: I78b3315f26ab91b6b443f5b028a635552f82f5a3
2019-05-11 02:44:26 +01:00
jenkins-bot
4435211205 Merge "user: Remove deprecated and unused method getPasswordValidity()" 2019-05-10 17:00:15 +00:00
jenkins-bot
9f5c319b09 Merge "Add 'avoidhours' option to Language#formatTimePeriod" 2019-05-10 16:59:58 +00:00
David Causse
888a8ec685 Properly output the name of the file in assertFileContains
Change-Id: If02d094049bd8ec21d5f180382ccc4bc6202f981
2019-05-10 16:02:34 +02:00
Jack Phoenix
b704c9f4de Add 'avoidhours' option to Language#formatTimePeriod
Example use case: in some skins we want to show how many *days* ago a page was edited, but we don't really care about the precise _hours_.
Thus we'll set [ 'avoid' => 'avoidhours' ] when calling Language#formatTimePeriod to output something like "Page last edited 60 days ago" instead of "Page last edited 60 days 9 hours ago".

Change-Id: I0a737aab14ccb2b8d4eccdc41e1eb9232eedcb8a
2019-05-10 11:06:00 +03:00
Derick Alangi
fffadf725e user: Remove deprecated and unused method getPasswordValidity()
This method was deprecated in 1.33 and no longer used. See usage;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbgetPasswordValidity%5Cb&i=nope&files=&repos=

Bug: T220656
Change-Id: I28829f33d40b5568bedb9678fc43beb146b72e56
2019-05-10 00:13:20 +01:00
Derick Alangi
5b2d38c750 MWMessagePack: Deprecate MWMessagePack class and its method
Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbMWMessagePack%5Cb&i=nope&files=&repos=

Bug: T220313
Change-Id: I3648f8c14116f924d835f68077f46333d892a038
2019-05-09 22:40:03 +01:00
Derick Alangi
e4f1fbddec page: Remove deprecated/unused methods in PageArchive class
This code is no longer used per usage (below) and was to be actually
removed in 1.33. Methods are;

getLastRevisionText(), listAllPages() and getTextFromRow(), see example
search of usage below.

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbgetTextFromRow%5Cb&i=nope&files=&repos=

Change-Id: I4b9675a9cf84442f08f125f4c23ec67d72b12c15
2019-05-09 12:23:58 -07:00
Derick Alangi
1981823755 Remove several methods, deprecated in 1.32
I've checked and doubled checked that these methods are no longer used
anywhere in core or extensions, hence removed them. They were hard deprecated
in MediaWiki 1.32.

* OutputPage:
  ** `::showFileCopyError()`
  ** `::showFileRenameError()`
  ** `::showFileDeleteError()`
  ** `::showFileNotFoundError()`

* ApiBase:
  ** `::truncateArray()`

* IcuCollation:
  ** `::getICUVersion()`

* HTMLForm:
  ** `::setSubmitProgressive()`

* ResourceLoaderStartUpModules:
  ** `::getStartupModules()`
  ** `::getLegacyModules()`

* BaseTemplate:
  ** `::msgHtml()`

* QuickTemplate:
  ** `::msgHtml()`

* WatchAction:
  ** `::getUnwatchToken()`

Bug: T220656
Change-Id: Ic1a723a991f4ff63fcb5f045ddcda18d1f8c3c68
2019-05-09 11:36:44 -07:00
jenkins-bot
34d2b3aa23 Merge "Simplify by using ?: operator" 2019-05-09 16:25:22 +00:00
jenkins-bot
3074a4521a Merge "Hard deprecate Password::equals()" 2019-05-09 02:09:42 +00:00
jenkins-bot
c4ab0efaae Merge "resourceloader: Remove redundant 'window' indirection" 2019-05-08 21:46:00 +00:00
jenkins-bot
993f0b285a Merge "resourceloader: Move per-page function calls to startup.js" 2019-05-08 21:40:19 +00: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
Timo Tijhof
cd45307ba1 resourceloader: Move per-page function calls to startup.js
Turn these embedded function calls into variable declarations,
later consumed by startup.js.

This has a few benefits:

* Variables can be declared immediately, without needing to
  defer it to after mw.loader arrives from startup, via an RLQ
  callback. This makes the inline script simpler and a tiny
  bit smaller.

* By moving the actual function calls to startup.js, they could
  easily be re-arranged in the future or migrated in other ways
  without needing to worry about HTML caching and keeping concurrent
  compatibility with both orders of execution.

Change-Id: I1c995a9572d9eb3201a565341c19bdf81ab00eff
2019-05-08 21:23:59 +00:00
jenkins-bot
9509a5a002 Merge "Fix Block::newLoad for IPv6 range blocks - follow-up to Ie8bebd8" 2019-05-08 19:34:29 +00:00
Thalia
5f8e8bc708 Fix Block::newLoad for IPv6 range blocks - follow-up to Ie8bebd8
Previously, the size of the range is calculated by finding the
difference between that start and end addresses, converted into
decimal. This fails when the numbers are too large.

Instead, use parsing methods from IP class to avoid having to
handle large numbers.

Bug: T222246
Change-Id: If466139c42c4ac832a9506c80bdb228e9da39638
2019-05-08 13:22:46 -05:00
jenkins-bot
9792a09c30 Merge "WebRequest: Change getFullRequestURL() to use local getProtocol()" 2019-05-08 18:20:33 +00:00
jenkins-bot
63772e162d Merge "FauxRequest: Remove influence from $wgRequest on getFullRequestURL()" 2019-05-08 18:20:15 +00:00
Thalia
824655f3b7 Separate Block into AbstractBlock, Block and SystemBlock
This commit splits the existing Block class into AbstractBlock, Block
and SystemBlock.

Before this patch, the Block class represents several types of
blocks, which can be separated into blocks stored in the database,
and temporary blocks created by the system. These are now
represented by Block and SystemBlock, which inherit from
AbstractBlock.

This lays the foundations for:
* enforcing block parameters from multiple blocks that apply to a
user/IP address
* improvements to the Block API, including the addition of services

Breaking changes: functions expecting a Block object should still
expect a Block object if it came from the database, but other
functions may now need to expect an AbstractBlock or SystemBlock
object. (Note that an alternative naming scheme, in which the
abstract class is called Block and the subclasses are DatabaseBlock
and SystemBlock, avoids this breakage. However, it introduces more
breakages to calls to static Block methods and new Block
instantiations.)

Changes to tests: system blocks don't set the $blockCreateAccount or
$mExipry block properties, so remove/change any tests that assume
they do.

Bug: T222737
Change-Id: I83bceb5e5049e254c90ace060f8f8fad44696c67
2019-05-07 17:36:31 -05:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
jenkins-bot
b00ce73122 Merge "Fix Block::newLoad for IPv6 range blocks" 2019-05-07 17:50:21 +00:00
Aryeh Gregor
82311f8c2c Update LinkRenderer to use NamespaceInfo
Change-Id: I4af843238ffd58925f57c0f7b98253a90cb285ec
2019-05-07 14:52:17 +02:00
jenkins-bot
7159f97a55 Merge "Log warning and show error on empty username" 2019-05-07 12:14:28 +00:00
jenkins-bot
9d8759327a Merge "Let User::idFromName always return int or null" 2019-05-07 11:58:31 +00:00
Aryeh Gregor
ddd1d4b920 Log warning and show error on empty username
Historically it seems that if Linker::userLink or friends were passed an
empty username (probably due to an incorrect database entry), they would
produce bogus output, e.g., an <a> with no contents or a link to the
invalid page "User_talk:" or similar.

In b6e1e99bec we replaced an occurrence of Title::makeTitle() (no
safety checks!) with creating a TitleValue, which asserts in its
constructor that the title text is not empty. This made such pages fail
an assertion and stop displaying at all.

Now there's a proper check for the error. Such cases will log a
production error and return "(no username available)".

Bug: T222529
Change-Id: Id65bdf9666b0d16e5553b8f38c7cf8fce2e37a25
2019-05-06 14:44:23 -05:00
jenkins-bot
5f3b124dfe Merge "Convert WatchedItem and friends to LinkTarget" 2019-05-06 19:33:44 +00:00
jenkins-bot
61d80fb2ca Merge "Move Title::getSubject/Talk/OtherPage to NamespaceInfo" 2019-05-06 19:33:37 +00:00
Timo Tijhof
4938038175 tests: Remove use of wfRandomString() for test fixtures
This reduces confidence in the test. There is no guruantee that
it won't return the same value twice during the duration of a full
PHPUnit run of all test suites, whether twice in a row or 20 minutes
apart.

For a test that needs a string of any kind, use an explicit, consinstent
and cheap literal value.

For a test that specifically needs some kind of uniqueness compared to
something else within the same test case, do so explicitly.

Tests that require something globally unique (for some undefined/vague
definition of "global") were not found, and should not exist anyway.

Also, in libs/objectcache tests, fix order of parameters in some
assertions (expected first, then actual), and use assertFalse/assertSame
instead of assertEqual for cases where false is expected to remove
tolerance of other loosely equal values.

Change-Id: Ifc60e88178da471330b94bfbf12e2731d2efc77d
2019-05-06 17:22:03 +00:00
Timo Tijhof
2bcd74d968 tests: Use standard utilities for temporary file names
Change-Id: Iff28c27990a81b02a92148a88256b9a25518f496
2019-05-06 17:21:45 +00:00
jenkins-bot
c3d8fa1fc3 Merge "Update LinkCache to use NamespaceInfo" 2019-05-06 16:48:20 +00:00
jenkins-bot
4a7555355a Merge "tests: Avoid namespace slashes in getNewTempFile() utility" 2019-05-06 16:22:32 +00:00
Aryeh Gregor
761e704d6e Convert WatchedItem and friends to LinkTarget
There is no longer any reference to Title in WatchedItem classes or
their unit tests except for one hook that keeps Title for compat. Happy
side effects include getting rid of $revisionGetTimestampFromIdCallback,
and a net reduction of 143 LOC.

Change-Id: Id998c6f336ed808f7259e4f8359bcf8d6c0210d6
2019-05-06 15:30:45 +00:00
Aryeh Gregor
e30cb5ba90 Move Title::getSubject/Talk/OtherPage to NamespaceInfo
This allows converting some more code to LinkTarget. 100% test coverage.

Change-Id: I28903af6a41d02755f37f31561a524547445821e
2019-05-06 08:29:28 -07:00
jenkins-bot
8d9d8c8bb3 Merge "Force user id and actor id to 0 when loading from remote wikis" 2019-05-06 15:19:38 +00:00
Bill Pirkle
d4b72572a6 Force user id and actor id to 0 when loading from remote wikis
Stop-gap solution for the problem described in T222212.
Force the User ID and Actor ID to zero for users loaded
from the database of another wiki, to prevent subtle data
corruption and confusing failure modes.

Bug: T222381
Change-Id: Ic585f972d61da136744d080df13d8eb1ecd04cf5
2019-05-06 09:08:51 -05:00
jenkins-bot
dfbcce91c2 Merge "Make RepoGroup a service instead of singleton" 2019-05-06 12:51:46 +00:00
jenkins-bot
123b2ff2fa Merge "100% test coverage for NamespaceInfo" 2019-05-06 12:32:17 +00:00
jenkins-bot
27ede06954 Merge "Move ApiQueryUserInfo::getBlockInfo() to ApiBase" 2019-05-06 12:29:40 +00:00
Aryeh Gregor
a220518f8f 100% test coverage for NamespaceInfo
In the new tests I added, I tried to cover all interesting scenarios and
not just hit each line to make the coverage green. But I didn't review
all the existing tests to see if they were properly thorough, so there
might still be room for improvement.

I uncovered a bug here that will be addressed in a separate commit,
because the fix is not so simple. For now I left the test expectation as
a @todo.

Change-Id: I33d556bf83c631a8a02a6c77f2f5cb06b8dbf869
2019-05-06 14:17:06 +03:00
Aryeh Gregor
e6691999f4 Make RepoGroup a service instead of singleton
Change-Id: Id1661bf992ee7b7a1822f52fdfefe8e045b9f280
2019-05-06 13:57:40 +03:00
jenkins-bot
7ada64684e Merge "Don't pass Config to NamespaceInfo" 2019-05-06 10:51:34 +00:00
jenkins-bot
a97bac4084 Merge "Update GenderCache to use NamespaceInfo" 2019-05-06 10:45:15 +00:00
jenkins-bot
2052711639 Merge "Deprecate the Http class" 2019-05-06 10:15:10 +00:00
Aryeh Gregor
6f2906e36a Update LinkCache to use NamespaceInfo
Change-Id: Ie9ebc2564861068dea8a64aea5cbeacb03597cea
2019-05-06 09:37:58 +00:00
Aryeh Gregor
3860a8d9b4 Update DefaultPreferencesFactory to use NamespaceInfo
Depends-On: I552264714de7227965f978f20f932f41cf96042e
Change-Id: I0568e7f4c7223208001f378a03fef395df8bff69
2019-05-06 12:19:13 +03:00