Commit graph

57 commits

Author SHA1 Message Date
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07: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
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +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
Aaron Schulz
c71fde92ad Fix Database IDEA warnings about callable parameters
Change-Id: Ia9ccc86bb9cbd78b5890ceaedce8cca8d6bb7fe4
2016-10-03 10:48:58 -07:00
Aaron Schulz
3a839c5927 Inject schema vars into DatabaseMysql
Also fix broken patchSql.php maintenance script

Change-Id: I45bccb0e2e10bd06651a551fa08ed0c66d11eb6a
2016-09-22 21:07:27 +00:00
Aaron Schulz
d7785d82f1 Fix undefined getDelimiter() call in sql.php
* Fixes regression from 4ef4438739.
* Also fixed numerous IDEA warnings.

Change-Id: Id41faff835ca25399ce1ceb10a19d19ffc914689
2016-09-19 22:30:06 +00:00
Aaron Schulz
3d5016569d More replication var cleanups in /maintenance
* Fix option check in sql.php
* Rename RecompressTracked vars and avoid deprecated
  method calls

Change-Id: Ie04f6e841d68d69c9243a185de1bd13a612b2070
2016-09-05 23:00:43 -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
c0a9ab0f6d Change "slave" => "replica DB" in /maintenance
Change-Id: Ibd3d617901130378a935402326cd4eefbb382c9e
2016-09-06 00:13:08 +00: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
Timo Tijhof
fc34ed8df7 maintenance: Add --query option in sql.php
This makes it easier to run a query in a scripted fashion,
e.g. with Wikimedia's foreachwiki.

Change-Id: I5562be2fb0871817ee55f1395b686537069f78dc
2015-07-18 20:53:25 +00:00
Brad Jorsch
f9b579efc6 Fix sql.php behavior on error
When an erroneous query is entered into sql.php, it doesn't clear its
line buffer, so the intended next query (often fixing a typo in the
original) winds up concatenated onto the erroneous query. Usually
leading to another error, which repeats the process.

The solution is simple enough: clear the line buffer unconditionally,
not only when no exception is caught.

Change-Id: Ia78e2df8b9c6698c0a225bfb3135274ed8da5303
2015-07-10 17:55:44 +00:00
Marius Hoch
a89338ff82 Improve documentation of maintenance/sql.php
I found this to be lacking earlier this week...

Change-Id: I409c7451baa71b88cf554af0d82d1bf5904a2c4c
2015-05-20 21:24:33 +02:00
Aaron Schulz
f4f5f41194 Allow the empty string as the wiki DB
* This is useful when cluster= is set but the DB is not there yet

Change-Id: I1766c564448502c7359c7da964f0becd2e3222c6
2014-11-06 23:40:24 +00:00
Bartosz Dziewoński
9e5443abc3 No space within the ?: operator
This style is a lot more common in our code.

Change-Id: I7f2fb3716c24c4a95a4c6c4a732b0226c315f242
2014-08-25 17:40:51 +02:00
umherirrender
25971af694 Cleanup some docs (maintenance)
- Fixed spacing inside docs
- Makes beginning of @param/@return in capital

Change-Id: I864b8b3f1f67e34e369aba7aadaf87e7752c894d
2014-08-09 22:08:40 +02:00
Siebrand Mazeland
606c680b21 Update formatting in maintenance/ (4/4)
Change-Id: I6b58d014a4bfd6600e4e6f80188fdcfce18482ca
2014-04-23 20:09:26 +02:00
Siebrand Mazeland
a50a5d9da7 Pass phpcs-strict on maintenance/ (1/8)
Change-Id: Ib68a7cf4251e8f4c71233df869673f4c5d3cf84c
2014-04-22 21:25:22 +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
Aaron Schulz
dd3a475346 Added --wikidb param to sql.php
* This is useful for updating DBs that are not actually a that of a wiki.
  For example a global blocking or central auth DB may not correspond to
  any single wiki. Trying to use --wiki will fail with het deploy

Change-Id: I232182b79c9ca6421789f19771ba427498fff713
2013-12-10 15:03:41 -08:00
Aaron Schulz
d2254ba11c Allow server selection when running sql.php
Change-Id: I2a643eb3a517eba09b80da19158e0957441bcaa5
2013-05-22 23:08:35 -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
bfb75bc8e2 Fixed spacing around parenthesis in languages/tests/maintenance
Change-Id: Idd4299d17f1fcf98ab1d635484cb4e880f35ee24
2013-04-28 15:57:34 +00: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
Reedy
9bdc558bc4 Add a wfWaitForSlaves() call at the end of sql.php
Useful if you're doing queries over many wikis (wmf usage) that might
induce some repllag

Change-Id: I9818f1763d3330d0b96d9bb9c192a957293b6a5b
2013-02-25 23:57:31 +00:00
Aaron Schulz
7d939705ce Made sql.php except a "cluster" option and cleaned up the arguments.
* This lets people choose to run the script on some external cluster
  instead of only the primary cluster for a given wiki ID.

Change-Id: I6e8c10bc772d4a26c38f2ed8ae5787c8d130bd4c
2013-02-21 22:36:09 +01:00
Antoine Musso
bb497c97b6 misc style issues
7zip.inc : $stream is really a private property.

userDupes.inc : still only used by MysqlUpdater, added a comment about
it and made the properties private.

sql.php : make sure we actually do nothing in some method. Previously we
just had an empty IF statement.

purgeList : a private method was named the same as the class, that is
how we declared constructor with PHP4. Renamed it to doPurge() to make
it clear that it is not the constructor.

Rests are whitespaces fixes.

Change-Id: I0b83f83ee3af37c770817ebfce3e804082c2fb41
2013-01-30 16:12:59 +01:00
Demon
63fe60368c Merge "alter sql.php prompt on line continuation" 2012-10-25 13:35:32 +00:00
Demon
c5462bcde0 Merge "(bug 37020) sql.php with readline eats semicolon" 2012-10-25 13:32:38 +00:00
Antoine Musso
0e7d61dd9f sql.php in interactive no more exit on DBerror
This patch make it so that after a DBerror a new prompt is shown to the
user. Save us from having to relaunch sql.php.

Change-Id: Id3df3df87f6fe7b2aea31e0526c5ff697bc5832c
2012-10-25 13:14:24 +02:00
Antoine Musso
b1a524fddc alter sql.php prompt on line continuation
As long as a command is not ended with a database delimiter, sql.php
kept appending the line without noticing the users. That is a bit
confusing since you might not even know what you are going to run when
entering the delimiter.

This patch alter the prompt to '    ->' until the command is finished.
That is more in line with how MySQL cli handles it.

Example:
	$ php sql.php
	> SELECT
		-> *
		-> from
		-> job;
	Query OK, 0 row(s) affected
// repeal command:
	> SELECT * from job

Change-Id: Ic18b39d75d4db48d37d485e66f36d691e95934fb
2012-10-25 13:03:59 +02:00
Antoine Musso
c8e136dbbb (bug 37020) sql.php with readline eats semicolon
The database delimitor is now appended to the command before it is saved
in readline history.

Change-Id: Ie6bbac2d74e2e5df3910c5612adbd373a9c4695b
2012-10-25 13:01:28 +02:00
Alexandre Emsenhuber
dd6613b6bd Added missing GPLv2 headers in maintenance scripts.
- made file/class documentation more consistent
- contains a fix for Id7a04ff8 (2a7478b)

Change-Id: I5264105ce1b6ad86a9840e05be1af99f5d6e252a
2012-09-04 18:48:17 +02:00
Alexandre Emsenhuber
a75b6d53cd Improve documentation of maintenance scripts.
Also contains a fix for Ia5a38311 (fae0550).

Change-Id: I630c83b48b66c5d8c97411082cabd731f316f42d
2012-09-02 20:33:22 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Sam Reed
d4675054cd Fixed reading from file from r108774 2012-01-17 13:29:42 +00:00
Sam Reed
ebf916f3fb Give sql.php eval.php type scrollback 2012-01-12 22:57:51 +00:00
Chad Horohoe
26505b170a Fix concern raised by Brion in r74108 (but has really existed since the maintenance rewrite). Right now, including a maintenance script causes it to execute. This is bad when you want to reuse the particular class but not have it start executing all by itself.
Until now, we relied on setting MW_NO_SETUP which was a) hacky, b) irreversable, and c) likely to be forgotten if you didn't use one of the wrappers like runChild().

Instead, move the freaky magic to doMaintenance and have *it* check if it's in a specific call stack that indicates this is being run from the file scope and should be executed. Rename DO_MAINTENANCE to RUN_MAINTENANCE_IF_MAIN so it's nice and clear what magic happens behind the require_once().
2011-01-13 22:58:55 +00:00
Mark A. Hershberger
617a5b1e15 Whitespace fixup under tha maint directory. 2010-12-04 03:20:14 +00:00
Sam Reed
659778619c Stylize maintenance folder.. 2010-05-22 16:50:39 +00:00
Chad Horohoe
9b5196a68d Fix child class visibility 2010-03-10 12:59:44 +00:00
Brion Vibber
02727d3f79 Fix regression in sql.php: needs to run w/ DB admin privileges in order to do DB updates 2009-09-22 16:41:04 +00:00
Alexandre Emsenhuber
44729064cd * batch change for "while ( $row = $db->fetchObject( $res ) )" and similar to "foreach ( $res as $row )"
* identation fix in nukeNS.php
2009-08-17 21:15:31 +00:00
Chad Horohoe
567f244e36 Revert r54244 which was stupid and fix this properly. Require commandLine.inc/Maintenance.php using the full path every time. 2009-08-03 21:56:41 +00:00
Chad Horohoe
30468dbcf7 Don't put \n on the end of every error() call, just do it in error() itself. Still have to use on output(), because people like "Something...done" stuff. 2009-08-02 21:55:10 +00:00
Chad Horohoe
a1c51e18af Merge maintenance-work branch (now with less errors!):
* Docs have been updated to indicate the standard on how to write maintenance scripts (MW.org docs will follow) Have ported vast majority of maintenance scripts to new format. Remaining ones (mostly FiveUpgrade-related) are a bit more tricky. commandLine.inc is untouched for now. Many have gotten code-style updates as well. Deleted .inc files were only used by their .php counterparts, and have been merged into single files.
* (bug 11867) Lock error on redirect table when running orphans.php
* (bug 16322) Allow maintenance scripts to accept DB user/pass over input or params
* (bug 18566) Maintenance script to un/protect pages
* initStats overhaul, now uses class SiteStatsInit. Also fixes bug 18930
2009-08-02 19:35:17 +00:00