Commit graph

309 commits

Author SHA1 Message Date
Daniel Friesen
da469e3abe Fix a bug in the installer caused by r77487 creating installer sql statements like "GRANT ALL PRIVILEGES ON 'dbname'.* TO ''tablename''@'%" while improving the database independence of replaceVars.
* Drop unused and likely broken /*$var*/` -> `$var syntax
* Replace {$var} with '{$var}' and `{$var}` handling that uses relevant database independent quoting ({$var} without surrouding quotes are never used)
* Give the generic/mysql class a proper quote_ident implementation
* Fix the unused Oracle and Sqlite quote_ident implementations which are potential sql injections if used
* Split common variable replacemnt code off to a replaceGlobalVars and make the generic and oracle code use it instead of duplicating the same code as each other
2010-12-04 09:27:02 +00:00
Sam Reed
9eb8f23538 Followup r77666, remove changed in database comment (no idea where that came from) 2010-12-03 23:50:00 +00:00
Sam Reed
612c934210 * (bug 26219) Show API limits for multi values in description
Also move bug 9675/r77612 RELEASE-NOTES to the correct section
2010-12-03 16:24:05 +00:00
Sam Reed
ebf546098e Documentation improvement to r77597 2010-12-03 09:57:53 +00:00
Sam Reed
b0efc1a61c Per MaxSem CR on r77597, make $alias paramater optional, as per the documentation 2010-12-03 09:40:11 +00:00
Sam Reed
22ab89938f Per Roans request, Merge in r65475 (Database.php only) from querypage-work2 branch 2010-12-02 19:39:32 +00:00
Antoine Musso
5cdd7614d5 pipe does not look nice in doxygen. fu r77499 2010-12-02 19:33:15 +00:00
Sam Reed
7320879184 Few braces and spaces
Fixing up documentation
2010-11-30 19:06:28 +00:00
Platonides
bd6b4d7af8 Replace addslashes with Database::addQuotes() 2010-11-30 18:21:55 +00:00
Platonides
6e81d60086 Fix potential html injection when the database server isn't available (bug 26164).
Wikis which set $wgServer in their LocalSettings or are in a virtual
host would never be vulnerable.
For sites which show the wiki in the default host, it will depend on how
forgiving is their webserver and php stack for that garbled input, although 
some kind of foolable proxy —moreover wrongly caching errors (or the default 
output buffering is disabled and something incorrectly sent a previous text)—
would also need to be present in order to make that useful for a 
potential attacker.
2010-11-29 16:34:28 +00:00
Mark A. Hershberger
bdf0b5efc7 revert r77271 since it was an expensive fix to a non-existant problem. 2010-11-26 02:37:28 +00:00
Mark A. Hershberger
028d32b0ff Give SQLite a translation for MySQL's UNIX_TIMESTAMP() functions. Pg will probably need something similar. 2010-11-25 07:39:51 +00:00
Alexandre Emsenhuber
6cb276056b Moved switches in Special:Unusedimages and Special:Ancientpages to extract a unix timestamp from a fielf to DatabaseBase and related classes to avoid code duplication 2010-11-24 15:40:25 +00:00
Max Semenik
f134f2f134 Fix PHP 5.2 compatibility for r77144 2010-11-23 14:08:46 +00:00
Max Semenik
42e8644437 This indexInfo() belongs to MySQL 2010-11-23 11:14:48 +00:00
Max Semenik
4345c2c20e Refactoring of *Field classes:
* Made them all implement one common interface (might add more functions to it later)
* Moved MySQLField to DatabaseMysql.php
* Renamed nullable() to isNullable()
* Removed maxLength() from:
** SQLiteField: makes no sense
** MySQLField: doesn't do what people may think, useless for this class' purpose of assisting querying the DB schema
2010-11-21 19:56:51 +00:00
Alexandre Emsenhuber
2bdeabdcc3 @fixme command doesn't exist in doxygen 2010-11-19 11:49:47 +00:00
Sam Reed
d189aaee05 (bug 24853) Kill failFunction - Fixed! :D 2010-10-24 21:27:33 +00:00
Sam Reed
16cded8b32 Start of bug 24853, killing off 'functional' parts of failfunction code. Seems when the constructors start getting changed, it starts borking. Using this as a point of reversion/stashing 2010-10-24 20:48:48 +00:00
Platonides
20d1e2d126 $wgUser is never a Stub since r70970.
This means, the user data was innecessarily loaded here just for the debug message.

It also caused bug 24995 - "fallback" key missing from localization cache.
For languages other than English (short-circuitted in Language.php:2800) during 
Language load, it gets the fallback from the localization cache, which used the db, 
which then loaded here the User object, which called WebRequest caused unstubbing (again)
of ContentLanguage for unicode normalization, which loaded again the Language (a call 
to loadItem( 'xx', 'fallback' ) under loadItem( 'xx', 'fallback' ) stack) and then 
caused it to finally fail.

It wasn't an unstub loop, but was near.

Backtrace:
LocalisationCache::loadItem  phase3/includes/LocalisationCache.php:205 <-- Second load of key fallback
LocalisationCache::getItem phase3/languages/Language.php:2802
Language::getFallbackFor phase3/languages/Language.php:169
Language::newFromCode phase3/languages/Language.php:140
Language::factory phase3/includes/StubObject.php:126
StubContLang::_newObject phase3/includes/StubObject.php:103
StubObject::_unstub phase3/includes/StubObject.php:57
StubObject::_call phase3/includes/StubObject.php:121
StubContLang::__call phase3/includes/WebRequest.php:204 <-- Second unstub
StubContLang::normalize phase3/includes/WebRequest.php:204
WebRequest::normalizeUnicode phase3/includes/WebRequest.php:231
WebRequest::getGPCVal phase3/includes/WebRequest.php:460
WebRequest::getCookie phase3/includes/User.php:835
User::loadFromSession phase3/includes/User.php:221
User::load phase3/includes/User.php:1501
User::getName phase3/includes/db/Database.php:658
DatabaseBase::query phase3/includes/db/DatabaseMysql.php:120
DatabaseMysql::open phase3/includes/db/Database.php:530
DatabaseBase::__construct phase3/includes/db/LoadBalancer.php:651
LoadBalancer::reallyOpenConnection phase3/includes/db/LoadBalancer.php:532
LoadBalancer::openConnection phase3/includes/db/LoadBalancer.php:455
LoadBalancer::getConnection phase3/includes/GlobalFunctions.php:3085
wfGetDB phase3/includes/LocalisationCache.php:772
LCStore_DB::get phase3/includes/LocalisationCache.php:326
LocalisationCache::isExpired phase3/includes/LocalisationCache.php:355
LocalisationCache::initLanguage phase3/includes/LocalisationCache.php:267
LocalisationCache::loadItem phase3/includes/LocalisationCache.php:205 <-- First load of key fallback
LocalisationCache::getItem phase3/languages/Language.php:2802
Language::getFallbackFor phase3/languages/Language.php:169
Language::newFromCode phase3/languages/Language.php:140
Language::factory phase3/includes/StubObject.php:126
StubContLang::_newObject phase3/includes/StubObject.php:103
StubObject::_unstub phase3/includes/StubObject.php:57
StubObject::_call phase3/includes/StubObject.php:121
StubContLang::__call phase3/includes/WebRequest.php:228 <-- First unstub
StubContLang::checkTitleEncoding phase3/includes/WebRequest.php:228
WebRequest::getGPCVal phase3/includes/WebRequest.php:250
WebRequest::getVal phase3/index.php:56
2010-10-17 22:33:25 +00:00
Sam Reed
a2589ff8c6 Assignment in loop conditions suck
while ( $row = $dbw->fetchObject( $res ) ) { to foreach ( $res as $row ) in includes

Add some braces
2010-10-13 23:11:40 +00:00
Max Semenik
797bc0c5f7 Turned Database::patchPath() into a member function, less globals to care about 2010-10-11 15:29:48 +00:00
Brion Vibber
2f360ee0f9 Revert r74286, r74287 -- broke parserTests completely; mixed lots of formatting and code cleanup in with functional changes making it impossible to review cleanly. 2010-10-05 15:10:14 +00:00
Mark A. Hershberger
a828027890 (second commit to get all files.)
= BacklinkCache.php =
* BacklinkCache class
** Set a few otherwise unset varables ($wgContLang & $wgMemc in
   BacklinkCache)
= testHelpers.inc =
* TectRecorder class
** TestRecorder::record() accept and use a recorder object
** change TestFileIterator::setParser use a MediaWikiParserTest instead
   of ParserTest
= parserTest.inc =
* ParserTest class
** Make $ParserTest->regex and $ParsaerTest->savedGlobals member
   variables available to stop warnings.
** Force ParserTest::$showProgress and $showFailure to false
** Set ParserTest::$uploadDir on time
** Move ParserTest::chomp() and addArticle() to bootstrap for
   MediaWikiTestSetup.
** Update ParserTest::runTest so that Success and Failure are reported
   via reporter->showsTestResult() or ParserTestSuiteBackend::show*()
   as needed.
** Set $ParserTest->uploadDir with setupUploadDir()
** Change ParserTest->setupGlobals() so that $wgDBprefix doesn't get
   to set to the “parsertest_” bits.
** Sprinkle $this->teardownGlobals() at exit points in
  ParserTest->teardownDatabase()
= bootstrap.php =
* MediaWikiTestSetup class
** Make member variables MediaWikiTestSetup::$suite,
  MediaW* Make member variables MediaWikiTestSetup::$suite,
  MediaWikiTestSetup::$regex, MediaWikiTestSetup::$runDisabled
  available.
* Setup a constructor MediaWikiTestSetup that accepts an optional
  PHPUnit_Framework_TestSuite so they can use PHPUnit.
* Change MediaWikiParserTest so that it is derived from
  MediaWikiTestSetup instead of PHPUnit_Framework_TestSuite
* Make MediaWikiParserTest create a PHPUnit_Framework_TestSuite for
  the parser tests and pass it to the new parent (MediaWikiTestSetup)
  as the PHPUnit testsuite.
* Replace MediaWikiParserTest->run() with MediaWikiParserTest::suite()
  so that the tests can be loaded into a suite and then run with
  PHPUnit's test runner.
= ParserHelpers.php =
* ParserUnitTest class
** Force run() $backend to use ParserTestSuiteBackend instead of
   trying to get the  backend from the suite member.
** Use ParserTest::runTest() instead of
  ParserikiTestSetup::$regex, MediaWikiTestSetup::$runDisabled
  available.
** Setup a constructor MediaWikiTestSetup that accepts an optional
   PHPUnit_Framework_TestSuite so they can use PHPUnit.
** Change MediaWikiParserTest so that it is derived from
   MediaWikiTestSetup instead of PHPUnit_Framework_TestSuite
** Make MediaWikiParserTest create a PHPUnit_Framework_TestSuite for
   the parser tests and pass it to the new parent (MediaWikiTestSetup)
   as the PHPUnit testsuite.
** Replace MediaWikiParserTest->run() with MediaWikiParserTest::suite()
   so that the tests can be loaded into a suite and then run with
   PHPUnit's test runner.
= ParserHelpers.php =
* ParserUnitTest class
** Force run() $backend to use ParserTestSuiteBackend instead of
   trying to get the  backend from the suite member.
** Use ParserTest::runTest() instead of
  ParserTestSuiteBackend::runTest()
* ParserTestSuiteBackend class
** extends PHPUnit_FrameWork_TestSuite instead of ParserTest
** Add member variables  $recorder, $term, and $usePHPUnit
** Add a constructor that determines if PHPUnit is usewd.
** Add a method showTestResult() that can be used to show success or
   failure
** Change showSucess and showFailure() to be static and use identical
   arguments and only use PHPUnit_Framework_Assert::assertEquals
   when PHPUnit is in use.
= SearchEngineTest.php =
** Fix path in require to bootstrap.php
2010-10-05 03:51:49 +00:00
Alexandre Emsenhuber
329d1c5f2e Added fname parameter to the query() call 2010-10-03 08:05:26 +00:00
Max Semenik
a3359e650e Follow-up r68878: ensure that returned value is int 2010-09-28 08:32:09 +00:00
Max Semenik
c357bc7c8a Special:Version now displays whether a SQLite database supports full-text search 2010-09-23 19:36:06 +00:00
Max Semenik
a9a40c0bed Pass calling function name and patch file from DatabaseBase::sourceFile() to query() to make updater debugging easier 2010-09-08 18:11:36 +00:00
Aryeh Gregor
9ac33a362f Move DatabaseType to Database.php
This way the required method names will show up when grepping
Database.php.  I thought we had no affectedRows() method for a minute
there, until G_SabinoMullane corrected me (good thing I think aloud
in #mediawiki).
2010-09-08 17:48:11 +00:00
Aryeh Gregor
338ae40072 Suggest running update.php on database error
This is a pretty frequently asked question in #mediawiki -- most
database errors are probably due to not running update.php.
2010-09-05 17:40:47 +00:00
Siebrand Mazeland
64fdb18e74 More whitespace updates for files touched in r72342:
* stylize.php run
* code formatting updates
* updated a few comments
* added braces where not used
2010-09-04 13:48:16 +00:00
Mark A. Hershberger
5dbbca7331 w/s changes 2010-09-04 01:06:34 +00:00
Chad Horohoe
ed7ff76d50 Move createTables() up a level, this code was practically identical 2010-09-01 19:03:56 +00:00
Sam Reed
fc38716f49 ApiBase.php:
"Don't show No more than 500 ( for bots) allowed" when MAX2 isn't set

Trim trailing whitespace from Database.php
2010-08-31 21:06:01 +00:00
Sam Reed
c59434f37f Spaces and braces 2010-08-30 20:28:32 +00:00
Chad Horohoe
9e6c7cc8ef Get rid of PHP4-style constructors 2010-08-30 16:52:51 +00:00
Sam Reed
050d94ccba Revert insertOrUpdate work
Will mark relevant revisions as reverted on CR as appropriate
2010-08-27 17:35:07 +00:00
Aryeh Gregor
7e8bef4ecb Style fixes for r71609 and follow-ups
Avoid one-letter variable names, be descriptive.  Name an unused value
variable in foreach "$unused".  Add spaces where needed.  Wrap comments
at 79 columns, not some arbitrarily-selected number.  Remove blank line.
2010-08-27 16:42:18 +00:00
Chad Horohoe
dbad19adc9 Move all abstract stuff that DatabaseBase children must implement to new interface DatabaseType. Puts all of the 'must implement' things in one place. Also lets me use abstract statics, as a workaround for r71441 2010-08-26 23:10:11 +00:00
Sam Reed
d5e9d8d997 Drop $options from insertOrUpdate - r71662 2010-08-26 22:31:49 +00:00
Sam Reed
fb627b636a Followup r71662
Update fname (same for DatabaseMysql)

Add missing spaces, remove superfluous makeList() call
2010-08-26 22:23:03 +00:00
Sam Reed
84d8dd59cd Followup r71662, remove debug code 2010-08-26 14:14:14 +00:00
Sam Reed
00a9c4f253 Fill out insertOrUpdate in DatabaseBase, rather than blank stub. Followup to r71634 2010-08-25 21:46:45 +00:00
Sam Reed
ebb8c9f929 Improve comment for $uniqueIndexes r71644 2010-08-25 19:08:52 +00:00
Sam Reed
931d48c3fc Replace todo with documentation with partial
Move brace
2010-08-25 18:50:36 +00:00
Sam Reed
b1ec616665 Move insertOnDupeUpdate (and rename to insertOrUpdate) to DatabaseMysql. Add todo/fixme in insertOrUpdate in DatabaseBase
Add some braces
2010-08-25 17:45:00 +00:00
Sam Reed
52a537c9df Followup r71609 add missing $ 2010-08-25 02:24:54 +00:00
Sam Reed
301a229768 Update documentation - Database:: to DatabaseBase:: considering Database:: is some legacy alias for DatabaseMySql 2010-08-25 01:24:47 +00:00
Sam Reed
9ca9ae5836 Create insertOnDupeUpdate, called by insert
Will be using soon
2010-08-25 01:03:43 +00:00
Sam Reed
40bb58a232 Param and return documentation for insert 2010-08-25 00:18:47 +00:00
Chad Horohoe
b9de087296 Be consistent with all the child classes 2010-08-22 20:57:53 +00:00
Chad Horohoe
e0cb9ef9b6 Make getSoftwareLink() static so I can use it without instantiating (and opening) a bunch of databases I probably can't support. Can't have an abstract parent now, so throw an exception for anyone who writes a child class without bothering to implement it. All of this to add some helpful text links in an infobox in the installer :) 2010-08-22 20:55:07 +00:00
Sam Reed
85af1b0901 Revert r71250 r71251 r71252 r71253
Know what the problem is, roughly, can't fix atm, so not leaving phase3 broken
2010-08-18 14:15:32 +00:00
Sam Reed
232483afcc Minor followup to r71250
Remove accidentally committed patch
2010-08-18 13:40:59 +00:00
Sam Reed
9ea1f1d388 Kill some crappy "failFunction" stuff, marked as old in r14625 2010-08-18 13:38:42 +00:00
Sam Reed
939015fac7 $bitField to $field 2010-08-18 10:02:39 +00:00
Aryeh Gregor
75e3521570 Add query count to $wgDebugDumpSql output
This makes it easy to see how many queries are being run on each view.
Also rephrased the message a bit.
2010-08-16 22:29:27 +00:00
Jeroen De Dauw
3c224e54ac Make NATURAL JOINs possible 2010-08-14 11:24:07 +00:00
Chad Horohoe
4c74490bb8 Big commit: kill almost every freeResult() call as useless 2010-08-08 12:27:48 +00:00
Ryan Bies
070122e8b9 DatabaseMssql class and related changes 2010-08-06 23:44:00 +00:00
Chad Horohoe
d6c112d38d Remove dupe implementations of begin/commit from Postgres. Also included checks for $mTrxLevel on commit/rollback, based on patch on bug 24629 2010-08-06 12:54:39 +00:00
Niklas Laxström
6314817969 Add @since for buildLike 2010-07-30 20:13:30 +00:00
Niklas Laxström
204ad71680 Mark escapeLike deprecated, since it is broken 2010-07-29 18:37:45 +00:00
Sam Reed
04f68827d0 Removal of unused globals
Removal of one setting of a variable to '', then not using further
2010-07-24 19:11:52 +00:00
Chad Horohoe
bfc9fd331e Fix r69229. This should not be abstract, return dummy in parent 2010-07-22 13:04:37 +00:00
X!
8cc3688dfd Move FakeResultWrapper to Database.php, allowing more special pages and extensions than just Special:Allmessages to use a ResultWrapper-specific class (TablePager comes to mind) 2010-07-15 22:39:48 +00:00
Max Semenik
e3b1c14542 Fixed mysqlisms in Database.php comments, abstracted getSearchEngine() 2010-07-10 10:15:59 +00:00
Chad Horohoe
c7f9869cf8 Kill deprecated function. Marked as such for ~30k revs and no callers 2010-07-09 14:15:48 +00:00
Max Semenik
775adbf329 Got rid of remaining usages of immediateBegin()/immediateCommit(), marked these functions with wfDeprecated() 2010-07-05 19:47:46 +00:00
Alexandre Emsenhuber
a643b87295 Fixed some doxygen warnings 2010-07-04 14:41:26 +00:00
Max Semenik
75d41fe3b6 Refactored Database*::getLag(): moved the default implementation to MySQL, replaced it with a proper dummy, deleted stub implementations from other classes. This adds fake lag support to all databases. 2010-07-02 13:17:28 +00:00
Max Semenik
67ebe72ade * Replaced the mess of every database class implementing filedExists() is its own way with one simple function in base class. Verified to work on MySQL, Postgres and SQLite.
* Fixed fieldInfo() on Postgres not using tableName() and thus failing for table user, for example.
* Made fieldInfo() on MySQL return false instead of throwing a query error if table does not exist. This is consistent with other databases' behaviour.
2010-07-02 10:01:09 +00:00
Platonides
62a615c6c0 Actually check sourceFile for failure, showing the error message in the install.
See report on http://permalink.gmane.org/gmane.org.wikimedia.mediawiki/33902
Fixed several tag nesting problems from setup_database().
Make sourceFile() always use text errors in the installer. It can't handle 
exceptions properly (introduced in r36211). But they are appropiate for update.php
thus the ugly branches.
The installer now always handles sourceFile() errors.
2010-04-29 21:49:58 +00:00
Max Semenik
092b9d9f92 Marked Database::newFromParams() as deprecated, cleaned up a few mysqlisms in comments 2010-04-28 18:12:42 +00:00
Brion Vibber
8eac509ab5 * (bug 14473) Add iwlinks table to track inline interwiki link usage
Like langlinks, this stores the interwiki prefix (as iwl_prefix) and full page title (as iwl_title), attached to the page doing the liking (as iwl_from -> page_id).
Unlike langlinks, there can be multiple entries stored per interwiki prefix.

Updater to add the table confirmed on MySQL, untested on SQLite but should work.
Someone may still need to add and test a PostgreSQL updater.

Refactored makeWhereFrom2d() out of LinkBatch to Database so it could be re-used for the similar mapping for the interwiki links, which need a string prefix rather than an int namespace key.
Also cleaned it up internally to reuse existing code for building where clauses from arrays. (Tim & Domas -- if the previous more verbose code was there to reduce function call and array processing overhead on very large link lists, feel free to unroll it again if the difference is measurable. Just swap the var names around from the old LinkBatch code and escape the base key value if it's not an integer, it'll be functionally equivalent.)
2010-04-16 01:40:05 +00:00
Alexandre Emsenhuber
1e2840cd31 Fixed some errors while running patchSql.php:
* Notice: Undefined variable: name in includes/db/Database.php on lines 2209 and 2212
* Fatal error: Call to undefined method DatabaseMysql::fileSource() in maintenance/patchSql.php on line 48
2010-03-14 15:48:29 +00:00
Mark A. Hershberger
564dafbdcf whitespace. 2010-03-06 18:14:11 +00:00
Max Semenik
eff719b75d Fixed r61214: moved MySQL munging to SearchEngine, updated calls. Can we kill $doStrip now? 2010-01-22 20:36:26 +00:00
Platonides
33917224dc (bug 21870) Remove Google logo loaded from it servers (privacy concern).
The form is now left as googlesearch message. We should probably remove the duplication and load it with wfMsgWeirdKey.
2010-01-20 22:01:37 +00:00
Max Semenik
f6dee6c1e7 Factored MySQL-specific munging out of Language::stripForSearch() to DatabaseMysql. This will also allow other backends to provide seamlessly their own munging algorithms in the future. 2010-01-18 20:54:43 +00:00
Tim Starling
fd3794c5bc For r60757: implement Database::getType() explicitly in each subclass, to make Roan happy. 2010-01-08 00:31:24 +00:00
Tim Starling
071bbbe218 Add a Database::getType() function so that we can get rid of $wgDBtype in favour of OOP goodness. 2010-01-07 00:22:18 +00:00
Sam Reed
b6e0df246f Attempt at normalistion of comparison styles - empty string on left and right hand side normalised to it being on the rhs
Before this change, there were (? being regex 0 or 1)

"" ===? 1
'' ===? 24
"" !==? 8
'' !==? 32

== "" 14
== '' 344
!= "" 9
!== "" 4
!= '' 151
!== '' 85


Rhs was the much more common, and the preferred style by many developers.. (Was a similar discussion in #mediawiki recently.. After that lolbugreport i think)

Where there is a string (non empty) on the lhs, and variable/method call on the rhs still need normalising
2010-01-06 19:59:42 +00:00
Tim Starling
ddd5acf900 Don't count unions of bracketed selects as being write queries 2010-01-06 04:05:49 +00:00
Chad Horohoe
b19e37425a Update callers from immediateCommit() to commit(). The former's been deprecated a really long time...Tim did it 45243 revisions ago. 2009-12-14 23:05:35 +00:00
Chad Horohoe
a4e5e935b6 Mass convert NULL -> null. Left strings and comments alone, obviously. 2009-12-11 21:07:27 +00:00
Max Semenik
25009de080 Per CR for r58631, moved default duplicateTableStructure() implementation to DatabaseMysql, replacing it with 'not implemented' exception throw 2009-12-11 19:53:10 +00:00
Max Semenik
1e3b2b8d5d Abstracted some parts of database interaction for parser tests, needs verification on Postgres. SQLite still doesn't work, though fails much later 2009-11-06 10:17:44 +00:00
Max Semenik
ae57ab1eec (bug 20275) Fixed LIKE queries on SQLite backend
* All manually built LIKE queries in the core are replaced with a wrapper function Database::buildLike()
* This function automatically performs all escaping, so Database::escapeLike() is now almost never used
2009-10-21 19:53:03 +00:00
Max Semenik
7055d6416d (bug 20268) Fixed Database::estimateRowCount on SQLite backend. This involved moving the previous implementation to where it belongs - DatabaseMysql, and replacing it with slightly tweaked DB2 implementation. 2009-10-21 12:21:09 +00:00
Max Semenik
c668e71421 (bug 20256) Fixed SQL errors on Special:Recentchanges and Special:Recentchangeslinked on SQLite backend 2009-10-17 12:23:23 +00:00
Tim Starling
80be14530c Added $wgShowDBErrorBacktrace, to allow users to easily gather backtraces for database connection and query errors. We've had a few LocalisationCache bugs that required backtraces to track down. 2009-09-04 01:49:34 +00:00
Aryeh Gregor
72ae064ca7 Whitespace 2009-08-25 18:57:47 +00:00
Alexandre Emsenhuber
41a2f8676c * (bug 15475) DatabaseBase::setFlag(), DatabaseBase::clearFlag() and DatabaseBase::getFlag() now have documentation 2009-08-24 08:54:28 +00:00
Alex Z
374b9e4af1 Mostly revert r53358 and r53365 per comments on code review. Change message to just say "Database" and remove the getDBtypeForMsg function (since I can't think of any other use for it) 2009-08-22 20:17:28 +00:00
Brion Vibber
620d56fc95 fix up doc comment on Database::buildConcat() 2009-08-19 18:28:59 +00:00
Chad Horohoe
c8cfe97d4e Spacing and declare public. 2009-08-15 19:17:56 +00:00
Tim Starling
84b6a177f1 * Converted BagOStuff.php from the style of memcached-client.php to the standard MediaWiki style, including camel case, using protected visibility instead of initial underscore, abstract functions instead of stubs, stylize.php.
* In SqlBagOStuff, ignore errors due to a read-only database, per my comments on CR r42796. Same for LocalisationCache. 
* Merged SqlBagOStuff and MediaWikiBagOStuff, that proved to be an awkward and unnecessary generalisation. Use the standard quoting wrapper functions instead of $db->query(). 
* Implemented atomic incr() and decr() functions for SqlBagOStuff. 
* Made incr() and decr() generally work roughly the same as it does in memcached, respecting negative steps instead of ignoring such operations. This allows decr() to be implemented in terms of incr().
* Per bug 11533, in MessageCache.php, don't retry 20 times on a cache failure, that's really memcached-specific and won't be useful for other cache types. It's not really very useful for memcached either.
* Moved MySQL-specific implementations of wasDeadlock() and wasErrorReissuable() to DatabaseMysql.
* Briefly tested page views with $wgReadOnly=read_only=1, fixed an error from Article::viewUpdates(). A CentralAuth fix will be in a subsequent commit.
2009-08-15 03:45:19 +00:00
Tim Starling
154ac68167 In Database::getLag(): Add some more I/O thread states. 2009-08-12 03:47:52 +00:00
Chad Horohoe
1e87cd3a7f patchPath not patchPatch 2009-08-09 15:27:29 +00:00
Chad Horohoe
a82c01a4b2 * Use DB_ADMIN for fixSlaveDesync, rebuildtextindex, updateSearchIndex, patchSql
* Duplicate archive() as DatabaseBase::patchPath(), clean up patchSql to use this
2009-08-09 15:22:34 +00:00
Chad Horohoe
df296de32e * Move generic return true; various for lock functions to parent, no need to implement this everywhere
* Make LOW PRIORITY optional
* Use sourceFile instead of dbsource
2009-07-29 23:41:16 +00:00
Greg Sabino Mullane
e8da51a574 Add standardSelectDistinct() function to help fork queries based on whether the order by items must appear in the select distinct list. See bug 18078. 2009-07-20 02:20:15 +00:00
Alex Z
bc1b8182e9 Followup to r53358 - Tweak the function name to be a little clearer as to what it does
Also make it abstract in DatabaseBase so all subclasses have to implement some human readable name 
(also make getSoftwareLink abstract for the same reason) Every current Database class already implements both.
2009-07-16 16:49:09 +00:00
Alex Z
3742d1058d (bug 19590) Database error messages are no longer hardcoded to use "MySQL".
Added a new function DatabaseBase::getDBtype() to get the DB type for messages, updated all subclasses.
Message change needs propagating.
2009-07-16 15:18:57 +00:00
Chad Horohoe
9924b70059 (bug 19591) Move setBigSelects() to DatabaseMysql 2009-07-09 00:14:43 +00:00
Chad Horohoe
f50573c33d * Move lock()/unlock() to DatabaseMysql, declare abstract
* Introduce lockTables() and unlockTables(), define in DatabaseMysql
* (bug 19372) updateSearchIndex has MySQLisms.
2009-06-25 00:40:12 +00:00
Aryeh Gregor
9244ed0c57 Abstract more methods in DatabaseBase
Notably, this will switch conditional() in MySQL from using IF() to
using CASE, like all other DBMSes.  Documentation suggests this works
back to 4.0.  If it's a problem, it's a matter of a few lines to
override it in DatabaseMysql.php.

Also, some extra explanatory comments have been added to a number of
methods in DatabaseBase.
2009-06-16 21:00:38 +00:00
Aryeh Gregor
2b83b91906 Make some Database methods optional to override
Specifically freeResult(), selectDB(), close(), and ping(), as suggested
by Tim on code review for r51918.  Where these were overridden by stubs
in subclasses, I deleted the stubs.
2009-06-16 20:22:11 +00:00
Aryeh Gregor
31492fc3f1 Move some stuff from DatabaseBase to DatabaseMysql
I moved a number of methods and marked them abstract in DatabaseBase,
namely those that met the following criteria:

1) Used some mysql_* function, so would obviously fail on any other DB.
2) Were already implemented by all five non-MySQL subclasses.

It would be reasonable to revisit these and make the less essential ones
return a dummy value instead of being abstract.  And document them.  And
move more methods that are MySQL-specific.  But one thing at a time.

I also split the classes Database, DatabaseMysql, and MySQLMasterPos to
DatabaseMysql.php.

This should theoretically have no practical changes, but it's a bunch of
changed code, so it will possibly break something by accident.

Followup to r51795.
2009-06-15 18:39:41 +00:00
Alex Z
0df1c0bdbd fix typo in comment 2009-06-15 18:38:15 +00:00
Aryeh Gregor
2f42924f36 Use parentheses for bit* to be on the safe side
Follow-up to r51815.
2009-06-14 20:13:17 +00:00
Niklas Laxström
ea0f52679f Follow-up to r?????:
PHP Catchable fatal error:  Argument 1 passed to DBError::__construct() must be an instance of Database, instance of DatabaseMysql given, called in /var/www/w/includes/db/Database.php on line 2736 and defined in /var/www/w/includes/db/Database.php on line 2547
2009-06-13 08:57:33 +00:00
Jure Kajzer
c3fafd96f7 Added bitwise operations to DatabaseBase and overloaded in DatabaseOracle. 2009-06-13 06:31:38 +00:00
Chad Horohoe
adb5b636dd Expect DatabaseBase, not Database. 2009-06-12 21:54:29 +00:00
Aryeh Gregor
d20794df5c Make Database into abstract class DatabaseBase
All other databases were changed to extend DatabaseBase instead of
Database.  Database was kept as an alias for DatabaseMysql for
compatibility.  Existing explicit references to Database that I could
find were changed to DatabaseMysql for the sake of clarity.

Should cause no functional changes.
2009-06-12 17:59:04 +00:00
Tim Starling
cb3bbe1809 Implemented save/restore logic for sql_big_selects, per CR comments on r50168. 2009-05-27 06:10:48 +00:00
Jure Kajzer
95f953b5c3 Preparations for Oracle database abstraction update. Take II.
Replaced hardcoded LIMIT clauses with database function (except in maintenance).
Created unionQueries in Database and overloaded it in DatabaseOracle (not commited yet).
Replaced all UNION clauses with function calls (except in maintenance).
2009-05-19 16:58:56 +00:00
Tim Starling
73776463f7 Fix breakage of SQLite ResultWrapper due to r45769. The "result" member in SQLite is actually an array and so passing by value to DatabaseSqlite::fetchObject() makes it fail to iterate. We can't really pass it by reference since that's an E_STRICT error due to a parameter type mismatch with Database. Pass the ResultWrapper instead.
This means that nothing at all should be passing bare result objects/arrays to Database*::fetchObject() anymore. The "instanceof ResultWrapper" logic can be removed in a subsequent commit. It can stay in this one for now for safer backport to 1.15.
2009-05-15 02:49:06 +00:00
Tim Starling
967eb9b0f0 Log function name for SHOW PROCESSLIST query in getLag(). 2009-04-30 05:23:25 +00:00
Alexandre Emsenhuber
dc70a8b270 Catch exceptions, since this part is likely to throw an exeception and use the default page if it occured. 2009-04-02 19:44:33 +00:00
Aaron Schulz
fcd22b9a84 More visual and xhtml fixes for file cache failback 2009-03-14 03:16:05 +00:00
Aaron Schulz
6cd1a1b1d9 * Avoid double output on filecache failover
* XHTML fixes to error html
* Added isDisabled() to OutputPage
* Make sure filecache marks output done
2009-03-13 20:15:16 +00:00
Tim Starling
8653947b06 * Skip COMMIT query when no write queries have been done.
* Improvement to ChronologyProtector: only record the master position if a write query was done. This should help to avoid the worst of the ChronologyProtector side-effects, such as having action=raw CSS requests block for a time equivalent to the slave lag on every page view, while maintaining the benefits, like preventing a 404 from being displayed after page creation.
2009-02-17 14:06:42 +00:00
Tim Starling
b45af1125c Added basic support for Wietse Venema's taint feature. Fixed a few instances of shoddy code that it turned up, no actual vulnerabilities yet. 2009-02-04 09:10:32 +00:00
Niklas Laxström
4f4501c24f * Cleanup database error message code
* (bug 7480) Internationalize database error message
2009-01-31 19:49:41 +00:00
Niklas Laxström
64c295e4ac * Escape backslashes before normal escaping, to not counteract the effect 2009-01-26 21:00:21 +00:00
Niklas Laxström
794eb21733 * (bug 17150) escapeLike now escapes literal \ properly 2009-01-25 09:12:41 +00:00
Roan Kattouw
41c9123723 Partial redo of r45819:
* rename non-PRIMARY indices that were implicitly named before r45764 back to their implicit names
* add the renamed un_user_id and un_user_ip to the indexName() rewrite
* use consistent casing for PRIMARY KEY
2009-01-19 14:12:59 +00:00
Roan Kattouw
a7c7a3fd33 Revert r45821, r45830, r45831 and r45835 all in order to revert r45819, per discussions on CR. Will redo part of r45819 momentarily. 2009-01-19 13:56:08 +00:00
Roan Kattouw
21ead1462a Fix up r45819 per CR comments: removing calls to removed function Database::indexName() 2009-01-17 09:56:38 +00:00
Roan Kattouw
312316088e Attempt at cleaning up r45764, r45769 (renamed indices for SQLite compat):
* removing the indexName() hack and with it the /*i*/ stuff from tables.sql
* undoing renames of formerly implicitly named indices
* three indices have to be called different in SQLite because of naming conflicts, adding a patch to updaters.inc that does that
2009-01-16 23:02:44 +00:00
Tim Starling
f058162bc5 * Preserve usertext_timestamp index name for MySQL, prefix it for SQLite. Issues remain on the experimental non-installable DBMSes.
* Clean up some E_STRICT issues
2009-01-15 14:20:28 +00:00
Tim Starling
4124558d7b For backport to 1.14.
* Made the upgrader work with SQLite
* Implemented missing schema info functionality in DatabaseSqlite
* Merged the SQLite and MySQL schemas into the one file with the help of some replaceVars() hacks.
* Moved all primary key definitions to the field definition, moved all indexes to CREATE INDEX statements, for best SQLite compatibility.
* Made all autoincrement fields primary keys, as required by SQLite.
* Removed meaningless buzzword from the category table comment
* tables.sql: s/'0'/0/
* In SQLite the index names have DB scope. Renamed archive.usertext_timestamp, user_newtalk.user_id, user_newtalk.user_ip
* SQLite does not support UPDATE with LIMIT by default. Removed all instances I could find.
* Made query errors work in the installer.
* Fixed DatabaseSqlite::lastErrno(), made SQLITE_SCHEMA errors automatically reissue the query as suggested on sqlite-users. Otherwise upgrade breaks.
* Removed miscellaneous status information from getServerVersion(), that's not the place to put it
2009-01-15 06:56:58 +00:00
Tim Starling
db22292391 * In selectField(), use reset($row) instead of $row[0] for compatibility with SQLite
* Non-broken (no-op) implementation of DatabaseSqlite::deadlockLoop(). Fixes bug 16123: total breakage of Special:Import on SQLite.
2009-01-09 03:53:28 +00:00
Andrew Garrett
c2ac8f8dfb DB layer compatibility with MySQL 5+ - allow both >Exec_master_log_pos and ->Exec_Master_Log_Pos in SHOW SLAVE STATUS. 2008-12-09 15:00:17 +00:00
Alexandre Emsenhuber
7bb2cada63 * fixed Doxygen errors in Database.php, DatabasePostgres.php, DatabaseOracle.php and DatabaseMssql.php
* renamed \2types and \3types both to \types (with different number of param), Doxygen doesn't seem to like numbers in aliases
* Added aliases for @private, @protected and @public
2008-11-29 18:50:39 +00:00
Tim Starling
5688ff12c8 Fixed getSlavePos() to use the SQL thread fields, not the IO thread fields. 2008-10-13 14:19:25 +00:00
Tim Starling
90ed80443e (bug 12586) Use wfHostname() everywhere, remove $wguname and $wgNodeName. Use getenv('COMPUTERNAME') on Windows. 2008-10-06 07:30:38 +00:00
Tim Starling
0d322a394e * Allow $wgDiff3=false
* Don't call quickUserCan('edit') unless section edit is enabled
* In DatabasePostgres and DatabaseSqlite: throw an exception on connection error
* In DatabasePostgres: don't send an invalid connection string whenever one of the fields is empty. Use quoting.
* In Database: make the captured PHP error prettier
* Display a descriptive error message when the user navigates to index.php with PHP 4, not a parse error. Check to see if the *.php5 extension works, using file_get_contents().
* The default port number for PostgreSQL is 5432, not blank.
* Better default for $wgDBname
2008-10-06 00:45:18 +00:00
Tim Starling
f1a352ccf9 * Revert revert r41234 of ES-related changes. The site_stats complaint should be fixed by the transaction added in r41287.
* Fix broken recursion guard in LoadBalancer::reportConnectionError(), which was causing getConnection() to return false on the second and subsequent errors, instead of throwing an exception. Revert incorrect fix r41229/r41230.
2008-09-28 01:42:55 +00:00
Brion Vibber
c4bbaf94c0 Revert some recent ES-related changes -- they made behavior much worse when we encountered problems with site_stats updates hanging and stacking up extra open ES connections.
r41230
r41229
r41093
r41091
r41092
r41086
r41063
r40696

Also reverted r41231 which no longer applies
2008-09-24 18:09:22 +00:00
Tim Starling
18e147f399 Logging tweaks 2008-09-21 08:28:21 +00:00
Tim Starling
45308adee2 Debugging code left in, probably needs an option of some kind. 2008-09-21 08:10:48 +00:00
Tim Starling
cd8378a5a6 Revert/rewrite of r40696.
* We used to have parameters to ignore errors, but they're obsolete now that we have exceptions. Implemented ES master failover using exceptions instead. 
* Changing the number of DB connection attempts from 3 to 2 for some random getConnection() calls is almost pointless, adds lots of ugly formal parameters all of the place, and misses the big picture. It should be 2 by default, based on the original rationale. Any reasonable implementation of failover should have zero timeouts per request, by storing state. Changed the default to 2, or 1 if a long timeout is set.
2008-09-21 06:42:46 +00:00
Tim Starling
9b8782aaa8 Don't run hour-long, unlimited row-count DB queries with set_time_limit(0) in response to unauthenticated web requests on the master. Run them on the slave instead. Maybe we can crash the whole cluster instead of just a master or two.
Don't use DB_LAST, ever again.
2008-09-20 15:00:53 +00:00
Tim Starling
e810660f91 * Always log connection errors
* Don't try to fetch the site notice, it will fail with the current code
2008-09-20 08:33:52 +00:00
Aaron Schulz
674f6f9bd5 $msg not defined...use $text? 2008-09-13 16:00:38 +00:00
Aaron Schulz
7b61c1972a ExternalStore tweaks:
* On read, spend less time checking on dead slaves
* Add randomInsert() to ES. This does the cluster picking for us
* Make revision text use randomInsert(). On write, fails-over to other clusters as needed instead of throwing db errors
2008-09-10 12:07:56 +00:00
Chad Horohoe
1f8b22edde Typo in comment. 2008-09-08 14:06:04 +00:00
Chad Horohoe
a374cf1101 Document isOpen() and lastQuery(). (set|clear|get)Flag still need some lovin'...I just don't know what they do. 2008-09-05 03:41:31 +00:00
Chad Horohoe
e8ad8d066d Remove DB logic from SearchEngine. New method in Database and associated subclasses called getSearchEngine() does this now. 2008-08-18 15:22:00 +00:00
Brion Vibber
dff6e3ae0b Don't die horribly from sql.php when making INSERT/DELETE/UPDATE/CREATE TABLE/etc calls that return 'true' instead of a result object.
Code was attempting to handle this case by asking the result object for its db so we can ask for the affected row count -- obviously that doesn't do so good when the result is not an object.
Changed Database::sourceStream() to send itself as the second parameter to the result-handling callback, so the callback knows which DB to check.
2008-08-01 21:00:24 +00:00
Alexandre Emsenhuber
056663a1d5 Missing param to wfDeprecated() 2008-07-08 17:27:50 +00:00
Tim Starling
c0a02eca70 * LBFactory is not really much of a factory if it doesn't have new*() functions, is it? Introduced them, for use in parserTests.inc.
* Came up with a neater way to micro-optimise local section determination.
* Renamed LBFactory::destroy() to LBFactory::destroyInstance(), and made it close connections since apparently that's not done by default when the connection resources are destroyed.
* Removed Database::$mOut, hasn't been used for a while and it dirties up var_dump($db)
2008-07-08 10:41:08 +00:00
Brion Vibber
7b78f7b7aa Revert r36755 for the moment; various things use 'new Database'
or Database::newFromParams() explicitly at the moment. While that's already bad (breaking PG support etc), I'd rather see those get fixed before we go introducing differences between Database and DatabaseMySql.
2008-07-02 18:22:38 +00:00
Merlijn S. van Deen
c1255ba7d1 bugfix: $wgSharedprefix -> $wgSharedPrefix (the correct global) 2008-06-28 12:31:59 +00:00
Chad Horohoe
de58074c74 Refactoring (un)lock. All the subclasses are currently returning true, except for mySQL. Makes more sense to put the no-op in the parent class then just subclass it as needed. Other things could maybe do this too. 2008-06-27 17:06:34 +00:00
Tim Starling
c6b902f180 * Reorganised the includes directory, creating subdirectories db, parser and specials
* Wrote a tool to check the integrity of the autoloader class list, fixed some issues that came up.
* Start the autoloader before LocalSettings.php, so that when an extension writer thinks an inefficient one-file special page extension is the way to go, they don't have to use explicit includes to make the class inheritance work. Should continue to work with $IP set in LocalSettings.php as long as $IP is set before extensions are included.
2008-06-16 20:21:26 +00:00
Renamed from includes/Database.php (Browse further)