summaryrefslogtreecommitdiff
path: root/includes/db/DatabaseSqlite.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/db/DatabaseSqlite.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/db/DatabaseSqlite.php')
-rw-r--r--includes/db/DatabaseSqlite.php43
1 files changed, 35 insertions, 8 deletions
diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index 112c417b..dfc506cc 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -20,11 +20,9 @@ class DatabaseSqlite extends Database {
* Constructor
*/
function __construct($server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0) {
- global $wgOut,$wgSQLiteDataDir;
+ global $wgOut,$wgSQLiteDataDir, $wgSQLiteDataDirMode;
if ("$wgSQLiteDataDir" == '') $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
- if (!is_dir($wgSQLiteDataDir)) mkdir($wgSQLiteDataDir,0700);
- if (!isset($wgOut)) $wgOut = NULL; # Can't get a reference if it hasn't been set yet
- $this->mOut =& $wgOut;
+ if (!is_dir($wgSQLiteDataDir)) wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
$this->mFailFunction = $failFunction;
$this->mFlags = $flags;
$this->mDatabaseFile = "$wgSQLiteDataDir/$dbName.sqlite";
@@ -48,11 +46,28 @@ class DatabaseSqlite extends Database {
$this->mConn = false;
if ($dbName) {
$file = $this->mDatabaseFile;
- if ($this->mFlags & DBO_PERSISTENT) $this->mConn = new PDO("sqlite:$file",$user,$pass,array(PDO::ATTR_PERSISTENT => true));
- else $this->mConn = new PDO("sqlite:$file",$user,$pass);
- if ($this->mConn === false) wfDebug("DB connection error: $err\n");;
+ try {
+ if ( $this->mFlags & DBO_PERSISTENT ) {
+ $this->mConn = new PDO( "sqlite:$file", $user, $pass,
+ array( PDO::ATTR_PERSISTENT => true ) );
+ } else {
+ $this->mConn = new PDO( "sqlite:$file", $user, $pass );
+ }
+ } catch ( PDOException $e ) {
+ $err = $e->getMessage();
+ }
+ if ( $this->mConn === false ) {
+ wfDebug( "DB connection error: $err\n" );
+ if ( !$this->mFailFunction ) {
+ throw new DBConnectionError( $this, $err );
+ } else {
+ return false;
+ }
+
+ }
$this->mOpened = $this->mConn;
- $this->mConn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT); # set error codes only, dont raise exceptions
+ # set error codes only, don't raise exceptions
+ $this->mConn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
}
return $this->mConn;
}
@@ -390,7 +405,19 @@ class DatabaseSqlite extends Database {
public function unlock( $lockName, $method ) {
return true;
}
+
+ public function getSearchEngine() {
+ return "SearchEngineDummy";
+ }
+ /**
+ * No-op version of deadlockLoop
+ */
+ public function deadlockLoop( /*...*/ ) {
+ $args = func_get_args();
+ $function = array_shift( $args );
+ return call_user_func_array( $function, $args );
+ }
}
/**