Commit graph

109 commits

Author SHA1 Message Date
Kunal Mehta
c4e5a9dd97 Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
2018-06-10 23:55:11 -07:00
daniel
218e8311d5 Pass '' instead of false for the $conds parameter in select calls.
Per documentation on IDatabase, $conds must be a string or an array.
Passing false for conds is confusing, since it's unclear whether this
should match everything or nothing.

Bug: T188314
Change-Id: I8be1ac4cbdaafc41aadc2a658be8a99b754b0268
2018-03-02 02:32:54 +00:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.

Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
2017-11-21 21:34:16 -07:00
Max Semenik
55a9b2f8b6 Finish migration to Maintenance::getBatchSize()
Change-Id: I02d89f71d820e4d00a39e86a30397b614bbdb432
2017-11-07 19:35:11 -08:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Jesús Martínez Novo
ec7b5e9262 refreshLinks.php: Fix fatal when using --category parameter
A title object must be passed to refreshCategory(), which is created in
the above lines, not the string representation received as a parameter.

bug: T172061
Change-Id: Id579a86a26cb438c1866351064c6887dbcea23b0
2017-07-30 15:39:36 +02:00
Timo Tijhof
1e0a992f6c maintenance: Consistently use hasOption() for boolean options
We already do this in many places, but there were also still plenty
of getOption(, false) calls. Change these to hasOption() for consistency.

Change-Id: I74f91a5bf5a8036496ab1f493e5862a04d27ec0f
2017-07-19 14:52:21 -05:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aaron Schulz
0916fa76e8 Add missing doUpdates() call to refreshLinks.php
Follows-up b8b01aa589 which accidentally removed this call.

Bug: T157545
Change-Id: Id4efdccb60e7829269df601b83f64288f6190db4
2017-05-19 19:09:44 +00:00
Aaron Schulz
21e71e0235 Use IDatabase type hints in /maintenance
Relatedly, move lockTables()/unlockTables() to IMaintainableDatabase

Change-Id: Ib53e9fa948deb2f9a70f0ce16c002613d0060bf9
2017-04-07 23:37:41 +00:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Kunal Mehta
504d558209 refreshLinks: Queue non-recursive updates
This appears to have been an accidental change introduced in
48d0bedd78.

Change-Id: I40a6bbead4b9966f130380fb91681a40395989a3
2017-02-13 18:59:53 -08:00
Max Semenik
13054a4c70 refreshLinks.php: allow refreshing by categories, tracking or not
Needed for selective updates of pages using a particular feature.
Intended to be run in production, so needs to scale.

Bug: T149723
Change-Id: If20fb1f91de8d4227def5b07d6d52b91161ed3fd
2017-01-23 14:30:16 -08:00
Kunal Mehta
fb1d035abf refreshLinks: Use vslow group for DB_REPLICA connections
Change-Id: If2f3bba7f0b518f26f0672150c94b999ac79f325
2016-09-15 17:41:48 -07:00
Kunal Mehta
47718dfab8 refreshLinks: Add --namespace option
This allows limiting refreshing data to pages in a single namespace.

Change-Id: I309058df98b638beb32adb1d663455a0c4aa1cec
2016-09-14 01:04:58 -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
b8b01aa589 Replace DataUpdate::doUpdates() callers in maintenance/
Change-Id: I51df9f419d6ea1e822fd0eef8c5dc4c43f9855e1
2016-09-01 21:30:34 -07: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
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Tim Starling
01a18cfc91 In refreshLinks.php don't clear tag hooks
It made perfect sense when I introduced this line in June 2005, but now
that we have <ref> etc., we need to use the normal parser configuration.

Change-Id: I5a32e4e38badff85fe6d7d63c3fa158dc6fd5336
2016-01-19 17:15:39 +11:00
Reedy
44cebea941 Update wfGetDB calls in Maintenance scripts to use getDB()
Change-Id: I9ad6745d84506b736dae94747256caac89715899
2016-01-02 16:58:23 +00:00
aude
6b82cb0ddf Remove begin/commit transaction calls in refreshLinks.php
these sometimes lead to issues with database deadlock loops
and probably are not needed here.

Bug: T75456
Change-Id: Iad03f6076d8e319ff02cb26259ec9705105e92a7
2015-10-27 02:07:46 +01:00
Tim Starling
2c6c954e23 Abstract and refactor Tidy support
* Split tidy implementations into a class hierarchy
* Bring all tidy configuration into a single associative array and
  deprecate the old configuration.
* Remove $wgAlwaysUseTidy

This is preparatory to replacement of Tidy (T89331). I used the name
"Raggett" for things relating to Dave Raggett's Tidy, since if we use
"tidy" to mean the new abstract system as well as Raggett's tidy, it
gets confusing.

Change-Id: I77af1a16cbbb47fc226d05fb9aad56c58e8910b5
2015-09-10 20:18:52 -07:00
Kevin Israel
be49081be6 refreshLinks.php: Don't wait for slaves if nothing found in a chunk
Since 40e300b827, the last deletion batch is no longer handled
separately, so the wfWaitForSlaves() call added in 7492e90cc6
should no longer be necessary.

Also moved the remaining wfWaitForSlaves() call after the DELETE
query, as is the case in most other maintenance scripts.

Change-Id: I2c3c5ce20f81aed28b4b4c7ecf4eaaca7b9791d1
2015-08-02 06:46:44 -04:00
Kevin Israel
6a1e956428 refreshLinks.php: Fix deletion of link entries from nonexistent pages
After checking a chunk of one of the links tables, the script failed
to restore the original chunk start when checking the next table.

Follows-up a1e0051559.

Bug: T107632
Change-Id: I21678bc3c83946f2e62afe3fdc69c7e84678ceeb
2015-07-31 18:16:24 -04:00
Chad Horohoe
f94e85e976 wfRunHooks() -> Hooks::run() in maintenance scripts
Change-Id: I6550bca3a6a3a6cd67bb1ed94c09805deed86dbc
2015-04-27 21:42:17 -07:00
Kevin Israel
a1e0051559 refreshLinks.php: Limit rows scanned per query in deleteLinksFromNonexistent()
This also makes the -e and [start] options apply to --dfn-only, making it
possible to restart the script other than at the beginning if necessary.

Bug: T38195
Change-Id: I828b522039290b5700faa89fb8ad4075e50332e7
2015-03-26 16:26:25 -04:00
Kevin Israel
1976b1a6fd refreshLinks.php: Tweak exit condition in deleteLinksFromNonexistent()
Instead of exiting the do...while loop only once a query returns zero
rows, exit whenever fewer rows than the batch size are returned. This
could save quite a bit of time when the highest nonexistent page_id
found is a relatively low one.

Follows-up 40e300b827.

Bug: T44180
Change-Id: I14d2d48c2405fcc0bd05a3181ba6293caef5298c
2015-02-28 04:54:48 -05:00
Kevin Israel
40e300b827 refreshLinks.php: Get IDs in batches in deleteLinksFromNonexistent()
... instead of making an unbuffered query, which is discouraged in the
doc comment for DatabaseBase::bufferResults().

Also used NOT IN for the antijoin instead of LEFT JOIN...IS NULL; when
combined with DISTINCT, the latter causes MySQL to use a temporary
table rather than an appropriate index, according to EXPLAIN. (Using
GROUP BY instead of DISTINCT also avoids this problem. I don't know why.)

Bug: T44180
Change-Id: Idca85fac7dd7879f9fbef2712b6aa83343099e02
2015-02-27 15:16:48 +00:00
Siebrand Mazeland
606c680b21 Update formatting in maintenance/ (4/4)
Change-Id: I6b58d014a4bfd6600e4e6f80188fdcfce18482ca
2014-04-23 20:09:26 +02:00
umherirrender
e78776373e Fixed some @params documentation (maintenance)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I727deec35a712de0f0c676cc87dfa661f1ee965b
2014-04-17 22:48:32 +02:00
Brion Vibber
5cd20add48 bug 23839: "Refreshing links table" -> "Refreshing links tables"
There's not a single links table; there are several tables. :)

Change-Id: Ie2a76da3d047a41d102442be1919796bcd7bf2d2
2013-09-25 09:14:27 -07:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
umherirrender
b114f5e1c1 Fixed some spacing in maintenance folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9657f72996358f8c1c154cea1ea97970d973723c
2013-04-18 20:48:44 +02:00
Alexandre Emsenhuber
591a275230 Make redirect update in refreshLinks.php bypass the redirect table
This makes this script actually useful when updating namespaces by
making sure the target registred in the "redirect" is the correct one.

Consider the following example:

- Create a redirect page pointing to a page "Extra:Target"
- Add $wgExtraNamespaces[100] = 'Extra'; in LocalSettings.php
- run refreshLinks.php

Previously the redirect target of that page was not updated and still
pointing to (0, "Extra:Target") which no longer a valid title.
Now it will be updated correctly to point to (100, "Target").

The value of the page_is_redirect field will also be updated to be
sure it has the correct value, which might be wrong when the target
becomes valid or invalid, e.g. by changing $wgInvalidRedirectTargets.

Change-Id: I458ca63550df56ca96b35749daf4e7b866ab9d93
2013-01-17 10:51:35 +01:00
Alexandre Emsenhuber
2b6b4f9a0e Fix erroneous check in refreshLinks.php
Obviously null === false will never return true,
and what we actually want here is to check whether
we have a content or not.

Change-Id: Id78897e80ba2553c925e10d67c0fce2186aa11fd
2013-01-13 22:13:55 +01:00
Alexandre Emsenhuber
d85239a186 Use ResultWrapper::numRows() instead of DatabaseBase::numRows()
Change-Id: I87f059aaff72bf06ebc72ad3a7904cca8e11fab9
2013-01-06 11:52:40 +01:00
Platonides
6882ff0d75 The class is named Revision, no need to shout its name :)
Remove a couple of unused globals.

Change-Id: I750536bc05ed7a5433840b916b17df93d30da5bf
2012-10-26 23:41:24 +02:00
daniel
9994968774 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 15:20:15 +02:00
Daniel Kinzler
392af46809 Revert "merged master"
This reverts commit 67bfdc7a68
2012-08-29 13:14:49 +00:00
daniel
67bfdc7a68 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 12:06:38 +02:00
daniel
29719f846b merging latest master
Change-Id: I36b7f2f63ab8c08f8412d521dc68ea45c8b67711
2012-08-20 16:55:28 +02:00
daniel
8d280dde9b Moved getParserOutput to Content interface.
On Tim's request, this change moved getParserOutput() and getSecondaryDataUpdates()
from the ContentHandler to the Content interface.

Change-Id: Ia654aa8710a242ba5fe7a4eb528e6a6449035f59
2012-07-23 23:52:34 +02:00
daniel
3d58f903d8 Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata 2012-06-11 17:45:59 +02:00
Reedy
7492e90cc6 Add a bit more slave waiting...
Change-Id: I329219bfdd56b57609237fc9f907f2b31628d282
2012-06-09 03:37:38 +01:00
daniel
48d0bedd78 cleanup and fixes for secondary data updates 2012-06-07 14:57:43 +02:00
daniel
684178dfb6 Use Title, not IContextSource; remove createArticle, etc.
This merges the latest core patch into the Wikidata branch,
implementing suggestions collected on gerrit. Most importantly:

* Methods in the Content class no longer rely on a IContextSource
* createArticle and createEditPage were removed from Contenthandler
2012-05-23 08:53:01 +02:00
daniel
96b4779ebd introducing Content::getSecondaryDataUpdates() 2012-05-16 20:14:14 +02:00