Commit graph

36 commits

Author SHA1 Message Date
Bryan Davis
aaf1e17088 Remove "@author Bryan Davis" and "Brad Jorsch" annotations
Undo traces of a practice we carried over from past projects and
existing examples that is neither universal nor actively encouraged in
the MediaWiki codebase.

Bug: T139301
Change-Id: I5c9c89b72a45a44aa4264a5e57b003c1a86cdf6e
Co-Authored-By: Brad Jorsch <bjorsch@wikimedia.org>
2017-06-26 15:25:46 -06:00
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
James D. Forrester
1e9c361960 tests: 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.

Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
2017-02-21 02:14:34 +00:00
Aaron Schulz
864eab03e7 Move DBMasterPos to Rdbms namespace
Updated all callers

Change-Id: Iacd5d6f7f18d8b23df24637cda61592112490eb0
2017-02-10 02:38:56 -08:00
Aaron Schulz
38b31bc8db Move DatabaseDomain to Rdbms namespace
Change-Id: Ifb06e792a36b5123ec3596933d0d394711ee5d08
2017-02-07 13:21:40 -08:00
Aaron Schulz
59053a0716 Move ChronologyProtector/TransactionProfiler to Rdbms namespace
Change-Id: I37a655bd8bd267c9bc32028b55925b2dce527d33
2017-01-26 10:30:57 -08:00
Seb35
ec215d010c Replace mocks of DatabaseMysql by DatabaseMysqli
The class DatabaseMysql corresponds to the PHP extension 'mysql' which is
deprecated since PHP 5.5, and the class DatabaseMysqli corresponds to the
PHP extension 'mysqli' which is the current MySQL driver. Given the class
DatabaseMysql is likely to be removed in the future, this change is a
first step towards this.

Bug: T120333
Change-Id: I7b8363838449cae09b360221d8f50ace3a008f11
2016-12-31 12:52:16 +01:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Aaron Schulz
508d3b21ea Remove unused Database::isView()/clearViewsCache() methods
Also make getLazyMasterHandle() protected.

Change-Id: Id6b48ff976a800052c22e90b572695ab3b8beb7e
2016-09-23 20:32:36 -07:00
Aaron Schulz
489330f4aa Set more FakeDatabaseMysqlBase fields in __construct()
Change-Id: I37a1e4aae186e19637817bd10be0d8fad06187d4
2016-09-21 21:07:24 +00:00
Aaron Schulz
69aa57ed91 Set the DatabaseDomain in some tests classes for sanity
Change-Id: I6531dc6cf89fbe7e5656354bcd4a27369f573752
2016-09-21 10:02:31 +00:00
Timo Tijhof
f6ce15ead3 phpunit: Simplify mock object syntax in includes/db/ tests
* Omit redundant `expects( $this->any() )`.
* Use willReturn() instead of `will( $this->returnValue() )`.

Change-Id: If90ac651748af8a78a720992240e40ba53cec79c
2016-09-15 01:47:18 +00:00
Aaron Schulz
46b029e17c database: Clean up profiling code in DatabaseBase
This cuts down on conditionals and ScopedCallback use.

Change-Id: Ie478c613b062e45120cdd626f9fb9de09594c638
2016-08-29 22:13:03 +00:00
Aaron Schulz
3675f1d447 Make Database disconnect and error suppression more robust
* Disallow $ignoreErrors in query() on deadlocks, since that would otherwise
  silently rollback all changes from any other callers.
* Move recoverability checks for disconnects to canRecoverFromDisconnect().
* The first write of a DBO_TRX transaction is now considered recoverable.
* Run onTransactionResolution() callbacks on disconnect/deadlock rollback.
  Some DeferrableUpdate need this to know to abort.
* Disallow $ignoreErrors on disconnects considered unrecoverable. This
  makes it so that query() callers cannot cause writes from other callers
  to be silently lost, which is hard to reason about.
* Moved ping() logic to simple reconnect() method and ping() simply do
  a dummy SELECT, which triggeres reconnection if safe. Previously,
  ping() might cause subtle partial transaction loss.
* Remove ping() from strencode(), which would cause partial transaction
  loss where it actually reached.
* Remove mysqlPing() per https://bugs.php.net/bug.php?id=52561.

Bug: T142079
Change-Id: Ifb7f772ae849d67c0d92240a115c3f392e252937
2016-08-11 07:26:33 +00:00
Aaron Schulz
d1337eadda Added GTID support to slave lag methods
The IDs will be included in MySQLMasterPos objects and,
if specified by config, in slave lag wait methods.

Bug: T135027
Change-Id: I1dfc0210b715b449ec07760c712d0267763f2697
2016-07-19 02:41:31 +00:00
Aaron Schulz
6e38db159c Support custom query in pt-heartbeat lag detection
Bug: T111266
Change-Id: Ib0f9ca8072d9becebacfa8c9afe9d61567f73912
2016-04-01 23:41:14 +00:00
Aaron Schulz
b64a178a21 Fixes to masterPosWait() for master switchovers
* Clean up return value types and docs.
* Handle master switch-over better w.r.t the job queue due
  to binlog name changes (the host portion). Previously the method
  would fail and trigger read-only mode when waiting on former
  master positions. Assume the the switch-over was done properly
  and thus return immediately.

Bug: T126436
Change-Id: Ib8c05a5c72d03a5c98e41b23c5653fc194b6d130
2016-03-08 03:37: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
Aaron Schulz
9c0b55d926 Make getLagFromPtHeartbeat() always use the LB cluster master entry
Before, it just used the immediate master entry, which could be another
slave. In that case, it may not even exists at all.

Bug: T119648
Change-Id: Iea970b81ad2c9855aafcccf0bb0662fc0b3a8d4d
2015-12-09 22:00:19 -08:00
Aaron Schulz
da4a378e74 Improve LoadBalancer::doWait() performance via APC
* This avoids bothering with MASTER_POS_WAIT() if an equal/higher
  position was already successfully waited on by another process.
* Add DBMasterPos toString() and hasReached() methods, which
  MySQLMasterPos already implemented and used.
* Moved more wfDebug() statements to the 'replication' log.

Change-Id: I423b5fe2da8d97889a6d204a635e351342de7649
2015-11-10 05:07:39 +00:00
Aaron Schulz
b11abb540f Fix DatabaseMysqlBase.php IDEA errors
* Declare base mysqlRealEscapeString()
* Fix MySQLField::tableName() return value

Change-Id: I1277166e741e69cb1c045b3baa6ed8de664e9255
2015-10-03 18:28:17 -07:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Timo Tijhof
ff6513f28b Remove '@section LICENSE'
This was used in 2 special classes, the logger classes and spread
to a few other random classes.

Afaik this has no meaning. Is for something we don't use, and
goes against the meaning of '@section' in Doxygen, which we do
use.

In Doxygen output, all LICENSE references became links to
ProfilerXhprof (the one Doxygen encoutered first).

Bug: T72328
Change-Id: Icc7c443245c70bc0f549bee7d105eef5691c864d
2014-11-26 02:20:55 +00:00
Siebrand Mazeland
1742e9448c Pass phpcs-strict on some test files (6/11)
Change-Id: I5f4bc0df8183cf338ff45cacfc7279c2cd38ee04
2014-04-24 18:26:19 +00:00
Kevin Israel
bc06a9b8b7 Abstract out mysql_field_type() call from DatabaseBase
DatabaseMysqlBase::fieldType() is used in the maintenance script
convertLinks.php for upgrading from MediaWiki 1.2 or earlier. This
script was failing when the mysqli extension was enabled.

Follows-up b1cc3511fd, b2d64432ee, and 00299ecb95.

Change-Id: I5d888f4dd344ecba15506023d35f6d2d6e24cfd8
2013-12-15 18:40:50 +00:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
Alexandre Emsenhuber
a222905098 Use the native set_charset() method if available instead of SET NAMES
According to the PHP manual, it is the recommended way to set the charset.

- mysql extension has it for MySQL >= 5.0.7
- mysqli extension has it for MySQL >= 5.0.6
or if using mysqlnd.

Change-Id: I8cd2f97fcad4b045c6f99ff894254847b13c6878
2013-11-16 07:57:52 +00:00
jenkins-bot
164f334e53 Merge "Cleaned up DatabaseBase constructor to use an array" 2013-11-07 19:36:22 +00:00
AlephNull
e9d53667f4 MySQL method to find out view + fix fatal in tests
We were missing a method to list out views defined in a database. This
patch adds in MysqlBase::isView() and MysqlBse::listViews().

Since listViews() cache its result in DatabaseBase::$allViews, we also
introduce a final DatabaseBase::clearViewsCache() to let us clear the
per process cache.

Finally, fixed fatal error when duplicating VIEWs in MySQL.

bug: 43571
Change-Id: I8650baa4b721fe69ea3e1d557dd76745c0c7754e
2013-11-07 09:43:59 +00:00
Aaron Schulz
58a0e0c06d Cleaned up DatabaseBase constructor to use an array
Change-Id: I094185585dc844ca4d2d8b629107b2ab8f9bef39
2013-11-06 12:17:15 -08:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
addshore
26e52f0c49 Add @covers for main Database test types
Change-Id: I010ff5ce7afd85c7f9d528a98f2448547874b8b3
2013-10-18 12:36:09 +02:00
Chad Horohoe
7d1cd6c376 Remove silly test cases that are likely to fail
Nobody should be giving objects or arrays to addIdentifierQuotes() anyway

Change-Id: Ibebf5d32196ac5b80cd477aedfef982fd2c9a0e6
2013-10-09 18:14:42 -07:00
Bryan Davis
cfde3c1958 Escape backticks when quoting MySQL identifiers
Previously mysql_real_escape_string() was improperly used which escapes
for inclusion in a plain string rather than an identifier.

Also adds basic test support for the DatabaseMysqlBase class.

Co-Authored by: Antoine Musso <hashar@free.fr>
Bug: 55427
Change-Id: Ic045e195c89d8d5d0f0edbda0cd1df781de7025c
2013-10-09 15:43:45 -06:00