Commit graph

392 commits

Author SHA1 Message Date
Brian Wolff
528042054f Fix some phan-taint-check false positives
Change-Id: Ic5ccbb3f97722476bee7188b83b80cdc652d2a64
2018-09-21 17:27:44 -07:00
Umherirrender
acb2e720d8 Pass delimiter to preg_quote
This ensure that the regex is escaped correctly,
even when the quoted value never contains the delimiter

Change-Id: I2dc93fa0154d4506c276a30cab008bc2ac5e0687
2018-09-01 14:52:16 +02:00
jenkins-bot
badc95193a Merge "rdbms: fix a few IDEA warnings in Database" 2018-08-22 05:06:36 +00:00
jenkins-bot
da748c3a91 Merge "rdbms: fix IDEA warnings in DatabaseMssql.php" 2018-08-22 05:01:43 +00:00
Aaron Schulz
8053bc9e0d rdbms: fix a few IDEA warnings in Database
Change-Id: I1bdca5c643ff81eb822443b8e45f71f5f3fb2155
2018-08-21 21:25:48 -07:00
Aaron Schulz
2b5e59fad1 rdbms: fix IDEA warnings in DatabaseMssql.php
Change-Id: Iffef01cfac4c714c768190e375bc873a2d3eaf2f
2018-08-21 20:14:26 -07:00
Aaron Schulz
41a37d14fa rdbms: make Database::open() protected
This is not called externally and there is little reason for that to
change. The current caller pattern is to use factory(), possibly with
initConnection() afterwards, or to use a LoadBalancer to begin with.

Change-Id: Ib1fdd5c960f1ed877fcd17bcb99b999d5d894716
2018-08-21 18:34:51 -07:00
jenkins-bot
7da455154e Merge "rdbms: use Database::getDomainId for transaction logging calls" 2018-08-16 05:54:35 +00:00
jenkins-bot
cab845c8a1 Merge "rdbms: Disable DBConnRef::selectDB() for sanity" 2018-08-16 04:33:58 +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
Aaron Schulz
5358c41e86 rdbms: use Database::getDomainId for transaction logging calls
Change-Id: I360ca633b145dc8e510bb00b542ac44933283943
2018-08-15 01:29:39 -07:00
Aaron Schulz
5891967297 rdbms: Disable DBConnRef::selectDB() for sanity
Bug: T193565
Change-Id: I4276d1a7d77a019e0e60dab4b9ec36c93e418037
2018-08-15 03:03:51 +00:00
Aaron Schulz
d9fdc4098b rdbms: Avoid numRows() warnings for mysqli after table creation
Bug: T201900
Change-Id: Ie86a7b8e680d79ad3f9be6ca4ec260b0589e5d0e
2018-08-14 18:52:27 +00:00
Fomafix
0a0d5cb7f7 Fix typos
Bug: T201491
Change-Id: I25a27d11faabe2f5fa02950c7a4fb58b13fb3662
2018-08-14 09:52:19 +00:00
Aaron Schulz
f3a197e49b rdbms: add "maxReadRows" limit to TransactionProfiler
Change-Id: I008fc1857c7aa43d93f43361803d5e52c4ddf089
2018-08-13 13:30:08 -07:00
Aaron Schulz
ff7edd1038 Clarify IDatabase docs for upsert() and replace()
Change-Id: I0f23a77ba0837684c2151c33b9e93046dbc73b48
2018-08-01 10:34:17 -07:00
Tim Starling
7584bf22fb Fix total breakage of SQLite web upgrade
Partial revert of 8d61cf2793, since LBFactoryTest.php passes without
overriding selectDB() in the current master. It's unclear why it was necessary.

Bug: T200861
Change-Id: I7c0560d7890616899297f81a227db98996d5cb7f
2018-08-01 10:21:25 +10:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
Aaron Schulz
e73f4a21f5 rdbms: give TransactionProfiler write time and row count for ROLLBACK
This will hopefully provide more diagnostic info when DBTransactionSizeError
rollbacks are triggered.

Bug: T190260
Change-Id: Ib8bea5a9ec7d3ffeaf423adb930dc6fb14314449
2018-07-18 18:03:46 +00:00
jenkins-bot
216865344b Merge "rdbms: add IDatabase::lockForUpdate() convenience method" 2018-07-11 19:52:31 +00:00
Aaron Schulz
9eff263e8e rdbms: add IDatabase::lockForUpdate() convenience method
Change-Id: I238fd96407e1122e90058e2c4acf743044a267ec
2018-07-10 20:09:01 +01:00
jenkins-bot
c07b08b36c Merge "Avoid deprecated IDatabase::getWikiId() reference" 2018-07-07 23:07:45 +00:00
Aaron Schulz
86dd3b0ac0 Avoid deprecated IDatabase::getWikiId() reference
Change-Id: I26991079b1630335c8a6e907554760fc85c1bad6
2018-07-07 22:55:15 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
jenkins-bot
4b5773a4de Merge "rdbms: fix Sqlite::tableExists() method to avoid STATUS_TRX_ERROR" 2018-07-03 05:40:03 +00:00
Aaron Schulz
d16bfb0a30 rdbms: fix Sqlite::tableExists() method to avoid STATUS_TRX_ERROR
Sqlite used the base implementation of trying a SELECT 1 query and
seeing if it failed. Instead, make it use the sqlite_master table.
Also remove the base version of that method since it would always
cause this problem and all subclasses have proper implementations.

Make LoadBalancerTest::assertWriteAllowed() more explicit and add
more assertions there.

Change-Id: I6c7b0bea8894c45dfe8931748d6687f0e5d1e101
2018-06-22 22:33:45 +00:00
Niklas Laxström
0e1566505f Fix typo in method documentation
Change-Id: I891f9725acfac993966238abff255e59e9aee07a
2018-06-14 10:47:08 +02:00
Max Semenik
1e680456b4 Get rid of call_user_func(_array)(), part 3
Also cleaned up nearby code in a couple places.

Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
2018-06-10 02:21:24 +00:00
jenkins-bot
5a6c78c441 Merge "Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient" 2018-05-31 19:01:07 +00:00
Tim Starling
25503cf011 Maintenance script to wrap the mysql binary
This is more or less equivalent to the WMF shell script "sql", but it is
reasonably portable and written in a less hackish way.

Change-Id: I240d8d4e65ce46680cac257ee376a9b026c13f92
2018-05-31 15:42:51 +10: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
jenkins-bot
b6e8e6b832 Merge "rdbms: make runOnTransactionIdleCallbacks() reset DBO_TRX on exceptions" 2018-05-30 21:47:27 +00:00
jenkins-bot
9da597821b Merge "rdbms: do not silently rollback empty transactions on error" 2018-05-30 19:19:22 +00:00
Aaron Schulz
0b5ed025e9 rdbms: do not silently rollback empty transactions on error
Since there might be important view snapshots, temp tables, or effects
from SET statements or the like, go into TRX_ERROR state for "possible
transaction level errors" even if no recognized writes took place and
the transaction was not explicit.

Change-Id: I32c34bc28b845e343d0167a220412824838eaed8
2018-05-30 03:10:02 +00:00
Reedy
ab85b17368 Add @deprecated tags to DatabaseBase
It was there in REL1_27, but REL1_28 Database was the default...

Bug: T195576
Change-Id: I06d3a48c3112da95f38bb7f6a055fe7682e03096
2018-05-29 22:38:49 +01:00
Reedy
765370a6db Add @deprecated tags to various class_alias calls
Bug: T195576
Change-Id: I10cd8415891bfe4a278eee06c9cfe905b3e036dc
2018-05-29 13:10:20 -07:00
Aaron Schulz
b172aff090 Avoid PHP 7.2 warnings in DBConRefTest about count() on non-Countable
Change-Id: Ida81bf998b462f2f6bb2b708df1f15bbc1933db1
2018-05-25 17:29:17 -07:00
Aaron Schulz
8880a25112 rdbms: make runOnTransactionIdleCallbacks() reset DBO_TRX on exceptions
Change-Id: Ibbb2a3ebf9dd970772ee704aa643a3843f20a3b5
2018-05-25 23:40:47 +00:00
Aaron Schulz
b6cd5421b9 rdbms: rename onTransactionIdle() to onTransactionCommitOrIdle()
This is clearer and is consistent with onTransactionPreCommitOrIdle()

Change-Id: I3a34a0e9adea69ec55ed6ddfef47703e31e7c3b5
2018-05-09 21:07:06 +00:00
Aaron Schulz
082ed053b6 rdbms: fix finalization stage errors in LBFactory::commitMasterChanges
If a pre-commit callback caused a new LoadBalancer object to be created,
that object will be in the "cursory" state rather than the "finalized"
state. If any callbacks run on an LB instance, make LBFactory iterate
over them all again to finalize these new instances.

Make LoadBalancer::finializeMasterChanges allow calls to
already-finalized instances for simplicity.

Bug: T193668
Change-Id: I4493e9571625a350c0a102219081ce090967a4ac
2018-05-07 18:04:43 +00:00
Aaron Schulz
b32325bd23 rdbms: improve log warnings in runMasterPostTrxCallbacks()
Bug: T191282
Change-Id: Iba663c58224af920f90d7b401aab2eb21f921941
2018-05-01 13:24:39 -07:00
Aaron Schulz
5bfa77f8d9 rdbms: enforce and improve LBFactory/LoadBalancer callback handling
* Handle the case where an onTransaction* callback for one handle
  adds more onTransaction* callbacks to a different handle. Instead
  of supporting only a short chain of such callbacks, try to resolve
  the whole chain by using a loop in LoadBalancer and LBFactory.
* Add sanity checks to enforce the proper call order of LoadBalancer
  transaction methods, such as those that execute callbacks. This is
  the order that LBFactory already uses. Use ROUND_ERROR for problems
  that can ruin the instance state. Such problems require rollback.
* Correct setTrxEndCallbackSuppression() calls in beginMasterChanges()
  that were making tests fail.
* Make Database handle callback suppression for FLUSHING_ALL_PEERS
  instead of making LoadBalancer/LBFactory have to manage it.
* Simplify finalizeMasterChanges() given that suppression does not
  actually effect runOnTransactionPreCommitCallbacks().
* Make dangling callback warning in Database::close work properly.
* Actually use $fname in flushReplicaSnapshots().
* Use DBTransactionError instead of DBExpectedError in some places
  where stages fail.
* Fix failing testGetScopedLock() unit tests so everything passes.

Add more comments to setTransactionListener and onTransactionIdle.

Change-Id: I6a25a6e4e5ba666e0da065a24846cbab7e786c7b
2018-04-30 21:55:25 +00:00
jenkins-bot
878c986f3a Merge "rdbms: Replace reportConnectionError() with direct throws" 2018-04-26 20:00:12 +00:00
Timo Tijhof
c7fc4ef9bf rdbms: Replace reportConnectionError() with direct throws
When reading through DatabaseMysqlBase::open(), it was not
obvious that execution would not continue after the conditional
`!$this->conn` block, given it ends in a method call, without
return or throw. I considered adding a return statement after it
for clarity, but it seems in this case it might make more sense
to throw directly given $error here has already gone through a
fallback to getLastError() a few lines up.

Replace the other three calls to reportConnectionError() as well,
which previously passed a useful string that was overwritten
with lastError(). Instead, log both. And make their call to
queryLogger->error() match the previous ones to have an 'error' as well.

This leaves reportConnectionError() as being unused, except for
a call from LoadBalancer. That call was problematic because
it was inside a conditional for IDatabase, but the method isn't
part of that interface. Replace it with a direct throw as well.

Deprecate the method as its now unused in core, and also remove its
'# New method' comment which hasn't made sense since r75341 (16cded8b32).

Change-Id: I0f2ef00ba44bf7090a3ce54edeb8c7e8e543e46a
2018-04-26 04:25:17 +00:00
Aaron Schulz
c8085ad43f rdbms: make IDatabase::onTransaction* methods pass the DB handle for convenience
Change-Id: Ia45a26830d62326b103593268fbf34c907783c90
2018-04-24 16:45:11 -07:00
jenkins-bot
984381d6d9 Merge "rdbms: make select() warn when FOR UPDATE is used with aggregation" 2018-04-23 20:01:13 +00:00
Aaron Schulz
b992b3aea5 rdbms: make select() warn when FOR UPDATE is used with aggregation
Using FOR UPDATE or LOCK IN SHARE MODE with aggregation leads to
query errors with PostgreSQL.

Bug: T160910
Change-Id: Iaed964e7e59468365cbc62cb4bfd3ad44b898452
2018-04-20 03:42:26 +00:00
jenkins-bot
d6d9e4e3a7 Merge "rdbms: correct atomic section examples in comments" 2018-04-19 20:19:45 +00:00
jenkins-bot
a7c2042234 Merge "rdbms: make cancelAtomic() handle callbacks and work with DBO_TRX" 2018-04-19 20:14:21 +00:00
Aaron Schulz
20777d7399 rdbms: make cancelAtomic() handle callbacks and work with DBO_TRX
Make transaction callbacks aware of cancelled sections. If the
statements of a section are reverted via cancelAtomic(), then the
dependant callbacks are now cancelled as well. Any callbacks for
onTransactionResolution(), which does not depend on COMMIT, will
see the triggering event as a ROLLBACK, since the unit of work it
was part of was rolled back.

Also fix the handling of topmost atomic sections with DBO_TRX.
These still need their own savepoint to make cancelAtomic() work.

Follow-up to 52aeaa7a5.

Change-Id: If4d455c98155283797678cfb9df31d5317dd91a2
2018-04-19 12:43:01 -07:00