Commit graph

50 commits

Author SHA1 Message Date
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Umherirrender
5a318bd5bf Pass function name to database functions (maintenance scripts)
Useful for logging

Change-Id: I79fe037abcd74f56c935abc118d706bef0198124
2020-06-07 17:24:10 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Bill Pirkle
d2b000414e Update populateRevisionSha1.php for MCR schema changes
Maintenance script populateRevisionSha1.php was using the deprecated
Revision class. Instead, use the new RevisionRecord class if
possible, and custom code otherwise.

Bug: T217829
Change-Id: I0c22286a16d7b243306447d8948428702269a4bd
2019-07-04 08:58:01 +00: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
bf5a104146 Remove wfWaitForSlaves when using Maintenance::commitTransaction
Maintenance::commitTransaction is calling waitForReplication already.
No need to wait a second time, hopefully the lags are 0 already.

Change-Id: Id457ed2cdd6bfd9663665ba0cd5c4e3dd640b738
2018-02-26 21:05:33 +01: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
Phantom42
9b4d71f531 Cast block start to int in maintenace SQL
Bug: T182209
Change-Id: Ic2dbbacdf0a77b8ac531cff8e11be0da8014e083
2017-12-08 22:03:49 +02: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
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
fa4a909def Replace more uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation. The
upcoming actor table change, and the suggested title table change, will
add more such requirements.

Change-Id: Ic8213bff74b8350b15cd271d0ef252e63e7e79bd
2017-10-13 19:02:56 +00:00
James D. Forrester
242df680ce maintenance: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

This includes renaming fixBug20757.php to fixT22757.php for similar consistency.

Change-Id: If81a590d658fbd82c20c54ac47dfdc8856745ca3
2017-02-21 18:32:44 -08: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
Aaron Schulz
fa8e1a9b00 Clean up transactions in maintenance scripts
Add transaction methods to complement getDB().
This makes it easy to grep for direct begin()/commit()
calls to IDatabase by having script use their own
wrapper. Maintenance scripts are one of the few places
that can (and need to) use begin/commit instead of the
start/end atomic methods.

Eventually, there should be almost no direct callers
and those methods can be made stricter about throwing
errors on nested calls.

Change-Id: Ibbfc7a77c0d2a55f7fc2261087f6c3a19061e0aa
2015-12-30 23:40:35 +00:00
Aaron Schulz
6921770414 Updated some try-catch statements: MWException -> Exception
Change-Id: I76601a86e30f4984e3b1a8c8ec5ef5a0f652433a
2015-01-09 17:20:22 -08:00
Siebrand Mazeland
5a77286a1e Update formatting in maintenance/ (3/4)
Change-Id: I4390c4ea12a6a626b0e6817b6446635116ca9fe3
2014-04-23 20:09:13 +02:00
Siebrand Mazeland
0619388d87 Pass phpcs-strict on maintenance/ (3/8)
Change-Id: I453ecc474139c7a5f1d0d20306ad28c2cee80ec9
2014-04-22 21:25:52 +00: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
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
dbd0b590e9 else if -> elseif
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20
2013-04-17 16:52:47 +02:00
MarkAHershberger
34c9bca6a8 (bug 38110) provide a way to separate out schema changes
Allows update.php to be run when $wgAllowSchemaUpdates = false.

This is useful for non-WMF environments where strict DB permissions
allow database updates (which update.php performs), but no schema
changes (such as adding or dropping tables or indices which update.php
also performs).

It does this by adding the --schema and --noschema flags. Without
either of these flags, update.php will perform exactly as before.

With --noschema, all changes to the table structure or table additions
are skipped. Only data changes are made.

With --schema is used, no schema changes are made to the database, but
the schema changes are saved to a separate SQL file that can be run.

Change-Id: I96b4cfd4c02e9cbf46cc6a0499b87fb3b89020a0
2012-11-21 22:53:24 -05: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
2ce15203a6 getting rid of getRawText() 2012-06-08 08:34:38 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Aaron Schulz
8241670132 Handle more ES exceptions when getting text.
Change-Id: I795dce37bcf4a24d5922d2d5166bf27ba9b77607
2012-05-29 16:51:15 +02:00
Brion VIBBER
739c194516 Merge "Work around annoying Revision::newFromArchiveRow exception." 2012-05-24 18:48:38 +00:00
Aaron Schulz
41aa27cf8c Work around annoying Revision::newFromArchiveRow exception.
Change-Id: Ib5cfae54b12fd2fee5120d7dbae7a1e2b99b0181
2012-05-23 13:18:57 -07:00
Aaron Schulz
d94a5c89f9 Skip legacy archives rows that already have the sha1 filled.
Change-Id: I070413a736211017022c7ae36a9efab3aa0e1fe1
2012-05-23 12:28:09 -07:00
Sam Reed
3a8e088540 Minor followup to r111795, make doSha1LegacyUpdates return it's count value so it can be added to the count of archive rows
Don't return true in doSha1Updates(), return 0 if table is empty
2012-03-06 19:21:07 +00:00
Sam Reed
c47f83a4d4 More __METHOD__ in our madness 2012-02-24 18:45:24 +00:00
Aaron Schulz
b4704adf09 r111795: Split out upgradeLegacyArchiveRow() function and added NS/title to condition. The $idCol var was misleading as obviously ar_timestamp is not unique. 2012-02-20 11:00:56 +00:00
Aaron Schulz
8ad95acd4d r111795: update line to remove bogus $db argument 2012-02-19 19:47:09 +00:00
Aaron Schulz
7d1d9a7c51 (bug 34373) - 'populateRevisionSha1.php misses archive rows, whose text is stored directly in the archive table (not text table)' 2012-02-17 21:48:01 +00:00
Sam Reed
c760826b64 Documentations! 2012-02-14 04:05:49 +00:00
Aaron Schulz
c326cab516 Reinstated r94289 et all - rev_sha1/ar_sha1 field for bug 21860 2011-10-27 18:44:10 +00:00
Brion Vibber
5ce010f85c Revert r94289, r94290, r94294, r94333, r94345, r94362, r94370 -- core schema change with no discussion 2011-08-15 18:24:38 +00:00
Aaron Schulz
8991eea8fb More to r94370:
* Fixed hard-coded output message (use $table)
* Removed doPopulateRevSha1 from SqliteUpdater.php too (didn't notice someone added this)
2011-08-12 19:24:08 +00:00
Aaron Schulz
18f5bf2c95 * Added LoggedUpdateMaintenance subclass
* Moved PopulateRevisionLength/PopulateRevisionSha1 scripts to $postDatabaseUpdateMaintenance
* Fixed bogus "{$prefix}_sha1 != ''" comparison (r94362)
* Removed unneeded NOT NULL check (speeds up script a bit) from populateRevisionSha1 script
* Various code cleanups
2011-08-12 19:11:04 +00:00
Aaron Schulz
40f7928918 Give notice about missing text 2011-08-12 17:13:28 +00:00
Aaron Schulz
537a6eb680 Fix for r94289: we want to skip rows with non-empty sha1, not non-NULL (which is impossible) 2011-08-12 16:50:03 +00:00
Max Semenik
b87c77ebb7 Follow-up r94289: SQLite support, unbreaks tests 2011-08-12 13:16:06 +00:00
Roan Kattouw
975666e7d5 Fix copy-paste mistake in r94289 2011-08-12 10:00:09 +00:00
Aaron Schulz
606872436b * Added rev_sha1 and ar_sha1 columns to revision/archive tables (useful for bug 25312)
* Created a script to populate these fields (doesn't handle archive rows without ar_rev_id set though)
2011-08-11 21:52:54 +00:00