Commit graph

5561 commits

Author SHA1 Message Date
jenkins-bot
aff39bd7c9 Merge "Enforce partial blocks" 2018-10-24 03:15:39 +00:00
jenkins-bot
728d6e918c Merge "Add partial block details to block-log entries." 2018-10-24 01:45:25 +00:00
jenkins-bot
8da9405898 Merge "Update Special:Block to set Partial Blocks" 2018-10-24 01:45:18 +00:00
jenkins-bot
8f338c0e29 Merge "Add block restriction classes" 2018-10-24 01:28:36 +00:00
Dayllan Maza
d67121f6d3 Enforce partial blocks
Enforce partial blocks and display a slightly different block
notice depending on if the block is sitewide or not

Bug: T197117
Depends-On: I675316dddf272fd0d6172ecad3882160752bf780
Change-Id: I8a3635a4a04a33912eb139b7b13c4bd874183d31
2018-10-24 00:57:48 +00:00
Dayllan Maza
f24991c6ed Add partial block details to block-log entries.
Block information needs to be more detailed if a block is not
sitewide. With this change, page restrictions will be visible
as part of the block information in Special:Contributions,
Special:Block, and Special:Log and via API

Bug: T197108
Change-Id: I5d2ef606f709bdd60bf52e2a048890b0f6360fca
2018-10-24 00:47:27 +00:00
David Barratt
0813c46daa Update Special:Block to set Partial Blocks
Make the necessary UI changes to Special:Block in order to set/update
partial blocks.

Bug: T197109
Change-Id: Ib3067824b5dcbdd893ab1f165d169a35d0716cb2
2018-10-24 00:47:08 +00:00
Dayllan Maza
a562611e5b Add block restriction classes
Partial blocks logic will be used in multiple places. This
classes will group block restriction functionality to avoid
code duplication

Bug: T202036
Change-Id: I675316dddf272fd0d6172ecad3882160752bf780
2018-10-23 17:41:50 -07:00
Gergő Tisza
cfb62c605f Hard-deprecate LegacyHookPreAuthenticationProvider class
The hooks that used to be called by this class will be removed in
I24d6fa963. The only reason to keep this class around is that
someone might have added it to $wgAuthManagerConfig so removing
it would trigger class lookup failures, so make sure any use
of the class triggers a deprecation warning.

Change-Id: I9755288eda7461ecf3dcd35de2081fbb3eb04ae3
2018-10-22 12:14:19 -07:00
jenkins-bot
72e5b5af65 Merge "Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()" 2018-10-22 01:49:58 +00:00
Bartosz Dziewoński
5f7002b907 During special page transclusion, save and restore context's WikiPage too
Setting the Title by calling setTitle clears the WikiPage, and the
next time getWikiPage() is called, it will be lazy-initialized to a
different instance of WikiPage.

This is mostly okay (the behavior has been like this for years and no
one noticed any problems), but it turns out that some extensions
(ConfirmEdit) use custom properties on the WikiPage object to pass
data between different hooks, which are lost when it's re-initialized.

Bug: T207065
Change-Id: I2881895f337bcfb1f86d5fc5a994fa9b0dcc768a
2018-10-19 22:19:52 +02:00
jenkins-bot
c44bba66c9 Merge "Watchlist: Commit after each batch watchlist insertion and removal" 2018-10-19 15:23:20 +00:00
Kosta Harlan
05b490bc4a Watchlist: Commit after each batch watchlist insertion and removal
With this change, adding large numbers (500+) of items to one's Watchlist via
Special:EditWatchlist/raw will no longer trigger DBPerformance warnings
for "max affected rows expectation not met". The same code mechanism is added
for bulk removal of watchlist items.

Bug: T171898
Depends-On: Ia0f496b8bfb2b68217d0f45f892045538494bfdc
Change-Id: I832b1843d1341b05227cdee2549bdcefa21eb300
2018-10-18 14:33:50 -04:00
jenkins-bot
837b96248d Merge "Revert "Introduce Special:RedirectExternal"" 2018-10-18 17:05:10 +00:00
Kosta Harlan
7e81d6f49e Revert "Introduce Special:RedirectExternal"
This reverts commit b83cf88837.

Reason for revert: Security concerns, needs some more nuance.

Change-Id: I5823c3da77accca9839f9632611315223e05351b
2018-10-18 16:18:20 +00:00
Max Semenik
ff2804804f Hard deprecate functionality replaced with random_bytes()
Deprecated in 1.32, no callers.

Change-Id: Id2d59c303fd60fab2b323af6cab137fdf74b5377
2018-10-17 19:57:52 -07:00
Brad Jorsch
c5a5b02240 Database: Allow selectFieldValues() to accept SQL fragments
The documentation says "This must be a valid SQL fragment", but as
written it breaks if given anything other than a field name. It's easy
enough to fix by adding an alias to the internal select() call.

Bug: T201781
Change-Id: I76428af6d3aadc266254fdb24109a0ac2db3761f
2018-10-17 22:21:40 +00:00
jenkins-bot
c75059dacb Merge "Introduce Special:RedirectExternal" 2018-10-17 22:12:52 +00:00
Kosta Harlan
b83cf88837 Introduce Special:RedirectExternal
Special:RedirectExternal is an unlisted special page that accepts a URL as
the first argument, and redirects the user to that page.
Example: Special:RedirectExternal/https://mediawiki.org

At the moment, this is intended to be used by the GrowthExperiments project in
order to track outbound visits to certain external links. But it could be
extended in the future to provide parameters for showing a message to the user
before redirecting, or explicitly requiring a user to click on the link, which
could help improve security when users follow on-wiki links to off-wiki sites.

Bug: T207115
Change-Id: I822af14a84569aab22249e2f16a662a60e60f76a
2018-10-17 14:52:09 -07:00
jenkins-bot
c27ea8dbd1 Merge "Allow getRevisionText to function without the text table." 2018-10-17 15:16:06 +00:00
daniel
7d8a959543 Allow getRevisionText to function without the text table.
Without this patch, getRevisionText would fail silently (by
returning false) when the text table no longer gets joined,
due to the switch to the new MCR schema.

Bug: T205808
Change-Id: Iffc25c82a5d2b865c28070c76156d39d390cc675
2018-10-17 10:54:39 -04:00
C. Scott Ananian
c0ed262053 Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()
This change ensures that the output is tidy, and is necessary to support
future parsers which will not be able to produce untidy output.

Bug: T198214
Change-Id: I743f4185a03403f8d9b9db010ff1ee4e9342e062
2018-10-17 10:35:28 -04:00
C. Scott Ananian
d404b76510 Add OutputPage::wrapWikiTextAsInterface() to safely wrap wikitext
This patch introduces a new method,
OutputPage::wrapWikiTextAsInterface(), which wraps the result of
OutputPage::addWikiTextAsInterface() in a tidy and robust way that
won't break if the wrapped message contains double newlines, extra
</div>, or other nasties.

This replaces a common unsafe pattern:
  $output->addWikiText( '<div class="..."' .... '</div>' );

Bug: T205624
Change-Id: I1040c7cf0ec1f5c4bef7c06d4486f50d85f2dc0f
2018-10-16 23:39:43 -04:00
C. Scott Ananian
4b1db1190b Tidy Message::parseAsBlock() by enabling tidy in MessageCache
We are incrementally removing places where the parser is used with
tidy disabled, since future parsers will not support such operation.

Bug: T198214
Change-Id: I0f417f75a49dfea873e9a2f44d81796a48b9f428
2018-10-17 02:43:07 +00:00
jenkins-bot
a1bbdcb629 Merge "rdbms: re-add DB domain sanity checks to LoadBalancer" 2018-10-16 23:54:38 +00:00
Aaron Schulz
b06f020217 rdbms: re-add DB domain sanity checks to LoadBalancer
Also clean up empty schema handling in DatabaseDomain

This reverts commit f23ac02f4f.

Bug: T193565
Change-Id: I95fde5c069f180ca888a023fade25ec81b846d44
2018-10-16 23:35:05 +00:00
Aaron Schulz
4fc5ba8bf8 messagecache: check overridable message array in getMsgFromNamespace()
Follow up to a3d6c1411d.

This avoids extra queries for messages that have a software defined value.

Bug: T193271
Change-Id: I25aa0e27200a0b417721cf1fbd34a82095405b89
2018-10-16 20:39:38 +00:00
jenkins-bot
9bfe012bdb Merge "API: Allow prop=info intestactions to return reasons" 2018-10-16 19:37:22 +00:00
jenkins-bot
b05aa05841 Merge "Migrate some wfWikiId() callers to getLocalDomainID()" 2018-10-16 19:37:18 +00:00
Brad Jorsch
20d18cf3cb
API: Allow prop=info intestactions to return reasons
T194585 raises a use case for callers to be able to know why an action
is not allowed. We can make that possible easily enough. The default
remains to return only a boolean.

This also deprecates inprop=readable in favor of intestactions=read,
since they both just return `$title->userCan( 'read', $user )`.

(ApiQueryInfoTest added by David Barratt)

Bug: T194585
Change-Id: Ib880f0605880eac776d816ea04e0c7ab9cfbaab1
Co-Authored-By: David Barratt <dbarratt@wikimedia.org>
2018-10-16 12:37:40 -04:00
Brad Jorsch
6698b7ea1d Add session_write_close() calls to SessionManager tests
PHP 7.3 doesn't like it if session_id() is called when the session has
been started, so we need to be sure to close it first in a few tests.

Bug: T207112
Change-Id: Ief36c1bb7b5c9066f158b5bb0d6d785a7f7ddd3c
2018-10-16 10:22:33 -04:00
Aaron Schulz
ebbccf1845 Migrate some wfWikiId() callers to getLocalDomainID()
Change-Id: I33fe222b7ca66babd61610febaebcf52d3806a7d
2018-10-15 23:58:49 -07:00
Brad Jorsch
6ff65e57bb API: Remove long-deprecated methods (and one class)
* ApiBase::profileIn() (deprecated in 1.25)
* ApiBase::profileOut() (deprecated in 1.25)
* ApiBase::safeProfileOut() (deprecated in 1.25)
* ApiBase::profileDBIn() (deprecated in 1.25)
* ApiBase::profileDBOut() (deprecated in 1.25)
* ApiBase::dieUsage() (deprecated in 1.29)
* ApiBase::dieUsageMsg() (deprecated in 1.29)
* ApiBase::dieUsageMsgOrDebug() (deprecated in 1.29)
* ApiBase::getErrorFromStatus() (deprecated in 1.29)
* ApiBase::parseMsg() (deprecated in 1.29)
* ApiBase::setWarning() (deprecated in 1.29)
* ApiPageSet::getInvalidTitles() (deprecated in 1.26)
* ApiQueryLogEvents::addLogParams() (deprecated in 1.25)
* ApiUsageException::getCodeString() (deprecated in 1.29)
* ApiUsageException::getMessageArray() (deprecated in 1.29)
* UsageException (deprecated in 1.29)

Change-Id: Iabb2589a29cc3b46624d31358f3a6bf7b3ccbd57
2018-10-15 16:37:04 -04:00
jenkins-bot
69d27cc0b6 Merge "Output only to stderr in unit tests" 2018-10-13 06:29:17 +00:00
jenkins-bot
6928652735 Merge "SlotDiffRenderer: add utility method for parameter type checks" 2018-10-13 05:27:16 +00:00
jenkins-bot
bce87740d7 Merge "Pass LBFactory to WatchedItemStore" 2018-10-12 21:48:54 +00:00
jenkins-bot
95e140cb71 Merge "HtmlTest: Perform multilingual tests" 2018-10-12 18:59:28 +00:00
Erik Bernhardson
9f28aa0709 Render namespace lists in the user's language
Asking users to select from a list that is in a namespace
other than their user language can be quite difficult.
Transition a number of use cases. This was applied via a flag
to avoid unexpectedly changing extensions also utilizing
the namespace selector.

Pages updated:
* Special:Search
* Special:Watchlist
* Special:RecentChanges
* Special:Contributions
* Special:Import
* Special:WhatLinksHere

Bug: T174057
Change-Id: I3fdac72179a124849ef7ad1e0e54eb66396c3c6e
2018-10-12 11:27:20 -07:00
Erik Bernhardson
1c6e6a4c91 HtmlTest: Perform multilingual tests
The tests here were only testing when user and content language
are the same, but the way things are rendered when they differ
is perhaps more interesting as it allows ensuring the two are used
in the correct places.

Change-Id: I357f50b082882fee485a95323d3a0a7cadb9a63c
2018-10-12 11:24:17 -07:00
C. Scott Ananian
6258e5e55c Deprecate $wgUseKeyHeader and OutputPage::getKeyHeader()
The `Key` header was a draft IETF specification which expired without
becoming a standard.  It does not appear to be in active use anywhere.

Change-Id: I3924a1b5ff428b107573d2827c40e4af8adaaeb1
2018-10-12 13:29:06 -04:00
Umherirrender
98c37e1549 Pass LBFactory to WatchedItemStore
Instead of passing the LoadBalancer and than get the LBFactory from the
service,
store the LBFactory on creation

Bug: T206601
Change-Id: I4c0d3712da591b2c5ddf2a65855d2cc9142417d2
2018-10-12 12:25:28 +00:00
jenkins-bot
4ddc1da854 Merge "Make MergeableUpdate jobs avoid the sub-queue so they can always merge" 2018-10-12 01:13:29 +00:00
Aaron Schulz
f61868f13d Make MergeableUpdate jobs avoid the sub-queue so they can always merge
Change-Id: I5b100fae29b785ab4524d165dad2e8ee46406b0c
2018-10-12 00:36:39 +00:00
Aryeh Gregor
ff7c3c9f03 Increase OutputPage test coverage to >45%
Also stop returning a value from OutputPage::adaptCdnTTL().  There are
no users and the value doesn't seem very helpful: one would probably
expect it to return the new value of mCdnMaxage, but instead it
returns the new value of mCdnMaxageLimit. Better to have no return
value than one that's easily misunderstood (*and* which nobody uses).

Change-Id: Ia9dab86923b839334eab9f6fde17c4aed52130ec
2018-10-11 18:59:42 -04:00
jenkins-bot
d69b967481 Merge "MessageCache: replace should actually replace, not reload" 2018-10-11 20:56:33 +00:00
jenkins-bot
64ef09d6a8 Merge "Ensure LanguageCode::bcp47() returns a valid BCP 47 language code" 2018-10-11 20:46:35 +00:00
jenkins-bot
36e1c72d0a Merge "Drop wfRunHooks, deprecated since 1.25" 2018-10-11 19:41:18 +00:00
jenkins-bot
b53f299af2 Merge "Revert "Unwrap HTML loaded from parser cache"" 2018-10-11 18:11:55 +00:00
Brad Jorsch
08e9eb1fef MessageCache: replace should actually replace, not reload
Prior to I462554b30, MessageCache::replace() did just that: it took the
existing cache and updated the one entry.

In I462554b30, the rearrangement of work into a DeferredUpdate
introduced a bug: the in-process cache was updated, but when the shared
cache was loaded later the entry was never updated in there so the
shared caches kept the old value. This was found in code review and
worked around by reloading all the messages from the database instead of
updating the existing cache.

But all that extra work reloading everything from the database causes
major slowness saving any MediaWiki-namespace page when the wiki has
many such small pages. Let's go back and fix the bug so replace() can
again replace instead of reloading everything.

Bug: T203925
Change-Id: Ife8e1bd6f143f480eb8da09b817c85aadf33a923
2018-10-11 11:20:51 -04:00
jenkins-bot
b52123f4ab Merge "Drop ChangesListSpecialPageFilters, deprecated in 1.29 and uncalled" 2018-10-11 07:36:20 +00:00
C. Scott Ananian
21ead7a98d Ensure LanguageCode::bcp47() returns a valid BCP 47 language code
MediaWiki uses a number of nonstandard codes which do not validate
according to the IANA language subtag registry.  Some of them have
the wrong semantics entirely: MediaWiki's `sr-ec` variant maps to
BCP 47 `sr-EC` which is "Serbian as used in Ethiopia" (!).

Extend LanguageCode::bcp47() to map our nonstandard codes to valid
BCP 47 language codes.  Export the mapping so that it can be used
in JavaScript's corresponding mw.language.bcp47() implementation
as well, and return the standard BCP 47 codes in the siteinfo
API.

Thanks to TheDJ (I10b4473c7e53f027812bbccf26bb47aec15fddfd) and
Fomafix (I93efc190714ba76247d30ba49fc21ae872fc3555) for previous
attempts at this!

Also removed a fixme for the name of 'Twi', dating back to 2004
(f59c3be23b) -- checking
tw.wikipedia.org it certainly appears that the autonym of 'Twi'
is correctly 'Twi'.

Tracking bugs for invalid language codes are T125073 and T145535.
Discussion of zh-XX => zh-HanX-XX mapping is at T198419.

This is a replay of an earlier merged patch,
8380f0173e, which had to be reverted
because it caused regressions in the Babel extension (T199941).

Bug: T34483
Bug: T106367
Bug: T120847
Depends-On: I27a5b8e45b34c6b57c1b612b11548001c88cd483
Change-Id: Iebbc604af21d7f2af9c1f1ab2574cb5f309bf6ed
2018-10-11 01:53:54 -04:00
jenkins-bot
079a0c4caa Merge "WikiPage: Fix viewing of wiki redirects to NS_MEDIA" 2018-10-11 01:54:19 +00:00
Alex Ezell
d4a45f9ea8 WikiPage: Fix viewing of wiki redirects to NS_MEDIA
If a user creates a redirect to a Media namespace title, a fatal
error is thrown on viewing such rediect because we protect against
redirecting to virtual namespaces. This fix catches this kind of
redirect and modifies the namespace to be File before the Title object
is created.

Follow-up from 613e2699.

Bug: T203942
Change-Id: Ib211d98498f635862fea6bf3e7395f4f8718b3d8
2018-10-11 01:29:47 +00:00
Brad Jorsch
993baa3493 ActorMigration: Remove possibility of read-both
When this was originally written, the plan was to read both the old and
new fields during the transition period, while stopping writes to them
midway through. It turns out that the WHERE conditions to do read-both
correctly are generally not handled well by the database and working
around that would require a lot of complicated code (see what's being
removed from ApiQueryUserContribs here, for example).

We can simplify things greatly by instead having it write both fields
during the transition period, reading from the old for the first part
and the new for the second part, as is being done for MCR.

Bug: T204669
Change-Id: I4764c1c7883dc1003cb12729455c8107319f70b1
Depends-On: I845f6ae462f2539ebd35cbb5f2ca8b5714e2c1fb
Depends-On: I88b31b977543fdbdf69f8c1158e77e448df94e11
2018-10-11 12:12:00 +11:00
jenkins-bot
57e631b78c Merge "Fix TitlePermissionTest failures due to test leakage" 2018-10-10 23:36:02 +00:00
jenkins-bot
591b0ba887 Merge "rdbms: Database::selectDB() update the domain and handle failure better" 2018-10-10 23:20:49 +00:00
Aaron Schulz
e8f41f6847 Fix TitlePermissionTest failures due to test leakage
Bug: T201776
Change-Id: I46d44c031ec45ac0be4c372891d2992c1e4f35ab
2018-10-10 23:17:13 +00:00
James D. Forrester
17e5334fc9 Drop wfRunHooks, deprecated since 1.25
Change-Id: I0350fba3f1a4a4ff500af746609bc9c6b46f0bdf
2018-10-10 15:30:00 -07:00
James D. Forrester
24ca95aad9 Drop ChangesListSpecialPageFilters, deprecated in 1.29 and uncalled
Change-Id: I03a9bce0d1085dc30dbc5c3408b4cea154ade19a
2018-10-10 15:30:00 -07:00
Aaron Schulz
fe0af6cad5 rdbms: Database::selectDB() update the domain and handle failure better
LoadBalancer uses Database::getDomainId() for deciding which keys to use
in the foreign connection handle arrays. This method should reflect any
changes made to the DB selection.

If the query fails, then do not change domain field. This is the sort of
approach that LoadBalancer is expects in openForeignConnection(). Also,
throw an exception when selectDB() fails.

The db/schema/prefix fields of Database no longer exist in favor of just
using the newer currentDomain field.

Also:
* Add IDatabase::selectDomain() method and made selectDB() wrap it.
* Extract the DB name from sqlite files if not explicitly provided.
* Fix inconsistent open() return values from Database subclasses.
* Make a relationSchemaQualifier() method to handle the concern of
  omitting schema names in queries. The means that getDomainId() can
  still return the right value, rather than confusingly omitt the schema.
* Make RevisionStore::checkDatabaseWikiId() account for the domain schema.
  Unlike d2a4d614fc, this does not incorrectly assume the storage is
  always for the current wiki domain. Also, LBFactorySingle sets the local
  domain so it is defined even in install.php.
* Make RevisionStoreDbTestBase actually set the LoadBalancer local domain.
* Make RevisionTest::testLoadFromTitle() account for the domain schema.

Bug: T193565
Change-Id: I6e51cd54c6da78830b38906b8c46789c79498ab5
2018-10-10 12:03:30 -07:00
C. Scott Ananian
2837fe8556 Hard deprecate OutputPage::addWikiText*Tidy() methods
These have been replaced with OutputPage::addWikiTextAsContent().
There is only one apparent use outside core, in the ProofreadPage
extension.

Bug: T198214
Depends-On: I826e463c1623481c11156a55a5b7e1da0aa27b8b
Change-Id: I4b1a9429029bfbbf70b2d5da1b290319ecbbdf3a
2018-10-10 14:54:27 -04:00
C. Scott Ananian
f2b325002b Hard deprecate unused OutputPage::addWikiText* methods
Codesearch shows no users of `OutputPage::addWikiTextWithTitle()`,
and no users of `OutputPage::addWikiTextTitle()` (other than the
implicit uses by the other `OutputPage::addWikiText*()` methods).

These methods produce untidy output, which future parsers won't
support.

Bug: T198214
Change-Id: Id5ee3bdfa6c464e3a92af82af7bc7317ca9d07a9
2018-10-10 14:54:27 -04:00
C. Scott Ananian
7af52285f7 Deprecate and rename OutputPage::addWikiText* methods
Tidy will always be enabled with our future parsers, and it is fast
and pure PHP now with the Remex implementation, so deprecate all the
untidy variants of 'OutputPage::addWikiText*()' and add new methods
which tidy by default.  Clarify the content language/interface
language distinction while we're at it by adding 'AsInterface' to the
name of methods which use the "interface language" by default,
and renaming the 'addWikiText*Tidy' methods to
'addWikiTextAsContent'.

The 'OutputPage::addWikiTextTitle' method has been deprecated, but it
is still used internally as the implementation for the newly-added
methods.  It is expected that the shared implementation will move in
the future to a new private method.  Setting the `$tidy` parameter of
`OutputPage::addWikiTextTitle` to false is independently deprecated;
for backwards-compatibility with old MW releases you may wish to
continue to invoke OutputPage::addWikiTextTitle() but set $tidy=true;
this will result in the same tidied output that the newly added
methods would produce.

Bug: T198214
Change-Id: Ia58910164baaca608cea3b24333b7d13ed773339
2018-10-10 14:54:27 -04:00
jenkins-bot
9d1b8a59d1 Merge "ChangeTagsTest: Mark tables as "used" to avoid ID reuse" 2018-10-10 17:37:17 +00:00
jenkins-bot
8318677eee Merge "Use non-deprecated login in ApiLoginTest" 2018-10-10 15:49:04 +00:00
jenkins-bot
cc814cae88 Merge "Improve ApiLogin test coverage" 2018-10-10 15:48:59 +00:00
Aryeh Gregor
de0143015a Use non-deprecated login in ApiLoginTest
Change-Id: I62c7bfce88aeda7ec1429493e733f868887976a9
2018-10-10 11:13:05 +03:00
Aryeh Gregor
1496fd4b4e Improve ApiLogin test coverage
Coverage is 100% except for one session-related bit that seems a bit
involved to test right now.  It looks like it will be easier once
SessionManager becomes a service.

I removed the third parameter from the return value of
canonicalizeLoginData, since af37a4c7 made it always return true.

I also removed three lines of dead code from ApiLogin.php.

Change-Id: Ia0073eddd27c82827518e0031e3c313f83cfd7cc
2018-10-10 11:11:43 +03:00
jenkins-bot
08911f6674 Merge "Hard-deprecate authentication-related hooks deprecated by AuthManager" 2018-10-10 05:54:03 +00:00
jenkins-bot
cf6fb41666 Merge "Re-namespace RevisionStore and RevisionRecord classes" 2018-10-10 05:16:45 +00:00
Kosta Harlan
5685904a11 Tests: Simplify badaccess group check for patrol action
The important part of the assertion is badaccess-groups, so we can drop the
other components and simplify the test code, plus also work around database
name issues that caused Travis CI to fail.

Bug: T206130
Change-Id: I137be892a611cd1f2d61baa77ad9528659587adf
2018-10-10 03:59:53 +00:00
Gergő Tisza
efa7a92e7c
Hard-deprecate authentication-related hooks deprecated by AuthManager
Hard-deprecates AbortAutoAccount, AbortNewAccount, AbortLogin,
LoginUserMigrated, UserCreateForm, and UserLoginForm.

Change-Id: Ibb267def9c295997ef71d820ff482e1e6a816873
2018-10-09 18:13:21 -07:00
Brad Jorsch
9f60798508 ChangeTagsTest: Mark tables as "used" to avoid ID reuse
If ChangeTags::updateTags() isn't passed all three of $rc_id, $rev_id,
and $log_id, it attempts to look up proper values from the subset that
is passed.

Some of the tests in ChangeTagsTest blindly use certain IDs, expecting
them to either not exist in the relevant tables or at least to be sane
(e.g. the same log_id isn't used on multiple rc_id rows). Depending on
the exact behavior of previous tests, this expectation may not hold.

The simple fix is to just mark the relevant tables as "used" by
ChangeTagsTest so MediaWikiTestCase will truncate them.

Change-Id: Ie60092b8a6e50f6f8a5cfdaaf4cac8ddb4fc6f53
2018-10-09 15:52:05 -04:00
jenkins-bot
5ab9496031 Merge "Clean up ApiLoginTest" 2018-10-09 19:17:20 +00:00
Gergő Tisza
617dbc4c18 Revert "Unwrap HTML loaded from parser cache"
This reverts commit 1bb5b58eb1.
A month has passed, the workaround for old parser cache entries
should not be needed anymore.

Bug: T203716
Change-Id: I446b47cc6b4c43aaae33675d62086d842b04ddcb
2018-10-09 18:29:20 +00:00
Aryeh Gregor
8435e0907b Clean up ApiLoginTest
Change-Id: Icd77f8a5ee0c26cfbd3cc8f220412cfa1bf49d60
2018-10-09 20:04:58 +03:00
Brad Jorsch
dff469a408 Re-namespace RevisionStore and RevisionRecord classes
During development a lot of classes were placed in MediaWiki\Storage\.
The precedent set would mean that every class relating to something
stored in a database table, plus all related value classes and such,
would go into that namespace.

Let's put them into MediaWiki\Revision\ instead. Then future classes
related to the 'page' table can go into MediaWiki\Page\, future classes
related to the 'user' table can go into MediaWiki\User\, and so on.

Note I didn't move DerivedPageDataUpdater, PageUpdateException,
PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept
long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\
instead.

Bug: T204158
Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
2018-10-09 10:22:48 -04:00
jenkins-bot
dfd526b37e Merge "Make RefreshLinksJob MCR compliant." 2018-10-09 02:28:04 +00:00
jenkins-bot
bc8571cca2 Merge "Revert "Re-enable tests from TitlePermissionTest"" 2018-10-09 01:44:03 +00:00
Krinkle
ae4476c54d Revert "Re-enable tests from TitlePermissionTest"
It's still broken, and 4 days passed with broken Travis CI builds.
Re-reverting for now.

This reverts commit 589741b541.

Change-Id: I85a0b02d3f32303a90118e2705a7b2afc721cb57
2018-10-09 01:21:00 +00:00
jenkins-bot
5cc5250c26 Merge "Make SpecialPageTestBase always call parent::tearDown" 2018-10-08 19:17:39 +00:00
jenkins-bot
88ecea4991 Merge "Suppress "Headers already sent" in PHP 7.2 too" 2018-10-08 18:17:44 +00:00
Aryeh Gregor
383a925f68 Output only to stderr in unit tests
Otherwise, session tests don't work in PHP 7.2 because headers are
already sent: https://bugs.php.net/bug.php?id=75628

Bug: T206476
Change-Id: Ie88db4a61a56b756c6445d2579a2f30da22c3ee8
2018-10-08 21:04:12 +03:00
daniel
6248556b5e Make RefreshLinksJob MCR compliant.
So far, RefreshLinksJob re-generated the ParserOutput ba calling
Content::getParserOutput. This only works for the main slot. It
needs to instead get the parser output for all slots combiend,
by using RevisionRenderer and RenderedRevision.

Bug: T174035
Change-Id: I253dda26bfa5aefa15f8b1dcc59e69fc7e9d0cb7
2018-10-08 19:20:13 +02:00
Aryeh Gregor
1572f3b1b8 Suppress "Headers already sent" in PHP 7.2 too
The "h" is now capitalized, so we need to update the regex.

Change-Id: I1111e1228868ec66d930c7a3b0d7972e5c6356b9
2018-10-08 20:10:36 +03:00
Aryeh Gregor
0a5fc8dcc6 Make SpecialPageTestBase always call parent::tearDown
Change-Id: Ifc244d5117e7da4bf46cdf273eca9fc4ae5c3a42
2018-10-08 19:54:32 +03:00
jenkins-bot
862fb6e168 Merge "Improve ApiFormatJson test coverage" 2018-10-08 16:03:07 +00:00
Aryeh Gregor
edb52e7338 Improve ApiFormatJson test coverage
The only thing missing is tests for the rawfm paths, which I don't
understand well enough to test easily.

Change-Id: I08779391798b9d2d5eeb7e19ec4764059336069c
2018-10-08 13:42:20 +03:00
Aryeh Gregor
09eee138e1 Deprecate MediaWikiTestCase::stashMwGlobals
This method encourages directly editing configuration variables.  It's a
better idea to use setMwGlobals() (or other set wrappers) so that we can
be intelligent in the future, for instance resetting services after the
config change.  Plus, a lot of the callers come out cleaner this way
anyway.

Depends-On: I8a1e81acc5c42a8d7f30938a72cface0acea4a70
Depends-On: I4105dbcf9c5399fe7239478c460ec57c015a98d4
Depends-On: I1b220996acf2f66cf7b0f092b341584663df32f9
Depends-On: Ie2d1ea65c0cb334bbde1666d00781474b7ac4dab
Change-Id: I23d77398e401f4986b1d5bd1c9e11a8a40da16f8
2018-10-07 19:39:47 +03:00
Alex Ezell
613e269920 Replace Media namespace redirects with File namespace
If a user creates a redirect that goes to a [[Media:example.jpg]]
page, then an exception is thrown because NS_MEDIA is a virtual
namespace. This change catches this case and changes the namespace
to an NS_FILE namespace and the redirect works correctly. This
change only happens when we are dealing with a redirect so other
uses of the NS_MEDIA namespace shouldn't be affected.

Bug: T203942
Change-Id: Ia744059650e16510732a65d51b138b11cbd43eb4
2018-10-05 18:04:24 -04:00
Aryeh Gregor
376e702942 Test ApiUnblock
Full coverage (except for the examples/help URL).

Change-Id: I4c618506b5446680f06fa9b605d3babe7194de94
2018-10-05 00:23:01 +00:00
jenkins-bot
f340c7271c Merge "ParserOutput::getCacheTime should stay the same after the first call." 2018-10-04 16:58:00 +00:00
jenkins-bot
1dde3dadc0 Merge "Ensure OutputPageTest works when Translate extension is loaded" 2018-10-04 16:53:20 +00:00
jenkins-bot
6871d732a1 Merge "Use Remex for TextContentTest subclasses" 2018-10-04 16:38:46 +00:00
jenkins-bot
96361e8866 Merge "tests: Allow string to be passed to getTestUser() etc." 2018-10-04 15:54:57 +00:00
jenkins-bot
076f262023 Merge "Minor cleanup in ApiBlockTest" 2018-10-04 15:50:51 +00:00
jenkins-bot
a4120368bb Merge "Only use "*Test.php" for actual PHPUnit tests" 2018-10-04 15:43:12 +00:00
jenkins-bot
fdce3717a1 Merge "Re-enable tests from TitlePermissionTest" 2018-10-04 15:40:48 +00:00
jenkins-bot
ca725a12bc Merge "registration: Let extensions add PHP extension requirements" 2018-10-04 15:38:58 +00:00
Aryeh Gregor
b93b18d98a tests: Allow string to be passed to getTestUser() etc.
If there's only one group, let's not require the brackets.

Change-Id: Ib46ef1facbbbf2ba01c13b8290ebbe3a8e08cb4f
2018-10-04 15:30:47 +00:00
Aryeh Gregor
c057200613 Minor cleanup in ApiBlockTest
Use tablesUsed instead of cleaning up ourselves.

Change-Id: Ibe470a8f292d65ceeaa098d5c033b8585501a9f3
2018-10-04 15:55:55 +03:00
daniel
414215ccac ParserOutput::getCacheTime should stay the same after the first call.
Previously, getCacheTime would default to the current time, potentially
causing the return value to change over subsequent calls. With this change,
the value is determined on the first call, and then remembered for subsequent
calls.

Bug: T205464
Change-Id: If240161c71d523ad5b0d33b9378950e0bebceb6e
2018-10-04 13:08:56 +02:00
Timo Tijhof
1d0e26cf83 UIDGenerator: Misc clean up
Various miscellaneous clean ups with no change to any of the
logical code. This to make the next commit have a cleaner diff
for easier review.

* Make internal millitime() non-static.

* Improve documentation and add missing @covers annotations.

* Correct getTimestampedID88() documentation to state that
  only two values need to be passed, not three.
  This is significant because the Flow extension is actually
  using this method in a subclass and passes only two values.

Bug: T94522
Change-Id: I2a0c51bea58df4cc0c253c1c10de3ac383f04c8e
2018-10-04 12:44:17 +02:00
Fomafix
1472f02b36 Phabricator: Use Tddddd instead of Bug ddddd in comments
Change-Id: Ic9fe03cab270bd6be738af346164ad5d31a0d780
2018-10-04 09:15:02 +02:00
jenkins-bot
9eb3834b89 Merge "Drop 'SpecialRecentChangesQuery' & 'SpecialWatchlistQuery' hooks, deprecated in 1.23" 2018-10-03 23:32:36 +00:00
jenkins-bot
6866617c2c Merge "Database: close() should not commit transactions" 2018-10-03 23:25:22 +00:00
Kosta Harlan
0a7c0a6797 Move test assertion to mirror parameter order
Follow up from I2df0551c5837adc578b27082ab6ba2ac95d937f8

Bug: T206130
Change-Id: Ib669c77fdb709846d0182cb28796cf53914114c4
2018-10-03 16:42:55 -04:00
jenkins-bot
12d9221ede Merge "SECURITY: Fix permissions check for patrol action" 2018-10-03 19:50:32 +00:00
Kosta Harlan
890ffc619d SECURITY: Fix permissions check for patrol action
Return existing errors instead of empty array in checkUserConfigPermissions().
Returning an empty array wiped out previously-found errors.

Also add test coverage for patrol action.

Bug: T206130
Change-Id: I2df0551c5837adc578b27082ab6ba2ac95d937f8
2018-10-03 12:07:46 -07:00
Brad Jorsch
bf30fcb714 Database: close() should not commit transactions
Transactional databases normally roll back when a connection is closed
with an open transaction rather than committing them, so MediaWiki
committing them is unexpected.

There are two cases being changed here: automatic transactions without
writes and manual transactions. For the former it shouldn't make a
difference if we commit or roll back since no writes were done anyway.
The latter has logged a message since MW 1.31 (I0992f9a8), and that
warning has not been logged in Wikimedia production in the past 60 days
so we should be ok there too.

Bug: T206147
Change-Id: Ieceef4deb49044db8f0622d38ee76c9d9f39704c
2018-10-03 14:55:43 -04:00
Aryeh Gregor
2bb3551082 Only use "*Test.php" for actual PHPUnit tests
Otherwise I get errors every time I try to run PHPUnit on includes/ or
includes/parser, because it tries to run ParserIntegrationTest.php and
fails.  Apparently the <exclude> in suite.xml doesn't work if PHPUnit is
invoked on a directory.

Bug: T201278
Change-Id: I7d09576bee2705d8516152e8fa671da8dac40233
2018-10-03 20:22:22 +03:00
Aryeh Gregor
589741b541 Re-enable tests from TitlePermissionTest
Let's see if they work now that services are reset between tests.

This reverts commit 7f843b0c04.

Bug: T201776
Change-Id: Iea7c74f8c77a97d83385b4399e500cf8129a1158
2018-10-03 15:38:45 +03:00
jenkins-bot
b3a4973cf8 Merge "Migrate image descriptions from image_comment_temp" 2018-10-03 01:23:54 +00:00
Aaron Schulz
7d2b121ac8 MessageCache: remove confusing and unused $isFullKey parameter from get()
Follows-up cba0fb1c15, which removed the last caller.

Change-Id: I00c17fedff39b1b35519cff2a0f8eac3e4d6f2ab
2018-10-02 23:34:53 +00:00
jenkins-bot
99dcd46f00 Merge "rdbms: make * consistently act like in select/insertSelect methods" 2018-10-02 16:44:54 +00:00
jenkins-bot
4e82bcaf9f Merge "Add audience parameter to PoolWorkArticleView" 2018-10-02 15:12:05 +00:00
Brad Jorsch
7a422138a7 Migrate image descriptions from image_comment_temp
image_comment_temp was always intended to be temporary, until an
expensive schema change on Wikimedia Commons's image table could be
done. Now that that has been done, stop writing image_comment_temp and
add a migration script to copy existing data into img_description_id.

Ic8efeddc will remove the reads from image_comment_temp and drop the
image_comment_temp table.

Bug: T188132
Change-Id: Iab5f521577a415b2dc213b517ee8a0dca4fdd0aa
2018-10-02 10:30:00 -04:00
Gergő Tisza
5174fa8364
Add audience parameter to PoolWorkArticleView
The old behavior was that the audience was RAW if the revision object
parameter got passed in, otherwise PUBLIC. This was undocumented and
not used outside core; this patch gets rid of it in favor of an
explicit argument.

Bug: T205578
Change-Id: Ic7cdb38f658f6d85c48ff13c7f84c64a45c9b1ee
2018-10-02 03:53:28 -07:00
James D. Forrester
144b643537 Drop 'SpecialRecentChangesQuery' & 'SpecialWatchlistQuery' hooks, deprecated in 1.23
Depends-On: I9822bb2bc1bcc13eec7924208bf3819d3512ad26
Change-Id: I67c06bb99d9c9582a638f061f523661c821bca8d
2018-10-01 18:15:38 -07:00
jenkins-bot
eee5e41280 Merge "ApiOptions: fix resetting some preferences to default" 2018-10-02 01:06:20 +00:00
jenkins-bot
d3ed3b8409 Merge "Remove temporary rcfilters variables" 2018-10-01 23:09:28 +00:00
Max Semenik
3ea7bba4d4 ApiOptions: fix resetting some preferences to default
For preferences like 'skin' that have a limited number of values, null
is not a valid value, thus attempts to reset them fail with
"Validation error for \"skin\": This value is required."

Bug: T65080

Change-Id: I86554a6d30c8ab970740d8682fb2261476de0677
2018-10-01 15:48:19 -07:00
Aaron Schulz
46cf714ce7 rdbms: make * consistently act like in select/insertSelect methods
This now matches the documentation of insertSelect()

Bug: T202553
Change-Id: Ie6602fdd3b48b9136de7c65289c85ced5f5f2f1d
2018-10-01 14:31:53 -07:00
jenkins-bot
67dc908246 Merge "Preserve whitespace in search index text content" 2018-10-01 18:22:48 +00:00
MGChecker
c7e45b6211 registration: Let extensions add PHP extension requirements
This change adds the possibility to specify ext-* keys under the 'platform'
key introduced in I6744cc0be2 to require given PHP extensions. Note that
it's impossible to add constraints different from '*', as there is no universal
way to retrieve PHP extension versions.

Bug: T197535
Change-Id: I510de1e6d80f5c1d92dc1d1665aaa6c25bf28bf7
2018-09-30 19:55:57 +02:00
Umherirrender
6fc9cf4f64 Fix caller name in DatabasePostgresTest
Seeing {closure} in the logs as caller is not helpful
Also add some missing caller name, which avoids Database::query as
caller in the logs
Change-Id: I3cab186cd63b295d1e4d1ca5232bc81925a85eb0
2018-09-30 17:38:22 +00:00
Kunal Mehta
68015d3b91 BitmapMetadataHandlerTest: Don't reinvent $this->checkPHPExtension()
Change-Id: I4957ca1be698844bafbf8de64af450cb884ec71a
2018-09-27 22:01:28 -07:00
C. Scott Ananian
91c81397cc Ensure OutputPageTest works when Translate extension is loaded
The translate extension registers the LanguageLinks hook which is run by
OutputPage::addParserOutputMetadata with a Title as an argument.  If
our mock doesn't provide a valid Title, then
PageTranslationHooks::addLanguageLinks() in Translate will throw a
TypeError in OutputPageTest::testParserOutputCategoryLinks().

Change-Id: I495c51731670f841e5ab752a3a1e014c86ef643d
2018-09-28 01:05:46 +00:00
C. Scott Ananian
f6081797f3 Add basic test cases for OutputPage::addWikiMsg / wrapWikiMsg
Change-Id: I621c22f2819b426ce6088ff3bdf1dadca274d1f9
2018-09-27 13:41:55 -04:00
Stephane Bisson
2e8512c7d0 Remove temporary rcfilters variables
wgStructuredChangeFiltersShowPreference, wgStructuredChangeFiltersShowWatchlistPreference,
and wgStructuredChangeFiltersOnWatchlist were introduced for progressive rollout
of the RCFilters app on RC and WL.

These variables and their related conditional code is no longer needed.

Bug: T196033
Change-Id: Id3799fefd21cd9bea0e089a5e12576ee9ea1085e
2018-09-27 13:39:05 -04:00
jenkins-bot
50f6b24ee6 Merge "Parser: Refactor parsing of [[File:...|link=...]] syntax for reusability" 2018-09-26 19:18:34 +00:00
jenkins-bot
2d75c56c17 Merge "Add constant for the name of the 'main' slot for MCR" 2018-09-26 11:55:10 +00:00
Bartosz Dziewoński
1c9664d18a Parser: Refactor parsing of [[File:...|link=...]] syntax for reusability
Change-Id: I91467297de4b7c532448a4c20b9a0dc8216c7200
2018-09-26 13:36:32 +02:00
jenkins-bot
361f73a912 Merge "Don't wrap output added by OutputPage::addWikiText*()" 2018-09-26 10:50:27 +00:00
jenkins-bot
0cc987680f Merge "OutputPageTest should be independent of $wgResourceLoaderDebug setting" 2018-09-25 19:36:07 +00:00
C. Scott Ananian
300b91a1ec Don't wrap output added by OutputPage::addWikiText*()
There are three methods affected: `OutputPage::addWikiTextTidy()`,
`OutputPage::addWikiTextTitleTidy()`, and
`OutputPage::addWikiTextWithTitle()`.

There's a special case in Parser.php which adds the wrapper class from
ParserOptions to the ParserOutput only if "interface mode" is off; the
affected methods default to adding output in "content language" mode
(not "interface language" mode), but they seem to be used for
"interface messages in the content language" (rare) and so should also
be unwrapped.  This would make all the `OutputPage::addWikiText*()`
methods consistent.

The `OutputPage::addWikiTextTidy()` method is only used once in the WMF
repositories, where it is used to insert an interface message in the
content language:

91cd2a928f/SpecialProofreadPages.php (40)

The `OutputPage::addWikiTextWithTitle()` method is used by no one:

https://codesearch.wmflabs.org/search/?q=addWikiTextWithTitle%5C(

The `OutputPage::addWikiTextTitleTidy()` method is used only in core:

3888c001a1/includes/EditPage.php (2669)

It seems clear that the output in this case is intended to be
unwrapped as well (the codepath adds its own explicit wrapper).

Ia58910164baaca608cea3b24333b7d13ed773339 will add additional
documentation to clarify the distinction between the different
OutputPage::addWikiText*() methods, but I felt it safer to make
this particular change first as a standalone patch, just in case
it had unexpected side effects or merited further discussion.

Change-Id: I3e5b598d358819191562b56d40ebf1cb6f3cda41
2018-09-25 14:43:20 -04:00
C. Scott Ananian
2cb60f4204 Use Remex for TextContentTest subclasses
We are deprecating untidy configurations of the parser.

Bug: T198214
Change-Id: I16529879a3b3aed960c5dc006e2af513d7e91fcd
2018-09-25 18:42:56 +00:00
jenkins-bot
3aad4bcdab Merge "Ensure disabled deprecation warnings are re-enabled before next test" 2018-09-25 17:13:14 +00:00
C. Scott Ananian
36f14abd26 OutputPageTest should be independent of $wgResourceLoaderDebug setting
`OutputPageTest::testMakeResourceLoaderLink()` and
`OutputPageTest::testBuildExemptModules()` tried to force
`$wgResourceLoaderDebug=false` before running the test, but they
neglected to clear the resource loader debug cache
(`ResourceLoader::clearCache()`) so the user's local setting of
`$wgResourceLoaderDebug` would be used despite it all.

Change-Id: I3e7dec762c8a02683fc66a630c950b72a4840a9b
2018-09-25 12:56:40 -04:00
jenkins-bot
9b1d351323 Merge "Deprecate the 'disabletidy' parameter for ApiParse" 2018-09-25 16:50:36 +00:00
C. Scott Ananian
8025629395 Ensure disabled deprecation warnings are re-enabled before next test
Tests should not interfere with each other; disabled deprecation
warnings should be disabled for a single test case only.

Bug: T191960
Change-Id: Ic9b892bc83ba6d71c1077df0d93c95dde36988bb
2018-09-25 16:30:38 +00:00
C. Scott Ananian
775bcac172 OutputPageTest: Don't rely on side effects of previous tests
Use the proper `MediaWikiTextCase::hideDeprecated()` method.

Bug: T191960
Change-Id: I974618a0bd1e11434d167820d119dcfd6e47b092
2018-09-25 10:22:52 -04:00
Gergő Tisza
ec72a9f495
SlotDiffRenderer: add utility method for parameter type checks
Change-Id: I0161070fd0330d4945cec2f76f4fd8128a9793b9
2018-09-24 23:09:18 -07:00
Gergő Tisza
6e8d39c6e7
Add constant for the name of the 'main' slot for MCR
Bug: T202142
Change-Id: I97a74e5a029b014f3c2195188936d5c8233c1b7f
2018-09-24 16:52:12 -07:00
C. Scott Ananian
eb351597e4 Deprecate the 'disabletidy' parameter for ApiParse
This will be unsupported by future wikitext parsers, which always
construct well-formed HTML.

Bug: T198214
Change-Id: Ic189cd1b38bca5b9ec0ef9810555fe0cbd8b733d
2018-09-24 17:40:51 -04:00
C. Scott Ananian
eb40f111d6 Suppress deprecation warnings for b/c use of UsageException::getMessageArray()
Follow up to efaaa2c1d6 (which was a
follow up to Iae0e2ce3).

These are exposed when T191960 is fixed.

Change-Id: I7c517b5a7cccfe9c324d0a9eeb7d774aa1be8adb
2018-09-24 17:18:00 -04:00
jenkins-bot
1ea48f3e29 Merge "resourceloader: Add filter cache version to module version hash" 2018-09-24 17:38:09 +00:00
jenkins-bot
1298becf10 Merge "resourceloader: Remove MW cacheEpoch from module version hash" 2018-09-24 17:35:22 +00:00
jenkins-bot
0245bce017 Merge "Code to read from change_tag_def table instead of valid_tag" 2018-09-24 17:19:48 +00:00
Roan Kattouw
1ed0a109ec resourceloader: Add filter cache version to module version hash
We already had a $filterCacheVersion variable, but it was
only used for the internal cache for JS and CSS minification,
which is not enough. If there is a breaking change in either
of these processes, we also need to invalidate version hashes.

This commit renames ResourceLoader::$filterCacheVersion to
ResourceLoader::CACHE_VERSION and takes it into account in
getVersionHash(). Adding it to getDefinitionSummary() is not
sufficient, because content-hashed modules also need to be
invalidated when there's a breaking change in the minifiers.

This cache version can also be incremented when there's a
breaking change in image embedding or LESS compilation,
although content hashing deals with that already, so we
could also add a separate cache version for those that's
only added to getDefinitionSummary().

Bug: T176884
Change-Id: Ife6efa71f310c90b9951afa02212b2cb6766e76d
2018-09-24 17:10:48 +00:00