Commit graph

591 commits

Author SHA1 Message Date
Aaron Schulz
cb15755e92 Normalize use of "INNER JOIN" to "JOIN" in database queries
The ANSI SQL default join type is INNER and this might save
some line breaks here and there.

Change-Id: Ibd39976f46ca3f9b71190d3b60b76ca085787a00
2019-03-06 09:17:30 -08:00
jenkins-bot
309c7b316f Merge "resourceloader: Remove addModuleScripts, and deprecate getModuleScripts." 2019-03-05 18:54:38 +00:00
Timo Tijhof
c6f3440832 resourceloader: Remove addModuleScripts, and deprecate getModuleScripts.
The addModuleScripts() methods were deprecated in 1.31 and 1.32,
these are now removed.

The getModuleScripts() are now deprecated as well, always returning
an empty array. To be removed in 1.34.

Depends on commits for bundled/wmf-deployed extensions that
remove the last few remaining callers to the deprecated functions
in: 3D, Collection, Flow, GlobalUserPage, and Wikibase.

Bug: T188689
Depends-On: If9f0bc6aef85117587fa1929f34f8861c8d80314
Depends-On: Ia8d41b97fbf6822f5f8f7ac889408acce1ac9a3a
Depends-On: I503b919739ea474ff33726815b0da55e2f7e2724
Depends-On: I236ef637fd03b810a46eb361e25067a037e9d183
Depends-On: I62e17779753b977a452cc0c9694947941e999cc3
Change-Id: I5a19b8f164ccf666485d2971202194b747f882df
2019-03-05 16:54:08 +00:00
James D. Forrester
3f717984c1 Drop AuthPlugin and related code, deprecated in 1.27
Bug: T215843
Depends-On: Ie49709faa6f67b0a31bd546823d29dbfea0a70eb
Depends-On: If8109dbfdeeb88a6265f4cd79d1ae81bff48d934
Depends-On: I36b195fa2d6c23a76631ebaf869c787e44427d60
Depends-On: Iaa171b085fde331eab7d85c7de74523e27fc625a
Change-Id: I330b30d6582034a233fed204c0680b1ce84eec6e
2019-03-05 08:23:14 +00:00
Brad Jorsch
426df4cd70 API: Handle Messages in errorArrayToStatus()
Two bugs here:
* If the error array contains an entry using a Message object instead of
  a string as the key, it'll blow up trying to do
  `self::$blockMsgMap[$error[0]]`.
* If the error array contains a Message object not wrapped in an array,
  it'll blow up trying to do `...(array)$error`.

Bug: T217382
Change-Id: I2a08e02bca0fb194416b3f2e6a1d6192d5c13cb2
2019-03-01 09:53:01 -05:00
Brad Jorsch
c073e531cf API: Spread autoblocks from action=edit and action=move
The code in EditPage and SpecialMovepage does this primarily in web UI
code paths that aren't called by the API. EditPage also has a check in
the internal code path used by the API, but ApiEditPage runs its own
permissions check first and won't reach that code path.

Bug: T216245
Change-Id: I6263c8b60a24f3195dba583463f1ce4b004f82f5
2019-02-19 17:34:48 -05:00
Brad Jorsch
ace0338421 API: Add block info to more block errors
When using ApiBase::errorArrayToStatus(), block info was added to
'blocked' errors. But when using dieStatus() with a Status object
returned by core MediaWiki code, block info was not being added.

Change-Id: I14887b6dd76d665055283945b956b2e26c521ed5
Depends-On: Ie3addf53ab5fabf1c24e1033b58e63927f4e21bf
2019-02-19 17:34:48 -05:00
Bill Pirkle
d993f499ee Refactor calls to deprecated function Content::getNativeData()
Function Content::getNativeData() was deprecated.  Replace with
calls to new function TextContent::getText() in most places.

Bug: T155582
Change-Id: I2bd508c72aac4faf474ba45ab1f92e2e8d2eb9be
2019-02-15 17:48:01 +00:00
jenkins-bot
9eafd89011 Merge "Prevent fatal PHP errors when PageRestriction::getTitle() returns null." 2019-02-12 16:27:04 +00:00
Brad Jorsch
94110916b1 API: Don't return a deprecation warning for default values
If a deprecated parameter has a default value, or a deprecated value is
part of the default value for a parameter, don't give the client a
deprecation warning about it.

Bug: T215548
Change-Id: I980763e3d44fb1b7459c64b175fcaddf5fd44a13
2019-02-07 15:32:36 -05:00
David Barratt
6710e8c212
Prevent fatal PHP errors when PageRestriction::getTitle() returns null.
Update usages of PageRestriction::getTitle() to handle a null response.

Bug: T214763
Change-Id: Ied33e2c3c9442c47ae8084a97bb0921869fb9d49
2019-02-07 10:06:15 -05:00
Thalia
5e683829d6 Ensure calls to Title::getArticleID use the same case as the definition
Change-Id: Ic92f43c9e9df2782ba20aa28ad9e6d2ef7976d2e
2019-02-06 22:15:05 +00:00
Fomafix
19f9660461 ApiQuerySiteinfoTest: Conversion of $wgContLang to service
Bug: T200246
Change-Id: Ibdf07adc7a4cf28f0f9f48f18985651a379bc10c
2019-02-05 05:05:53 +01:00
Kunal Mehta
643225cbc7 Add some missing @covers tags
Change-Id: Idb9af9515702ee9748755d7799663713b2283647
2019-02-02 21:53:40 -08:00
David Barratt
8631ea7bf6 Add tests to ensure that NamespaceRestrictions are returned from Block APIs.
Bug: T204989
Change-Id: Ibe44da41e9efa6688615dc9b0712f9713d4e8158
2019-01-23 21:31:12 +00:00
jenkins-bot
24b5967313 Merge "Add namespace restrictions to Special:Block and API" 2019-01-23 17:04:55 +00:00
Thalia
f589214d0f Add namespace restrictions to Special:Block and API
This adds a UI for blocking namespaces to Special:Block
and a namespacerestrictions parameter to the block API.

The number of namespace restrictions in a single block
is not limited as page restrictions are.

The checkbox allowing the blocker to specify whether
the target can edit their own user page is normally
disabled for a partial block, but is re-enabled if
the block is to the user talk namespace.

If the config $wgBlockAllowsUTEdit is set to false, the
checkbox will not appear, and the target will not be
able to edit their own user talk page if they are
sitewide-blocked, namespace-blocked from the user talk
namespace, or page-blocked from their user talk page.

Bug: T204986
Change-Id: I9e231ad109d7285486ec332b26780339592b8df7
2019-01-22 12:48:55 +00:00
Max Semenik
f735507bfc Convert RandomImageGenerator to use the new execution framework
Introduces a stringifier for Command, useful for debugging.

Change-Id: Ifcfccaef5a609e0cf30186e39a6bd0fa971c2dbd
2019-01-21 22:33:02 -08:00
Brad Jorsch
db67de7fad ApiDelete: Handle batched deletions properly
When batched deletions via the job queue were added in Ie800fb5a, the
way this was reported caused ApiDelete to report an error. Instead it
should report success with appropriate signaling to the client.

Bug: T212356
Change-Id: I1ef66277e988572c6720cf3e3cb36b18530746b4
2018-12-20 10:03:26 -05:00
Brad Jorsch
0867b6e8df ApiBlock: Avoid PHP warning when partial blocks are enabled but not used
If partial blocks are available but a sitewide block is being made,
$params['pagerestrictions'] is null and implode() raises a warning.
Since null casts to the empty array, it's easy enough to work around.

Also add a test hitting this case.

Change-Id: Id7e2559d7569031b7c1228adb0c0a14b3c1527c3
2018-12-19 11:14:50 -05:00
jenkins-bot
9ef78ab4c1 Merge "ApiComparePages: Don't error with no prev/next rev" 2018-12-18 10:06:23 +00:00
Thalia
9c8e1aaa4c Set API limits for page restrictions to 10
Bug: T212142
Change-Id: Ide0f2f86df2101194155be53a4b9012ddefbbcaf
2018-12-17 17:53:27 +00:00
jenkins-bot
41fa0b12e7 Merge "ApiComparePages: Don't try to find next/prev of a deleted revision" 2018-12-06 18:19:39 +00:00
jenkins-bot
5417327be0 Merge "Don't silently fail if API result fails to encode" 2018-12-05 20:15:04 +00:00
C. Scott Ananian
afd3dbaa95 Don't silently fail if API result fails to encode
Ensure that errors encoding API results produce actionable log entries.

Part of the follow-up to T210550.

Change-Id: I6f311451e3b07b540f14352ce25af9d74a053d19
2018-12-05 13:28:33 -05:00
Brad Jorsch
3c95d3bdd9 ApiComparePages: Don't try to find next/prev of a deleted revision
RevisionStore::getPreviousRevision() and ::getNextRevision() don't
handle being passed a RevisionArchiveRecord very well. Even if they
would, it's not clear whether the user wants to be comparing with the
next/previous deleted revision or the next/previous revision even if not
deleted. So let's just make it an error, at least for now.

Bug: T208929
Change-Id: I151019e336bda92aa4040ba4162eb2588c909652
2018-12-03 15:31:34 -05:00
Amir Sarabadani
02a930d7fb Drop $wgChangeTagsSchemaMigrationStage
Bug: T194163
Change-Id: Ieb6cc60cacf9dd0d86641b1be817249cdce42112
2018-11-28 23:03:41 +01:00
Brad Jorsch
c765b4e37c API: Add exception class as data to internal_api_error codes
The code for all uncaught exceptions will in the future be
"internal_api_error". If the client needs to know the class name for
some reason, it can check the new 'errorclass' data item on the error.

Change-Id: Ia9e32bbb8d17692203f4fbcee53a20e87be1776e
2018-11-26 13:42:07 -05:00
Brad Jorsch
4eace785e6 API: Validate API error codes
Validate them in ApiMessageTrait when the message is created, and again
in ApiMain before they're included in the header.

This also introduces an "api-warning" log channel, since "api" is too
spammy for real use, and converts a few existing things to use it.

Bug: T208926
Change-Id: Ib2d8bd4d4a5d58af76431835ba783c148de7792a
Depends-On: Iced44f2602d57eea9a2d15aee5b8c9a50092b49c
Depends-On: I5c2747f527c30ded7a614feb26f5777d901bd512
Depends-On: I9c9bd8f5309518fcbab7179fb71d209c005e5e64
2018-11-26 18:41:08 +00:00
jenkins-bot
cb4d4c4d8f Merge "Move user_editcount updates to a mergeable deferred update" 2018-10-26 20:32:24 +00:00
Aaron Schulz
390fce6db1 Move user_editcount updates to a mergeable deferred update
This should reduce excess contention and lock timeouts.
Previously, it used a pre-commit hook which ran just before the
end of the DB transaction round.

Also removed unused User::incEditCountImmediate() method.

Bug: T202715
Depends-on: I6d239a5ea286afb10d9e317b2ee1436de60f7e4f
Depends-on: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
Change-Id: I0d6d7ddd91bbb21995142808248d162e05696d47
2018-10-25 15:32:18 -07:00
David Barratt
b3014df3b6 List Partial Block details in ApiQueryBlocks and ApiQueryUserinfo.
The ApiQueryBlocks and ApiQueryUserinfo endpoints will now return whether or not the block is
sitewide or partial. Partial block restrictions can be returned with ApiQueryBlocks.

Bug: T197141
Change-Id: I76eb4cac4dc989c621a00a39996faebd0eb9892c
2018-10-24 16:26:32 +00:00
jenkins-bot
aff39bd7c9 Merge "Enforce partial blocks" 2018-10-24 03:15:39 +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
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
Brad Jorsch
cf4f985f22 ApiComparePages: Don't error with no prev/next rev
Prior to I700edfa76, torelative=prev on the first revision of a page
would "diff" from an empty revision, and torelative=next on the latest
revision would diff to that same latest revision. People were depending
on that behavior, so restore it.

Bug: T203433
Change-Id: Ie81b58c196998a8047322740fe1d1fa44eff8526
2018-10-22 13:47:43 -04: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
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
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
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
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
cf6fb41666 Merge "Re-namespace RevisionStore and RevisionRecord classes" 2018-10-10 05:16:45 +00:00
jenkins-bot
5ab9496031 Merge "Clean up ApiLoginTest" 2018-10-09 19:17: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
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