Commit graph

1783 commits

Author SHA1 Message Date
mainframe98
1aa6cdab0e Remove $wgDBWindowsAuthentication
Follow up to 807d793, this setting is unused.

Bug: T230418
Change-Id: I3e27af725ec2f8f206e068f140a9cfdaafa523c7
2019-11-10 16:00:43 +01:00
jenkins-bot
4b6468ba66 Merge "rdbms: Restore debug toolbar "Queries" feature" 2019-10-15 18:29:02 +00:00
Timo Tijhof
2e404a2582 rdbms: Restore debug toolbar "Queries" feature
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
2019-10-11 20:04:05 +01:00
James D. Forrester
6898ba7232 Services: Convert MWLBFactory's static to a const now HHVM is gone
Change-Id: I2b5c77c304e03af31bc3f15f2e3f6002ca2f2647
2019-10-08 21:14:19 +00:00
Brad Jorsch
5424238aa9 Remove MySQL index aliasing for user_newtalk indexes
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
2019-09-27 09:30:31 +00:00
Brad Jorsch
f45441aaa7 Clean up ar_usertext_timestamp index mess
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
2019-09-18 11:49:02 -04:00
Aaron Schulz
1b57f6a81b Make ObjectCache check the value of apc.enable_cli in CLI mode
Add HashBagOStuff fallback for APC in MWLBFactory::injectObjectCaches.

Also fix APC-cache variable typo in MWLBFactory.

Bug: T227838
Change-Id: I71cb2ca58972ea09ab2f64f7e47bda7a5096c19b
2019-08-29 09:04:18 -07:00
Daimona Eaytoy
f18af0b61f Remove more Oracle and Mssql leftovers
Follows-up 4d10bb14e8 and 807d793ab9.

According to codesearch [0], these were the last usages. Note that this
patch leaves two constants in places, IDatabase::DBO_SYSDBA and
DBO_DDLMODE. These are public constants used "mostly for oracle" according
to the docs, but maybe we could find other use cases in the future (?).

[0] - https://codesearch.wmflabs.org/core/?q=oracle%7Cmssql&i=fosho&files=%5C.%5B%5Ej%5Cd%5D%7Cen%5C.json&repos=

Bug: T230418
Change-Id: Ibfb748b4b23b885a77f4de161af4bf2ab9649a89
2019-08-25 17:21:49 +00:00
Amir Sarabadani
807d793ab9 More clean up of oracle/mssql
Bug: T230418
Change-Id: I1ff01548e55f01f9419668e31d5aa7dd03d23258
2019-08-14 17:04:50 +02:00
Amir Sarabadani
4d10bb14e8 Drop Oracle and Mssql
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
2019-08-14 11:31:41 +00:00
jenkins-bot
436f8eb32f Merge "rdbms: remove various deprecated methods" 2019-07-26 15:16:38 +00:00
Aaron Schulz
4c7e4575f5 rdbms: remove various deprecated methods
Change-Id: I5ae923065a08078225b7df080cb92edca799ebaf
2019-07-26 15:56:02 +01:00
Aaron Schulz
023c73f612 rdbms: normalize Database open() code and error handling
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
2019-07-26 15:24:28 +01:00
Aaron Schulz
c351a9cab0 rdbms: cleanup some Database error message wording for consistency
Change-Id: I7b338e6e856c62ecaab2ef97f76431c2220b430d
2019-07-11 21:37:54 +00:00
jenkins-bot
623264e2cf Merge "rdbms: fix typo and clean up some cruft in MWLBFactory" 2019-07-04 22:30:27 +00:00
Aaron Schulz
237dd3f142 rdbms: fix typo and clean up some cruft in MWLBFactory
Change-Id: Ib51dfee9ed06326a8b3acfed136e75b13fc4e234
2019-07-04 18:55:19 +00:00
Aaron Schulz
a830c14d0b rdbms: make implement IResultWrapper directly instead of via inheritence
Change-Id: If1b15c0c21d0ee336025fb99f47fc19ddf1d5435
2019-07-04 13:42:53 +00:00
Aaron Schulz
23ffabbf77 rdbms: combine trxLevel and trxShortId fields in Database
This avoids having to keep multiple fields in sync

Change-Id: If96267afe56a9b9cd660bab333e7667e4d8dc3d4
2019-06-28 14:40:27 -07:00
Aaron Schulz
7911da9c6f rdbms: remove $opened field from Database for simplicity
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
2019-06-27 18:29:12 +01:00
Umherirrender
348a784f48 Adjust type hints in database related classes
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
2019-06-05 19:10:13 +02:00
jenkins-bot
5ecb8b3ac6 Merge "Fix some docs" 2019-05-22 20:43:56 +00:00
Matěj Suchánek
68e8323160 Fix some docs
Discovered by phan.

Change-Id: Iadc2b151db6922f3159f061f10408d45636967c5
2019-05-22 21:50:52 +02:00
Aaron Schulz
e0cc49ce39 rdbms: improve query logging logic in Database
* 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
2019-05-08 14:58:10 -07:00
Aryeh Gregor
18ec468633 Don't pass Config to service constructors
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
2019-05-02 11:33:56 +03:00
Derick Alangi
70cafa4eed db: Use $fname instead of __METHOD__ magic constant
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
2019-04-15 16:05:31 +01:00
Aaron Schulz
2775ad190c rdbms: drop inappropriate and poorly documented "DatabaseOraclePostInit" hook
Change-Id: I3152e80d99b040b7918927e6c2a215cab59a9b10
2019-04-12 14:41:44 +00:00
Aaron Schulz
ff181a3c4e rdbms: inject reserved word table name rewrite logic into DatabaseOracle
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
2019-04-11 22:25:08 +00:00
Aaron Schulz
e40d52557e rdbms: inject more dependencies into DatabaseOracle and remove $wgContLang use
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
2019-04-11 04:48:44 +00:00
Aaron Schulz
208d89543d rdbms: reduce code duplication and make LBFactoryMulti sanity checks work
Change-Id: I2308719b3a8fe4745c86dc7e5af0950588732ebe
2019-04-10 17:19:55 +00:00
Aaron Schulz
0136ebe603 Use HTTP method as hint for the locking mode of sqlite
Bug: T93097
Change-Id: I4aa44345e2f9e252c1a351f252bdcb9e15f180a5
2019-04-04 01:35:15 -07:00
Aaron Schulz
a8447a337b Replace several uses of wfWikiId() with WikiMap methods
Also, reword some related comments.

Change-Id: I8aefa42f96b90e9ea871cf7ec1afcc7ed82a19b2
2019-03-29 14:56:18 -07:00
jenkins-bot
87ef000cf4 Merge "Make MWLBFactory sanity check that postgres is not used with a table prefix" 2019-03-26 20:18:42 +00:00
Aaron Schulz
b9a8ba3b06 rdbms: remove $wgDBprefix reference from DatabaseOracle
Rely on MWLBFactory as other DB classes do

Change-Id: I33d535c659626dd42c9cb8d20c1a0fc90a885c8c
2019-03-26 11:44:17 -07:00
Aaron Schulz
b88896d6cd Make MWLBFactory sanity check that postgres is not used with a table prefix
Change-Id: If0c75a042c0e85d4f124be2204cdd52fcd602932
2019-03-25 23:09:32 -07:00
jenkins-bot
7dddd2f7e2 Merge "db: Use variable functions/callbacks instead of call_user_func()" 2019-03-26 05:41:52 +00:00
jenkins-bot
e73b5913ea Merge "DefaultSettings: Remove deprecated $wgDBmysql5 from core" 2019-03-25 14:45:20 +00:00
Derick Alangi
d656baac64 db: Drop child methods as they're same as parent methods
Change-Id: I8b3827a57782f02497da2ab8191d1dad11e92bca
2019-03-25 00:29:22 +01:00
Derick Alangi
a7d1ad4d24 db: Use variable functions/callbacks instead of call_user_func()
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
2019-03-25 00:17:22 +01:00
Aaron Schulz
0449f653c7 Fix overzealous prefix check in MWLBFactory
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
2019-03-23 20:08:01 -07:00
Derick Alangi
26118ad094 DefaultSettings: Remove deprecated $wgDBmysql5 from core
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
2019-03-23 14:52:33 +01:00
Aaron Schulz
9df277a4ba rdbms: halt on some common broken $wgDBServers configurations
Mention the changes, usually simple, needed to fix the problem.

Bug: T215850
Change-Id: I9911f5f5213682ffb52ac548e3082db548e37b3d
2019-03-22 08:04:48 +00:00
jenkins-bot
e49122d07e Merge "db: Remove property assignment overriden by constructor" 2019-03-20 19:35:07 +00:00
Derick Alangi
e552f30253 db: Use brackets () in operation for better readability
Wrap the expression into () to improve readability of the code.

Change-Id: Id53ea4709a7601fd1354833a44bd652570c733e6
2019-03-20 19:02:06 +01:00
Derick Alangi
7efdf701ba db: Remove property assignment overriden by constructor
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
2019-03-20 18:38:26 +01:00
jenkins-bot
e895217711 Merge "rdbms: change "profiler" argument in Database::factory so it works again" 2019-03-15 00:02:35 +00:00
Aaron Schulz
b438db9e2c rdbms: change "profiler" argument in Database::factory so it works again
The Profiler::profileIn and Profiler::profileOut methods are just stubs.
Use a callback to the Profiler::scopedProfileIn method instead.

Change-Id: I16068bce583bb880250fe91235f2283453be5e4c
2019-03-14 22:19:58 +00:00
Aaron Schulz
f41a0837a9 rdbms: clarify $uniqueIndexes argument to replace()/upsert()
Also make upsert() match replace() for consistency.

Change-Id: I208f3ab810a61c6949ac0050436767675f99a60b
2019-03-12 20:09:21 -07:00
Thiemo Kreuz
cfda5e7efa Streamline code involving .= string concatenations
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
2019-03-11 12:43:45 +01:00
Fomafix
f17c297624 Use short assignment operator in PHP
Use
  $var .= $foo
instead of
  $var = $var . $foo

Change-Id: I5dcdd7278e618c14968e5ac1fb8ea43ac2200deb
2019-03-07 09:55:49 +01:00
Aaron Schulz
6ab386219e rdbms: document Database::doQuery() return value
Removed random @throws tag from a subclass while at it

Change-Id: I1cad1f66b62bb4a306feb5c773ed5556891f82a7
2019-03-01 02:23:27 +00:00