Commit graph

157 commits

Author SHA1 Message Date
Brad Jorsch
25f02d91dc Fix RevisionDeleteUser rev_actor query for MySQL
MySQL uses an extremely bad plan for the update with subquery here.
For the time being let's split out the subquery.

This'll break if the user has too many revision rows, but on the other
hand all the existing queries here will probably break in the same way
so let's leave that for later.

Bug: T210628
Change-Id: Ia3eb41b43b96c506349279e19743c41530969636
2018-11-29 11:24:57 -05: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
Erik Bernhardson
08dba3de30 Remove PhanUndeclaredStaticMethod from blacklist
There was a single instance of this issue which was reasonably simple
to solve. The code that triggered the issue was not wrong, but calling
the grandparent constructor directly is not the cleanest code so it
seems right to fix it. Switch revision initialization into an
overridable function to remove the need to even have a constructor in
the class.

Change-Id: Ic2af0d93e8d55e93061e3f4b5c7a4122509543f0
2018-08-28 05:38:43 +00:00
petarpetkovic
b7a4e82545 Fix some of the common typos
* supress -> suppress (Except in backup_LogTest.php)
* recomend -> recommend
* becuase -> because
* accross -> across

Bug: T201491
Change-Id: I8faa4e6cc688b3ee204b3f79ab55eb7b65cc1fdd
2018-08-16 00:59:32 +02:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Amir Sarabadani
6a2cd1c5c2 Use constants for rc_patrolled values instead of numbers
These are recently introduced, better to use them

Change-Id: Id904ff09081cb5a1fe2f1c24c5d415da18fd2294
2018-04-13 23:56:35 +02:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
Brad Jorsch
26e705da8d Fix typo
Followup to Ic3a434c0

Change-Id: Ie57ab2dab2f9ae801de49e8e3998ec5a56a4541e
2017-09-08 10:25:02 -04:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Brad Jorsch
11cf01dd9a Add comment table and code to start using it
A subsequent patch will remove the old columns.

Bug: T166732
Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
2017-08-30 15:05:00 +10:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Umherirrender
ace44e2064 Use correct variable name in @param documentation
For some varargs a variable name is added with suffix ,... as seen for
many other varargs

Some @param are swapped, because there are in the wrong order

Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
2017-08-11 19:27:19 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Thiemo Mättig
e16191caa3 Remove unused and unnecessary imports
Change-Id: I26e623a4e4ba965c07670369a90c8a95185ea1e4
2017-06-12 15:50:43 +00:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
WMDE-Fisch
ae3419f532 Replace some of the deprecated wfGetLBFactory() calls
Change-Id: I87aa0ebe273706438f1634167de8c60f51432878
2017-02-07 14:41:09 +01:00
Justin Du
81b9324620 Add tagging support to imagerotate, revisiondelete, and tag API modules
Adds a tags parameter. This allows a user with the applychangetags right to tag the log entry corresponding to the action.

Bug: T97720
Change-Id: I11418d22ee780944e92d82e32b271b8276c396bf
2016-12-31 11:45:18 -06:00
Brad Jorsch
96b60ded77 Fix RevDel API output for formatversion=2
Use booleans, not the old empty-string-or-undefined.

This bugfix is a breaking change, but chances are it won't affect many
clients.

Bug: T153518
Change-Id: If5fa2cdcb973b186349307b29e4266daceef0a9d
2016-12-19 11:48:49 -05:00
divadsn
870d05e408 Replace Linker::link() with LinkRenderer in all revisiondelete pages
* RevDelArchiveItem
* RevDelArchivedFileItem
* RevDelFileItem
* RevDelLogItem
* RevDelRevisionItem

Bug: T149346
Change-Id: I96f83d06b4d3ccf3f76ccfca843a6aaf76d89063
2016-12-06 19:25:14 +00:00
Aaron Schulz
a2790b1b80 Remove wfGetCaller() dependency from DatabaseBase
Change-Id: I3e240b2eb5c1f6a21f1bc974c3d28f5755c7451a
2016-09-15 14:40:00 -07:00
Roan Kattouw
59f09caabc Force primary index for RevDelRevisionList query
To work around an optimizer bug in MySQL where the
index on (rev_page, rev_id) is picked which mysteriously
leads to very slow execution times and timeouts.

In theory, the index being forced here is (rev_id),
which is fine for this query. In WMF production,
it can also be (rev_id, rev_user) (still fine), or
(rev_page, rev_id) (the index we're trying to avoid).
Mysteriously, the optimizer bug doesn't happen if
(rev_page, rev_id) is the primary key, so this still
behaves OK.

Bug: T104313
Change-Id: I15c68ba29309dca8dea274f19389d139a82784aa
2016-09-10 17:25:10 -07:00
Aaron Schulz
751c4d395f Make the page JOIN in RevDelRevisionList actually apply
The table was missing from the tables array

Change-Id: I613a2075e5d18210c8187587462b0f000769aec2
2016-09-09 23:21:32 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Aaron Schulz
32a8eb1822 Make various MWCallableUpdate usages rollback-safe
Support for this added to MWCallableUpdate and its helper method
in DeferredUpdates.

Bug: T141988
Change-Id: Ief150ea655036e2708557dd8ae847379edf21933
2016-08-15 00:47:42 -07:00
Aaron Schulz
56f14e2b5d Fix inconsistent RevDelFileItem visibilities
Bug: T142228
Change-Id: Ib5a0a1adbea2daf2b035cf6be367841362de03cc
2016-08-05 22:42:12 +00:00
jenkins-bot
d4f1e00a0c Merge "Make revision deletion acquire file locks to avoid races" 2016-07-27 00:47:03 +00:00
Aaron Schulz
d217cdf4b5 Make revision deletion acquire file locks to avoid races
Also made RevisionListBase an Iterator to avoid ugly loops here

Change-Id: I40d2d8cf63df95c59d0e1275e3ec45aff238e1cb
2016-07-26 16:32:15 -07:00
Aaron Schulz
3a922d36d8 Convert onTransactionIdle() callers to DeferredUpdate subclasses
* This puts the complex logic here after the commit step for
  all DBs, making the main multi-DB transaction more likely
  to be atomic. Previously, the idle callbacks could be hit
  bewteen DB commits.
* Enforce transactionality via AtomicSectionUpdate.
* Use $this instead of $that hacks for old PHP versions.

Change-Id: Idf7d54fdac6487f86907099680f5c1c4f5530b4e
2016-07-25 16:49:15 -07:00
jenkins-bot
e5e7d75a16 Merge "Avoid calling rollback() in setVisibility() when nothing changed" 2016-07-22 17:40:59 +00:00
Aaron Schulz
a68de43285 Avoid calling rollback() in setVisibility() when nothing changed
Change-Id: I7fde64fe1e6c9553447bcb9e62a1a9530f9e52ce
2016-07-21 18:42:48 -07:00
Aaron Schulz
6bbbb27446 Make non-exception rollback() calls safer
Use rollbackMasterChanges() instead so that all DBs get reverted.
Otherwise, external DB updates may get committed while related local
DB changes are rolled back.

Change-Id: I74de77f4b12dc15c0473c272d090caeeb97d6983
2016-07-21 18:10:43 +00:00
jenkins-bot
0124c6ce75 Merge "Title::getLinkURL(): Allow expanding PROTO_RELATIVE too" 2016-07-20 21:56:21 +00:00
Andrew Otto
ee75aa9bee Add $visibilityChangeMap parameter to RevDelList doPostCommitUpdates
This paramater contains a map of id => old and new visibility bits.
This allows doPostCommitUpdates to do something useful with the
differences before and after a visibility change.  Specifically,
RevDelRevisionList doPostCommitUpdates passes this to the
ArticleRevisionVisibilitySet hook.

Bug: T137287
Change-Id: I1824f56d2aadc15671c442cf30dc1f9f01e821f8
2016-07-06 10:36:08 -04:00
Kunal Mehta
5e11a28e7a Title::getLinkURL(): Allow expanding PROTO_RELATIVE too
Allow callers to get protocol-relative URLs by passing the
PROTO_RELATIVE constant. Since most callers don't pass in $proto, this
shouldn't change very much since the default of non-expanded is
effectively the same, but expanding to a protocol-relative URL when it
is not intended should still be safe.

A few callers that explicitly specified the default in core were also
updated.

Change-Id: I214f17aa6e8e30b647f21f0951fc3a15e87850c7
2016-07-01 11:31:56 -07:00
Aaron Schulz
f8f60f3926 revisiondelete: Fix $oldBits/$newBits usage in setVisibility()
This addresses the FIXME comment around updateLog()

Change-Id: Iedb9df0b4cf65308a6b58bd9d9295d1850bc2c28
2016-06-03 23:04:27 +00:00
Aaron Schulz
95ed38a0f3 Clean up setVisibility() log type logic
The log type used should be based on whether any item
was (un)suppressed, not just the last log entry. Otherwise,
unsuppression could end up in the wrong log if the last
item in the list was not unsuppressed but others were.

Change-Id: I7b6af524cc45a1d83b2b719bfa00138531455e35
2016-06-03 22:08:21 +00:00
Matthew Flaschen
77884372c0 RevDel: Fix ChangeTags for archived items
Bug: T128980
Change-Id: Ibc9ec57da16e1b71c9efa0d2c062f8d7965f59bc
2016-05-24 18:33:25 +00:00
Leszek Manicki
1588e2f279 Add a type hint to RevDelList::setVisibility
Docblock mentions an array already. All usages in core I've managed
to track also pass in arrays.

Change-Id: I830f446a2b63d09c7aa81205d66ac56d8bdab733
2016-04-27 16:57:28 +02:00
umherirrender
8678e32b8d Change remaining places to use short array syntax
Change-Id: I0785c73a239c11188ad7411c5cd8ed09a2dbc9b3
2016-03-11 18:41:26 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aashaka Shah
124026a712 Add IContextSource as parameter to ChangeTags::formatSummaryRow
Using IContextSource avoids the use of $wgLang and wfMessage which make
use of global $wgTtle.

Add IContextSource as parameter to ChangeTags::formatSummaryRow to avoid
globals. Define an IContextSource instance in all functions which
reference ChangeTags::formatSummaryRow and pass it in ChangeTags::formatSummaryRow
function call.

Also make the default value of IContextSource $context as null in
parameter, to avoid breaking changes for old callers in extensions.

Document default null value of IContextSource and add a @note to prefer
IContextSource over null value.

Remove trailing whitespace, and make code order according to parameter
order.

Bug: T105648
Change-Id: Ib54a6a96b73f6cd8fcdf8e520db2448a1e811cfa
2016-02-04 23:32:24 +05:30
jenkins-bot
e95100da6e Merge "Show change tags on Special:RevisionDelete" 2015-12-17 03:21:07 +00:00
mhutti1
112bec5c0e Show change tags on Special:RevisionDelete
RevDelRevisionItem.php has been modifed to display tags and
RevDelREvisionList.php has been modifed to request tag data
its database query.

Bug: T109041
Change-Id: Icaae790b7d21a6670c692d11e25c6db7b7325530
2015-12-15 20:24:36 +01:00
jenkins-bot
4657bd99ed Merge "PHP 7 compatibility: Fix variable interpolation in RevisionDeleter.php" 2015-12-14 00:29:23 +00:00
Aaron Schulz
282c5fa9f3 Rename SquidUpdate => CdnCacheUpdate
Squid is not the only possible CDN

Change-Id: Ie2a2955847c5706e630322bbbab71c9d063b378f
2015-12-09 16:31:17 -08:00