Commit graph

98 commits

Author SHA1 Message Date
physikerwelt
5048f30f69 Fix: numFields wrong for sqlite
Currently the first row of the result
is used to return the number of fields.
This fix corrects that calculation, which has returned
twice the number of fields before. The reason for that
was that the resulting data array has the following form:
array() {
 [0] => value_0
 ["field_name0"] =>value_0
 [1] => value_1
 ["field_name1"] =>value_1
...
Furthermore the constant 0 (int) is returned if the result
set is empty. This issue should be corrected in the future,
since the number or fields should be answered in a metadata context
independent of the data stored in the relation.

Bug: 65578
Change-Id: I399c7c857dcbd774cc4eb6102bbfe8a8764b07c9
2014-05-21 13:09:13 +00:00
Aaron Schulz
ac8c53583c Avoid fatal error if doing a DB query after close()
Change-Id: I606a3ec5a45136abf396f86f5a65db209128d5c9
2014-04-30 17:04:06 -07:00
Siebrand Mazeland
1742e9448c Pass phpcs-strict on some test files (6/11)
Change-Id: I5f4bc0df8183cf338ff45cacfc7279c2cd38ee04
2014-04-24 18:26:19 +00:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
aude
1959b3eb5a Avoid interacting with LBFactory singleton in tests
Instead test that LBFactory::getLBFactoryClass() does the right thing.

In LBFactory::getLBFactoryClass(), the method now requires a configuration
array as a parameter, and returns the class name as a string.

LBFactory::singleton() now passes in $wgLBFactoryConf into getLBFactoryClass(),
while tests can use test configuration.

Only use of LBFactory::getLBFactoryClass() in core is in LBFactory::singleton().

No extension in gerrit uses getLBFactoryClass() and I can find no use of it
when searching places like Github and Google, so it should be safe to make
such change in LBFactory.

Bug: 59105
Change-Id: I71ae7df16bc5c214b9389125140bca5ce68d274c
2014-01-02 14:27:19 +01:00
Siebrand Mazeland
210edff11b Remove underscore from classes LBFactory_*, LoadBalancer_*, LoadMonitor_*
Part of program to remove underscores from class names. Checked core and
600+ extensions for occurrences. All uses are in core in core are updated
in this patch.

Patches for extensions:
* https://gerrit.wikimedia.org/r/#/c/96463/ CentralAuth
* https://gerrit.wikimedia.org/r/#/c/96460/ SimpleSecurity
* https://gerrit.wikimedia.org/r/#/c/96459/ WikiBase
* https://gerrit.wikimedia.org/r/#/c/96472/ Wikimedia configuration

Antoine added tests to test the back compatibility.

Change-Id: I507ba00a83bca8375a0215f00891b47e3c7afb9f
2013-12-26 16:30:15 -05: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
jenkins-bot
a443be2747 Merge "Add DROP INDEX support to DatabaseSqlite::replaceVars method" 2013-11-05 14:18:01 +00:00
addshore
aea1b27db0 @covers tags for more test classes
Change-Id: I19d49c279646a4b4c595700e53b790ba4eb9521e
2013-10-24 20:35:04 +01: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
Dereckson
60596ab27e Add DROP INDEX support to DatabaseSqlite::replaceVars method
DROP INDEX is database-wide (and not table-specific) in SQLite,
so we need to add a rule in our MySQL to SQLite schema convert.

"DROP INDEX foo ON bar" becomes "DROP INDEX foo".

Change-Id: Ie10784d166ed5a7f6ea52cf4f3a812fb7878a744
2013-10-15 22:32:28 +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
jenkins-bot
e0e8ba9226 Merge "Changed quoting function for oracleDB." 2013-09-18 19:10:52 +00:00
umherirrender
070e11da65 Added tests for new DatabaseBase::upsert
Follow up Id7fc6652
Pass function name to begin/rollback/commit
Use __METHOD__ as default param (see I86cbdeab)

Change-Id: I9eb326c035d4a604db5b3492f090d8dd9d21c920
2013-06-04 20:34:49 +02:00
freakolowsky
d06721d2a9 Changed quoting function for oracleDB.
Change-Id: Ifba624f62702740b6531d0dab082015cd2a235b4
2013-05-26 16:35:48 +02:00
jenkins-bot
ca15b909fb Merge "Made DatabaseBase::getSoftwareLink() dynamic." 2013-05-15 14:37:58 +00:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Aaron Schulz
be7b10166a Made DatabaseBase::getSoftwareLink() dynamic.
* All callers are calling it this way and it breaks
  hhvm when declared statically and called dynamically.

Change-Id: I894e615fd828615384aa8457a16a759c8aa416ef
2013-05-14 21:18:57 -07:00
umherirrender
c6894adefc Fixed spacing
Added spaces around some parenthesis

Change-Id: If1e50e2a7b0046e91c0bbce8bf6641d8b2446a1d
2013-05-09 19:48:10 +02:00
umherirrender
da0bf68e4c Exclude external_user table in DatabaseSqliteTest
Follow up I794338dbb75961ee033d41fa44bb7aa22e54f447

Change-Id: Ie83cb113be3911431ba36ef18286d6892364b0ca
2013-05-02 21:07:18 +02:00
Brent Garber
58c72e5aa6 Fix PHPUnit ORM Tests to work with Postgres
Change-Id: Ia4321727f6f1eab65c91d9876f87d51b545a72c2
2013-04-28 12:54:56 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
umherirrender
302f4b0ce1 Add non DBMS depending SQL tests for DatabaseBase
Created a DatabaseTestHelper class, which extends DatabaseBase and
implements STUBs for the interface methods and abstract methods

Change-Id: I9965b3604e78b2722077a35a7b4ce62a5bcb370e
2013-04-16 09:38:30 +02:00
jenkins-bot
f4604544cd Merge "Test to make sure numRows() calls don't show unrelated errors" 2013-03-22 13:58:55 +00:00
Chad Horohoe
1b292fe465 Test to make sure numRows() calls don't show unrelated errors
Bug: 42430
Change-Id: Ie939785c1f75aa99bdf59e013d5ebf65e866289c
2013-03-22 13:51:07 +00:00
umherirrender
3dd97bf651 Use gettype only for debugging text
Changed some gettype == 'array', 'object' and similar to is_array,
is_object or similar

Output of gettype must not stable across versions and it is slow

Change-Id: I07bfc063b03be1200989dd6facee66b35ab51d77
2013-03-15 22:50:42 +01:00
nischayn22
b9b3d8821a (bug 37352) Boolean issue when using sqlite.
using a type cast instead, otherwise an empty string gets converted to
true when set with bool type.

Change-Id: I4161de32151a649161ab4084e80cafe4a462c7d5
2013-03-06 03:45:48 +00:00
Siebrand Mazeland
9f77245218 Update formatting
4 of n.

Change-Id: I23e2409ce9eff14c3434154d236de83c93a92440
2013-02-14 14:10:38 +01:00
jenkins-bot
490780c68a Merge "Force case-sensitivity on the LIKE operator, to ensure similar behaviour between MySQL and SQLite" 2013-01-31 20:49:56 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
jenkins-bot
a1d5bf7a41 Merge "(minor) Make ORMTable handle failed queries nicely." 2013-01-07 18:12:37 +00:00
daniel
4f15b61efe (minor) Make ORMTable handle failed queries nicely.
Database::select will return false if a query fails and the DB object
is set to "ignore errors" mode. ORMTable now detect this and throw
a DBQueryError, overriding the ignore errors mode.

This change also adds a dummy implementation for ORMTable to ORMTableTest,
so tests can be run on the base implementation.

Change-Id: I5d87295626c0800c38f807d19becb312ba7cc956
2013-01-07 14:14:56 +01:00
Alexandre Emsenhuber
fa4196bc53 Fix Sqlite upgrade test when profiling to database is enabled
The 'profiling' table is missing from expected tables when
$wgProfileToDatabase is set to true, since patch-profiling.sql
is applied while updating in this case.

Change-Id: Iedbe72dca1deda728304fb95fe19ef3b4bdad8de
2013-01-02 14:52:02 +01:00
btongminh
3300e5870c Force case-sensitivity on the LIKE operator, to ensure similar behaviour
between MySQL and SQLite

Change-Id: Idf2d90fe3df07364657abb6070f6eac59add1306
2012-12-24 21:10:22 +01:00
jeroendedauw
e90d1a0918 (bug 42226) failure in sites tests
MediaWikiSiteTest::testRemove got a duplicate key error.

Change-Id: I7a40fe50b757e4162b7ccf1655d872cbd2c51f5d
2012-12-07 11:38:40 +01:00
umherirrender
fa1394e1a7 Add parent::setUp() to DatabaseSQLTest
1) DatabaseSQLTest::testMediaWikiTestCaseParentSetupCalled
DatabaseSQLTest::setUp() must call parent::setUp()
Failed asserting that an array has the key 'setUp'.

Change-Id: I6aa5cb09999e0cee9b36fedd9193cb5aa08914ad
2012-12-06 21:20:52 +00:00
Antoine Musso
bd6f3ddc6f test: raise timeout for DatabaseSqlite
DatabaseSqliteTest does file access and hence needs a slightly higher
timeout in PHPUnit.

Change-Id: I4b5eb7d7c5a3b9d4790f11cdb4efa9f578763183
2012-12-03 09:18:43 +01:00
umherirrender
83f883c7cb Fix data type for timestamp in TestORMRowTest
1) TestORMRowTest::testConstructor with data set #0 (array('Foobar',
'20120101020202', 42, 9000.1, true, array(13, 11, 7, 5, 3, 2),
stdClass), true)
Failed asserting that 2147483647 matches expected '20120101020202'.

Change-Id: I4dddaedf4e386c2061ee79fe0ab18af59033f052
2012-11-23 13:50:43 +01:00
Demon
4daa24f4f1 Merge "drop orm_test table on teardown" 2012-11-16 05:21:15 +00:00
umherirrender
ce966298ca fix @depends
No need for the parentheses there

Change-Id: Id2ba72a7fb7bdd592de0642468994c9dab29adcd
2012-11-10 20:15:03 +01:00
umherirrender
93dd5435f0 drop orm_test table on teardown
No need to keep this table after the test

Change-Id: Id6814ceca063294da0761caa9a0d9975118dd4f1
2012-11-10 19:05:04 +00:00
aude
16e2c77715 move ORMTableTest from Wikibase to core
- this is more generally useful than to be buried inside Wikibase client.
- it was in Wikibase/client/tests/phpunit/includes/store/EntityCacheTableTest.php

- patchset 2: add to test autoloader

Change-Id: I5bc41d6d205f28bcc5bf0c8a78b782c8888c18eb
2012-11-09 09:57:45 +00:00