This broke after e0cc49ce39, due to the field 'master'
being removed from the log context. The LegacyLogger logic
forwarding these messages to MWDebug (for the debug toolbar)
however, was dependant on.
Users of debug toolbar experienced a silent failure because the
logic in question is very tolerant of missing fields. This is
because it uses those fields to distinguish the 'sql' messages
from channel=DBQuery from other messages in the same channel.
Making that less fragile is outside the scope of this commit.
This commit:
* Restore the basic functionality by making sure MWDebug::query()
gets called again for DBQuery messages.
* Remove the code relating to the 'master' field as this no longer
exists in RDBMS. It also wasn't used anywhere (to be used,
it would need to be read by mediawiki.debug/debug.js).
* Remove unexpanded "{method}" and "{runtime}" noise in the debug
toolbar text. This was introduced by he conversion to PSR-3
logging.. These fields are already rendered separately by
the toolbar and should not be part of the "SQL" column.
To do this, we need to log the $sql bit as its own key, so
I've made this a context field as well.
* Reduce the condition logic in LegacyLogger to only looking for
'DBQuery' and 'sql'. This way, if it breaks again it will
still call the logic within and emit E_NOTICE instead, which
would help detect the issue (and still fallback to at least
showing the queries). Unlike before this commit where it took
quite some time to figure out why it wasn't working.
* The above fixes still weren't enough to get queries to show
up in the Debug toolbar for me. Turns out, this was because
my local setup (mediawiki-docker-dev) uses a master-replica
set up. The setup doesn't use any custom LBFactory config,
just plain $wgDBservers. The logic for turning these plain
settings into LBFactory (in MWLBFactory.php) does kick in,
and does run (unlike if I had custom wgLBFactoryConf).
But, the DBO_DEBUG flag didn't make it through because of
the += operator preferring any pre-existing value my setup
has, which is just `DBO_DEFAULT`.
Merging 'flags' keys seems unsafe in general, but adding
DBO_DEBUG based on $wgDebugDumpSql seems innocent and doesn't
affect other behaviour (it's a case of DWIM).
Bug: T231742
Change-Id: I122bb1a65620a7ae4e1943136c975b63524a5111
While these have not yet caused problems, we should probably deprecate
the whole confusing "index aliasing" feature. Cleaning this up needs to
be done first.
Method MWLBFactory::setSchemaAliases() is being considered private due
to the @internal notation, and so is being removed without deprecation.
Bug: T233240
Change-Id: Ib04b7bc4af53382fde01bd8550cc7e361124255f
See T233221 for the sordid history. The short version is that it might
exist as `ar_usertext_timestamp`, `usertext_timestamp`, or both on
MySQL, so dropping it for the actor migration needs to drop both names
if they exist.
We can also remove the now-obsolete aliasing from MWLBFactory.
Bug: T233221
Bug: T104756
Bug: T229712
Change-Id: I429e7ade2c86a2514aafe947012f096b03aa67ce
Add HashBagOStuff fallback for APC in MWLBFactory::injectObjectCaches.
Also fix APC-cache variable typo in MWLBFactory.
Bug: T227838
Change-Id: I71cb2ca58972ea09ab2f64f7e47bda7a5096c19b
After approval of RFC T191231, we are going to drop oracle and mssql
and it will be possible to bring back the support using the abstract schema
Adding to release notes will be done in a follow-up
Bug: T230418
Change-Id: I90bd5cfcc3e18011b193c965fdb1fa54675040b5
Mainly:
* Use oci_new_connect() for Oracle to avoid broken connection reuse
similar to the PGSQL_CONNECT_FORCE_NEW flag in DatabasePostgres
* Set 'client_min_messages' unconditionally for PostgreSQL
* Factor out Database::getConnectExceptionAndLog() helper method
* Use the same style of query() calls in DatabaseOracle::open() as
the other subclasses
* Make sure the Database driver handle field is null on failure
instead of false for sanity
Also:
* Disallow changing of Database handle DBO_* flags after construction
where it does not make sense to change them
* Do not mention DBO_* flags meant for non-config use in $wgDBservers
* Ignore DBO_PERSISTENT for SQLite if DBO_TRX is also set for sanity
* Remove $wgDBOracleDRCP variable to discourage careless automatic
setting of DBO_PERSISTENT that breaks LoadBalancer assumptions
Change-Id: Iea948f7f872294ea8fc5d897fc10c9d29b7141d5
This avoids having two similar fields that have to stay
in sync. Clean up the related error handling for connections.
If a connection handle is unusable, like when essential SET
queries fail, then destroy it.
Also:
* Avoid use of transactions in DatabasePostgres::determineCoreSchema.
* Make sure all subclasses log on connection failure.
* Add schema sanity checks to mysql/sqlite classes.
* Add IDatabase::QUERY_NO_RETRY flag to simplify reasoning about
queries that already run on open() to begin with.
* Remove unused return value of Database::open.
* Remove deprecated Database::reportConnectionError method.
Change-Id: I97beba7ead1523085bda8784234d00c69ef1accc
Change from ResultWrapper to IResultWrapper
Change from mysqli_result to resource
Changed mixed to return hint of interface
Document that fieldInfo returns bool
Change-Id: I5572fd41e0e11a2bc2eb116d0c82327499ecc518
* Merge the two debug() calls in attemptQuery() into one single
call which checks DBO_DEBUG. This avoids pointless SPI logger
overhead.
* Avoid calling generalizeSQL() unless actually necessary. This
works via a lazy-loading object.
* Make lastQuery() a bit more consistent in terms of when it
gets updated.
* Add DBQueryDisconnectedError class for dropped connections.
* Clean up visbility and names of last query/error fields.
Change-Id: Ie8df3434d23b18f7a0f4c056d71388192cc52c6b
We don't want to depend on the entire site configuration when we only
need a few specific settings.
This change additionally means that these services no longer see a live
version of the settings, but rather a copy. This means in tests you
really do have to call overrideMwServices() if you want services to pick
up your config changes.
ResourceLoader and SearchEngineConfig will need more work to port,
because they expose their member Config in a getter, and the getter is
actually used.
Parser and NamespaceInfo are also relatively complicated, so I split
them into separate patches.
Tested with 100% code coverage. \o/
Depends-On: If6534b18f6657ec1aba7327463f2661037f995b3
Change-Id: I1a3f358e8659b49de4502dc8216ecb6f35f4e02a
The insert() method calls insertOneRow() method on line 391. It then
passes $fname which defaults to __METHOD__ in its function header and
not using $fname instead of __METHOD__ in insertOneRow() method makes
this parameter unused which of course should be used.
Change-Id: Ic5f5ee878e4f919a96900ba88755641ac85929df
This works similar to that of DatabasePostgres, which uses similar rules.
Fix bogus field access in duplicateTableStructure() as well.
Also, remove a pointless wfDebug() call in DatabaseOracle.
Change-Id: Ia06ff78011dfabc17c525d7a6d2ffad98fe297de
Instead of guessing/assuming input encodings for non-UTF8 fields,
just require that they be valid UTF-8 to begin with.
Also replace MWException use and break some long lines.
Change-Id: Ibb6f841d5d143776eca2a9d0d12cbb74f1e0d23e
Performance-wise, this gives a little boost in performance and also
it's more readable I think. But I could be wrong so please someone
let me know.
See: https://www.php.net/manual/en/function.call-user-func.php
Change-Id: I2f0a00408c29549a786b56792411f88998a5f003
Follow-up 9df277a4ba
If the server array ommitted 'tablePrefix', Database will
use '' as the prefix, so if $wgDBprefix is also '', then
no error should happen.
Change-Id: Ic207c3fceae8fd45c87f7fa24678079217a60730
This was an experimental configuration setting and was supposed
to be removed in 1.33. Also, remove option from db.
Bug: T196185
Change-Id: I357348505589ff963d668acadce3b58fe2a1b0bb
As these class properties are overriden by the class constructor,
we can safely remove them. In addition, remove a useless "/" in a
PHPDoc.
Change-Id: I9cecfc8a0e5b58c931ee32c7465c064a9add1a77
The Profiler::profileIn and Profiler::profileOut methods are just stubs.
Use a callback to the Profiler::scopedProfileIn method instead.
Change-Id: I16068bce583bb880250fe91235f2283453be5e4c
This was inspired by Idbbdb31. Originally, I did a regex search for
code that did string concatenations like `$str = $str . …` and replaced
them all with the .= operator. A duplicate patch was uploaded by another
author. I rebeased this patch on top of the other, which leaves all
the manual optimizations I did.
Change-Id: Iaeb73d9c63302c9409bd1051b91e0d2bd77788a7