Commit graph

134 commits

Author SHA1 Message Date
Siebrand Mazeland
e22a70a103 Update documentation for database related classes
Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f
2014-01-06 19:45:40 +01: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
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
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
Chad Horohoe
d0c8ba037c Remove wfDl() and cleanup everything it touched
wfDl() is a wrapper around dl(), which is an evil function and
basically only works from the command line of Zend. Luckily
no extension has ever used this thing, so let's just remove it
outright.

For comparison, here's a list of places it does not work:
- hhvm
- php as apache module
- php compiled with zts support
- safe_mode
- Basically any shared host that cares about security

Most callers are using it to check for extension support and are
actually failing gracefully when wfDl() returns false. In these
places we're just going to use extension_loaded().

While we're at it, clean up some of the test skip logic in the
media tests so we can bail as early as possible if we know we
can't complete the test.

This also immediately removes $wgLoadFileinfoExtension. It's been
enabled by default since 5.3 and falls back gracefully when the
support isn't available.

Change-Id: Ieb430dfc74483731dde51d6e20fa700d641ba1f4
2013-10-09 10:51:35 -07:00
Aaron Schulz
ea7d214040 Fixed mysql warning about expecting a resource.
Change-Id: I799d063fec7a8e96f49db34ce669453bd26c3fb3
2013-06-16 15:56:41 -07:00
Jakub Vrana
b1cc3511fd Prepare DatabaseMysql for mysqli
PHP extensions mysql and mysqli have lots in common.
In order to support mysqli, this diff separates common MySQL behavior to abstract class DatabaseMysqlBase and implements the mysql-extension specific in DatabaseMysql.
Outside behavior remains the same.

I've tried to minimize future code duplication by introducing mysql*() methods even if the parent method just unwraps the result.

Bug: 45288
Change-Id: I905d4a4550377bc849a860f0962dad710d9dc71f
2013-06-12 23:44:24 +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
Aaron Schulz
c2ee52dd25 [Database] Added an upsert() function to perform/emulate ON DUPLICATE KEY UPDATE.
Change-Id: Id7fc6652268a439af0457309a678677351867f37
2013-06-04 06:20:41 +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
Chad Horohoe
b27cfbd9e8 Use __METHOD__ for default $fname params to database functions
Change-Id: I86cbdeabee9709cde15a6b7bd47a53229c2e3f92
2013-05-07 06:18:57 +00:00
Reedy
d560eb0b3e Revert "Commit of various live hacks"
This reverts commit c6af934ae6.

Change-Id: I3e863bb632531d7cd4ec0614325a7c4a7ba9aa3d
2013-04-29 19:19:54 +01:00
Reedy
c6af934ae6 Commit of various live hacks
Disable of MessageBlobStore clear

Reset $wgAutopromote (should be moved to a config change!!)

Disable setting of wgStyleSheetPath

Throttle page_touched

Add apc htcp packet numbers to SquidUpdate

Disable set names binary/utf8

Commment out searchindex table indexes

Was c532e81d583d3d0439fe76eea4d105d675461b56

Original revision Change-Id I42c4f859e55eb198f6c6841e582b3552aad7b31f
https://gerrit.wikimedia.org/r/#/c/7606

Change-Id: I5ec8dd53188e9e4128f99ceaff38ebf9dcf570bb
2013-04-29 15:46:38 +00:00
umherirrender
6f79eef473 Fixed spacing around parenthesis in includes
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
2013-04-28 15:50:07 +00: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
umherirrender
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
jenkins-bot
c151d6e687 Merge "numRows on MySQL no longer propagates unrelated errors" 2013-03-11 18:14:19 +00: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
Niklas Laxström
36c18cffc5 numRows on MySQL no longer propagates unrelated errors
Bug: 42430
Change-Id: Ie2277c97177be34f4a48dfa0eac736a2b5716f22
2013-03-10 09:46:00 +00:00
Reedy
586e8fb7ec Revert "Commit of various live hacks"
This reverts commit 3d6851f662.

Change-Id: I26c418d631047783ba945e6b6a7f707d876b3146
2013-03-04 18:39:51 +00:00
Reedy
3d6851f662 Commit of various live hacks
Disable of MessageBlobStore clear

Reset $wgAutopromote (should be moved to a config change!!)

Disable setting of wgStyleSheetPath

Throttle page_touched

Add apc htcp packet numbers to SquidUpdate

Disable set names binary/utf8

Commment out searchindex table indexes

Was c532e81d583d3d0439fe76eea4d105d675461b56

Original revision Change-Id I42c4f859e55eb198f6c6841e582b3552aad7b31f
https://gerrit.wikimedia.org/r/#/c/7606

Change-Id: I5ec8dd53188e9e4128f99ceaff38ebf9dcf570bb
2013-03-04 18:03:39 +00:00
Alexandre Emsenhuber
4746329a73 Fix documentation of DatabaseBase::fetchObject() and DatabaseBase::fetchRow()
- DatabaseBase::fetchRows() returns the row as an array, not an object
- Both methods return false if there are no more rows in the result

Change-Id: I328d61b237bb82479d3fcb4c54ee9fd96dc4598f
2013-02-18 15:39:29 +01:00
Reedy
e028051140 Add a handful of missing @return
Change-Id: I21b218e6694600a2d2df4dd0a6b2b5cd2e10f1f9
2013-02-16 17:51:13 +01:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
Platonides
5d064a7433 Reorganise the functions doing wfProfileOut and returning on all if branches.
Makes life easier for static analysis, since they don't need to
handle if the end of a function where a wfProfileOut was not called
was reachable or not.

It is recommended to review this change ignoring whitespaces
(specially for includes/parser/Tidy.php)

Also documented the rationale for the elseif chain in UploadBase::detectVirus()

Change-Id: Ic4f65937fa9e6f926d8fcfd670e3b0e99e06eefc
2013-01-13 17:53:05 +01:00
Platonides
fb0966908b Miscellaneous profiling fixes
Change-Id: I8d8ce0bc0383e4feb4ed38fd96b2dd516dcb742e
2013-01-06 22:35:11 +01:00
Chad Horohoe
551d81df41 Revert "Commit of various live hacks"
This reverts commit acddbc862a.

Change-Id: Iabf5f917938c347ca6ddc7a373c731f44f23363b
2012-12-10 20:56:45 -05:00
Reedy
acddbc862a Commit of various live hacks
Disable of MessageBlobStore clear

Reset $wgAutopromote (should be moved to a config change!!)

Disable setting of wgStyleSheetPath

Disable squid updates in HTMLCacaheUpdate invalidateTitles

Throttle page_touched

Add apc htcp packet numbers to SquidUpdate

Disable set names binary/utf8

Commment out searchindex table indexes

Was c532e81d583d3d0439fe76eea4d105d675461b56

Original revision Change-Id I42c4f859e55eb198f6c6841e582b3552aad7b31f
https://gerrit.wikimedia.org/r/#/c/7606

Change-Id: I5ec8dd53188e9e4128f99ceaff38ebf9dcf570bb
2012-12-10 13:33:12 -05:00
MarkAHershberger
34c9bca6a8 (bug 38110) provide a way to separate out schema changes
Allows update.php to be run when $wgAllowSchemaUpdates = false.

This is useful for non-WMF environments where strict DB permissions
allow database updates (which update.php performs), but no schema
changes (such as adding or dropping tables or indices which update.php
also performs).

It does this by adding the --schema and --noschema flags. Without
either of these flags, update.php will perform exactly as before.

With --noschema, all changes to the table structure or table additions
are skipped. Only data changes are made.

With --schema is used, no schema changes are made to the database, but
the schema changes are saved to a separate SQL file that can be run.

Change-Id: I96b4cfd4c02e9cbf46cc6a0499b87fb3b89020a0
2012-11-21 22:53:24 -05:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
umherirrender
62362746d0 Remove deprecated 1.16 Legacy support: Database == DatabaseMysql
Change-Id: I8e7549e67aac072139923b7c4ea607563facf2e9
2012-10-05 22:39:31 +02:00
Tyler Anthony Romeo
b69cc58b7f (bug 39287) Fixed error checking in DatabaseMysql::fetchObject.
According to the libmysql API documentation, mysql_fetch_row,
upon which the PHP functions mysql_fetch_object, etc. are
based on, does not reset the error number or message upon
success. So calling mysql_errno() after a successful fetch
may return the error of the previous function call.

This commit changes DatabaseMysql::fetchObject and similar
functions to only check for specific error numbers that are
explicitly documented to be expected from mysql_fetch_*.

Change-Id: Iacb78828885a8a0d4e499a681d938a6adf651582
2012-09-04 11:41:58 -07:00
Alexandre Emsenhuber
72a72e26dc Fixes for DatabaseMysql::open()
- Group global declarations at the top
- Early abort on error, instead of going through
  the whole code
- Group double call to wfDebug()
- Whitespaces fixes

Change-Id: I9e28395a2698216e14458d1a74ef0a89e7ee48d6
2012-09-01 17:13:35 +02:00
Tyler Anthony Romeo
494b8b51b1 (bug 32774) Added config options and flags for SSL and compression in DB.
Added configuration options ($wgDBssl, $wgDBcompress) and related
connection flags (DBO_SSL, DBO_COMPRESS) to allow SSL/TLS and
compression on database connections. The flags are only observed if
the functionality is supported for that type of database (e.g.,
SQLite will ignore both flags as neither are supported).

Currently, only MySQL and PgSQL have support for at least one of
these flags in their PHP extensions. MySQL supports both flags and
PgSQL supports the SSL flag only.

Change-Id: I7b4d3ba82ccab0eed4a19e3b4e7bc0b4eb881262
Signed-off-by: Tyler Anthony Romeo <tylerromeo@gmail.com>
2012-08-16 10:48:07 -04:00
Aaron Schulz
eb16f5898d [Database] Various DB cleanups.
* Removed unused and obsolete set() and safeQuery() functions.
* Removed unused deprecated constructor functions.
* Removed unused limitResultForUpdate() cruft function.
* Removed unused standardSelectDistinct(), it's better to just follow the standard for all queries.
* Removed other cruft functions unused by core/extensions.
* Made some internal functions protected.

Change-Id: I90be88ea740834a417a17d7751f1be7bac4eae4e
2012-08-08 11:00:48 -07:00
Christian Aistleitner
af919fe3e0 Fix error message for MySQL connection failures
Change-Id: I23cbe6a58ab5aed88c656bfa9370568b39ca4e32
2012-05-28 22:06:43 +02:00
Aaron
ff187ea7cc [SiteStatsUpdate] Reduced contention by using a new lockIsFree() DB function.
* Note: follows up a4b3979160
* Cleanup up transaction statements a bit; transactions don't effect the lock calls
* Also made DatabaseMysql::unlock() actually return a bool

Change-Id: Iade2efa94165b6918eae0863716cc163f36a07b8
2012-05-10 15:48:58 -07:00
Catrope
c9047274d5 Revert "Commit of various live hacks"
Was meant for 1.20wmf2

This reverts commit 062773733d
2012-04-30 20:57:56 +00:00
Reedy
062773733d Commit of various live hacks
Disable of MessageBlobStore clear

Reset $wgAutopromote (should be moved to a config change!!)

Disable setting of wgStyleSheetPath

Disable squid updates in HTMLCacaheUpdate invalidateTitles

Throttle page_touched

Add apc htcp packet numbers to SquidUpdate

Disable set names binary/utf8

Commment out searchindex table indexes

Was c532e81d583d3d0439fe76eea4d105d675461b56

Change-Id: I42c4f859e55eb198f6c6841e582b3552aad7b31f
2012-04-30 20:10:13 +01:00
Alexandre Emsenhuber
78a56a67ba Added missing GPLv2 headers in includes/db.
Change-Id: Ib8fe301c6db77603e411113cea5a39c25c664961
2012-04-26 10:47:10 +02:00
Max Semenik
a8f718267e Follow-up r112565: fix code duplication 2012-02-28 14:42:08 +00:00
Chad Horohoe
2177a4d8b4 (bug 34762) Calling close() on a DatabaseBase object now clears the connection. Based on patch by Christian.
By the way, the duplication here is stupid.
2012-02-28 02:18:18 +00:00
Alexandre Emsenhuber
d97561461c Pass __METHOD__ to DatabaseBase::begin(), DatabaseBase::commit() and DatabaseBase::rollback() 2012-02-25 13:23:43 +00:00
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Sam Reed
e1d83d5721 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:54 +00:00
Sam Reed
138ddc452f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 17:42:35 +00:00
Sam Reed
ebf916f3fb Give sql.php eval.php type scrollback 2012-01-12 22:57:51 +00:00