Commit graph

54 commits

Author SHA1 Message Date
Aaron Schulz
d2e1734390 rdbms: rename setDomainPrefix to setLocalDomainPrefix in ILoadBalancer
Update CloneDatabase and unit test callers, which are the only things
that are likely to call it.

Change-Id: Idbc6d2965cd3828c2c6d23012319bbf0fc3ffa4a
2018-11-26 10:38:15 -08:00
Umherirrender
e3db33c615 Throw exception when nothing to clone in CloneDatabase
Just in case something goes wrong, when calling.

Change-Id: I4490aee6edccf0b185188250948a47b5fd8ba766
2018-08-24 21:28:01 +00:00
jenkins-bot
ef97002179 Merge "Simplify PHP by using ?? and ?:" 2018-07-11 09:09:18 +00:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
daniel
6cfdbdf60e Add support for extra database connections in unit tests.
This adds a way to take any connection to the wiki database and
allow it to be used for unit tests.

This is needed to test code that requires two independent DB
connections, to the same database or to a different wiki's database.

Change-Id: I0b84a0c4d174cbde830786028ee7568c4ea9fb5d
2018-07-04 19:07:45 +02:00
daniel
047151c692 Introduce DB schema overrides for unit tests.
This introduces MediaWikiTestCase::getSchemaOverrides,  which can be overwritten
to return information about which tables are going to be altered, and which SQL
files should be used to set up the target schema. This allows tests for a class
that interacts with the database can have a subclass for each supported database
schema.

NOTE: this has only been tested with MySQL.

Bug: T180705
Change-Id: I7a4071072d802a82ecf7d16fbf8882ff8c79287f
2018-01-05 16:23:55 +00:00
Chad Horohoe
e7c86d8537 Remove some dumb headers with my name in it
Change-Id: Ib34b623b47fb92f1383bc5c55c50a16dd6d49abd
2017-11-30 15:39:46 -08:00
Thiemo Mättig
91a920fd85 Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

This is similar to I994d11e. Even more trivial, because this here is
about comments that don't say anything but "constructor".

Change-Id: I474dcdb5997bea3aafd11c0760ee072dfaff124c
2017-07-21 12:19:30 +02:00
yoonghm
b620b4a254 Remove exception and drop cloned tables in PostgresSQL too
In PostgresSQL
a) Temp tables are automatically deleted upon end of session
b) Same temp table name hides existing table for current session

It is not necessary to consider 'postgres' during dropping of table.
I guess similar logic for Oracle but I could not verify.
It seems that no one use Oracle for MediaWiki.

Bug: T113445
Change-Id: I37b5483a6e9abe5cda0d4dfc103c287641f277a7
2017-06-13 19:31:06 +02:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
James D. Forrester
9635dda73a includes: 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: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Aaron Schulz
fe59c39da9 Add LoadBalancer::getMaintenanceConnectionRef() method
This is useful when IMaintainableDatabase methods are needed
for foreign wiki connections to things like external store.

Also:
* Set visibility for ExternalStoreDB methods.
* Cleaned up various type hints and comments.

Change-Id: Ie35b1ff21032cc4e78912dc499486da23aeba041
2016-12-10 15:35:09 -08:00
Aaron Schulz
86ce9b388a Fix IDEA warnings in CloneDatabase
Change-Id: I45231237dd49dfdd8158a68d8f63d769b762f19c
2016-09-21 11:20:22 -07:00
Aaron Schulz
32c7a9bf46 Make LoadBalancer domain handling more robust
* Cleanup setDomainPrefix() methods to handle existing LBs/DBs.
* This also makes it set just the prefix as the prefix rather
  than as the whole domain.
* Fix regression from 789a54a5f1 where "read" mode of
  tablePrefix()/dbSchema() still set the field.
* Make getConnectionRef() always have the domain set.
* Add a check in openConnection() for explicit local
  connections, treating $domain as false and avoiding
  openForeignConnection().

Bug: T145840
Change-Id: Idf392bd9992a215c4fa3bddf275562f3916596aa
2016-09-17 02:31:13 +00:00
Aaron Schulz
0e5cd18b74 Rename LBFactory => LBFactoryMW and make LBFactory in /libs
The former extends the later with MW-specific logic.

Also removed a wf* method call from ChronologyProtector.

Change-Id: I325f59b7467ab9c2137731d1ce69816f5a020f03
2016-09-15 17:14:32 +00:00
Aaron Schulz
272f45a8a0 Change DatabaseBase => IDatabase in /db where possible
Change-Id: Ia0a049cd4294c5a39aa9ed228d4eb5b15736ea1f
2016-09-14 19:31:51 -07:00
Aaron Schulz
4be70af8c6 Replace some MWExceptions with natives ones in /db
Change-Id: I94532d09216926d401e94c61acd60fdc6241a2a0
2016-09-14 01:50:33 -07:00
Aaron Schulz
bac2fa4503 Various dependency injection cleanups to LoadBalancer
* Inject wfWikiID() and MWExceptionHandler into LoadBalancer.
* Factor out LBFactory duplication into baseLoadBalancerParams().
* Remove $wgDBtype hack. Presumably, sites with others DBs would
  not have multiple servers configured if does not work anyway.
* Make use of injected TransactionProfiler rather than calling
  Profiler::instance()->getTransactionProfiler().
* Avoid use of trivial wfSplitWikiID() function.
* Make DBConnRef enforce its arguments more strongly and
  optimize getWiki() to avoid causing a connection attempt.
* Avoid deprecated method call in LBFactory::destroyInstance().

Change-Id: If134b62d4f48cd68cb48ccbe149e72f12aa26819
2016-09-13 23:57:30 +00:00
Chad Horohoe
dca7653437 CloneDatabase: Simplify callback structure
Change-Id: I4d5184fd7417e61e9a111bd414f8c62539229ef9
2016-08-23 12:16:01 -07: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
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Brian Wolff
8e98f9e3e6 Double check its safe before dropping new table during db cloning
parserTests.php just killed my user table :(

Bug: 65654
Change-Id: Idcf1c6af6a513c9e6dc650237863db8d61519886
2014-06-25 10:56:53 +00:00
Brian Wolff
0b32b01adb Make CloneDatabase error out on shared tables.
Due to the way prefixes are handled, this doesn't work properly.

Make it quit early to prevent confusion. I don't think there's
many people who need shared table support, so I don't know if
its worth the effort to actually fix.

Bug: 65654
Change-Id: I6cd701998fc9066d8c7a4fc86d93a4282cc7f9bd
2014-06-19 09:36:12 +00:00
Alexandre Emsenhuber
449ee32451 Add missing line breaks to wfDebug() calls
Also removed true as second parameter to it from CloneDatabase.php
since it is the default value of that parameter.

Change-Id: I727ebae2bd4df0e26019985ce8c7ce73381c5642
2014-03-29 11:52:07 +01:00
Ladsgroup
1ba0445c12 Changing URLs of mediawiki.org in scripts to the SSL-based website
http://www.mediawiki.org --> https://www.mediawiki.org

Part 2

Change-Id: I3be61fe3dfb502cc20180486eb1a8016eac151df
2014-03-12 23:24:03 +00:00
Siebrand Mazeland
e22a70a103 Update documentation for database related classes
Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f
2014-01-06 19:45:40 +01:00
Siebrand Mazeland
b547395796 Break long lines and formatting updates for includes/db/
Fix all line length related CodeSniffer warnings.

Change-Id: Id0fd8f4c7276185f51489659ee3cd06962fbc16d
2013-11-21 16:43:40 +00:00
Siebrand Mazeland
1e10dcd3aa Update formatting on database-related classes
Change-Id: I91f83e28ae25f80ba9e36c612f1ad050ffa1573c
2013-11-21 16:39:38 +00:00
Chad Horohoe
fc2218288c Remove pointless vertical alignment
Change-Id: I57926bfb718fdb7e4f55a08f39fc6af9f2e4adf6
2013-05-06 08:54:20 -04:00
umherirrender
892ee7a4af Fixed spacing in db/debug/diff/externalstore/objectcache folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I32a43c547630ce31b6b25cc1bc9eedc50e67b2d7
2013-04-20 22:28:52 +02:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
umherirrender
85d8ee1f87 Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I00f369641320acd7f087427ef031f3ee7efa0997
2012-10-10 20:14:40 +02:00
Alexandre Emsenhuber
e7ab34cf1d Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: If65d7313e1e05163ce6cc46d17daa310cb41888c
2012-04-28 20:41:55 +02:00
Aaron Schulz
5a6559d8b1 Reverted r108743 per CR comment. This should at least be discussed first. 2012-01-12 19:41:18 +00:00
Sam Reed
a5c200a25b Kill "* @return void" 2012-01-12 19:12:24 +00:00
Jure Kajzer
5933586266 some more oracle-phpunit-fu (should not affect non-oracle)
* CloneDatabase - already droping tables in internal function, removed duplicate action
* DatabaseOracle - stopped ignoring "temporary" parameter
* added two parameters to phpunit (use-normal-tables & reuse-db), default actions stay the same
* with reuse-db oracle phpunit test run on oracle down to 1m 20s ;)
2011-11-10 13:29:32 +00:00
Chad Horohoe
70430650e9 Followup r96369: update child classes and a few callers 2011-09-06 20:51:10 +00:00
Chad Horohoe
ba9d7db94d $newTablePrefix must be passed. All callers are ok 2011-05-30 02:06:12 +00:00
Sam Reed
51a0d53758 More documentation stuffs 2011-05-25 18:58:02 +00:00
Platonides
f524482f2d Change the duplicateTableStructure() to use the original names.
It is now duplicateTableStructure() duty to addIdentifierQuotes() them.
Fixed bug for mysql < 4.1 where the new name would be quoted twice.

Always quote identifier in Oracle, doing otherwise seems a bug (can someone confirm?)
2011-04-12 18:54:51 +00:00
Antoine Musso
0d2baed222 correct wfDebug() calls added in r79272 & r79368 2011-03-20 11:39:44 +00:00
X!
1b7bfdee49 I made MySQL work, and broke SQLite in the process. I fix SQLite, and made MySQL break. Fixing MySQL again, hoping that SQLite works too. :) 2010-12-31 21:01:17 +00:00
X!
dd68f3947a More work on getting SQLite to work with unit tests. DB Prefix changing is now static to allow for external classes to change it. 2010-12-31 20:42:39 +00:00
Platonides
666ee2902a Follow up r79314.
The table to drop is the NEW one, the one that is going to be recreated.
Sure, the prefix was changed, which means that we need just the table base.

The r79314 behavior was to perform the following:
 DROP /* CloneDatabase::cloneTableStructure  */ TABLE IF EXISTS `archive`
 CREATE /* DatabaseMysql::duplicateTableStructure  */ TEMPORARY  TABLE `unittest_archive` (LIKE `archive`)

Luckily, it failed there as it didn't find the table it had just dropped.
2010-12-31 14:08:10 +00:00
X!
f70c2b987c Use $oldTableName in CloneDatabase. The dropTable() appends the prefix, so $oldTableName becomes $newTableName 2010-12-31 02:18:25 +00:00
X!
1993c83277 -Destroy the DB automatically when initting the DB
-Add $force option to wfSetVar
-More work on getting SQLite to work
2010-12-30 17:30:35 +00:00
Sam Reed
490367210b Add function return type hint to wfGetLBFactory
More parameter documentation to CloneDatabase
2010-12-30 02:44:26 +00:00
Sam Reed
43ca0f0974 Array to array
Add some function documentation
2010-12-30 02:41:20 +00:00