jenkins-bot has submitted this change and it was merged.

Change subject: Remove wf* function and global variable usage from 
DatabaseSqlite
......................................................................


Remove wf* function and global variable usage from DatabaseSqlite

Change-Id: I81753621ecd1e7e3b099243b4c4d0f3428bf9ae2
---
M includes/ServiceWiring.php
M includes/db/DatabaseSqlite.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 31 insertions(+), 39 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 7a34b3a..7cd62ce 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -57,6 +57,9 @@
                if ( $class === 'LBFactorySimple' ) {
                        if ( is_array( $mainConfig->get( 'DBservers' ) ) ) {
                                foreach ( $mainConfig->get( 'DBservers' ) as $i 
=> $server ) {
+                                       if ( $server['type'] === 'sqlite' ) {
+                                               $server += [ 'dbDirectory' => 
$mainConfig->get( 'SQLiteDataDir' ) ];
+                                       }
                                        $lbConf['servers'][$i] = $server + [
                                                'schema' => $mainConfig->get( 
'DBmwschema' ),
                                                'tablePrefix' => 
$mainConfig->get( 'DBprefix' ),
@@ -70,22 +73,25 @@
                                $flags |= $mainConfig->get( 'DebugDumpSql' ) ? 
DBO_DEBUG : 0;
                                $flags |= $mainConfig->get( 'DBssl' ) ? DBO_SSL 
: 0;
                                $flags |= $mainConfig->get( 'DBcompress' ) ? 
DBO_COMPRESS : 0;
-                               $lbConf['servers'] = [
-                                       [
-                                               'host' => $mainConfig->get( 
'DBserver' ),
-                                               'user' => $mainConfig->get( 
'DBuser' ),
-                                               'password' => $mainConfig->get( 
'DBpassword' ),
-                                               'dbname' => $mainConfig->get( 
'DBname' ),
-                                               'schema' => $mainConfig->get( 
'DBmwschema' ),
-                                               'tablePrefix' => 
$mainConfig->get( 'DBprefix' ),
-                                               'type' => $mainConfig->get( 
'DBtype' ),
-                                               'load' => 1,
-                                               'flags' => $flags,
-                                               'sqlMode' => $mainConfig->get( 
'SQLMode' ),
-                                               'utf8Mode' => $mainConfig->get( 
'DBmysql5' )
-                                       ]
+                               $server = [
+                                       'host' => $mainConfig->get( 'DBserver' 
),
+                                       'user' => $mainConfig->get( 'DBuser' ),
+                                       'password' => $mainConfig->get( 
'DBpassword' ),
+                                       'dbname' => $mainConfig->get( 'DBname' 
),
+                                       'schema' => $mainConfig->get( 
'DBmwschema' ),
+                                       'tablePrefix' => $mainConfig->get( 
'DBprefix' ),
+                                       'type' => $mainConfig->get( 'DBtype' ),
+                                       'load' => 1,
+                                       'flags' => $flags,
+                                       'sqlMode' => $mainConfig->get( 
'SQLMode' ),
+                                       'utf8Mode' => $mainConfig->get( 
'DBmysql5' )
                                ];
+                               if ( $server['type'] === 'sqlite' ) {
+                                       $server[ 'dbDirectory'] = 
$mainConfig->get( 'SQLiteDataDir' );
+                               }
+                               $lbConf['servers'] = [ $server ];
                        }
+
                        $lbConf['externalServers'] = $mainConfig->get( 
'ExternalServers' );
                }
 
diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index a52c2ed..11acde7 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -59,10 +59,6 @@
         * @param array $p
         */
        function __construct( array $p ) {
-               global $wgSQLiteDataDir;
-
-               $this->dbDir = isset( $p['dbDirectory'] ) ? $p['dbDirectory'] : 
$wgSQLiteDataDir;
-
                if ( isset( $p['dbFilePath'] ) ) {
                        parent::__construct( $p );
                        // Standalone .sqlite file mode.
@@ -70,7 +66,10 @@
                        // which is derived from the file path in this case.
                        $this->openFile( $p['dbFilePath'] );
                        $lockDomain = md5( $p['dbFilePath'] );
+               } elseif ( !isset( $p['dbDirectory'] ) ) {
+                       throw new InvalidArgumentException( "Need 'dbDirectory' 
or 'dbFilePath' parameter." );
                } else {
+                       $this->dbDir = $p['dbDirectory'];
                        $this->mDBname = $p['dbname'];
                        $lockDomain = $this->mDBname;
                        // Stock wiki mode using standard file names per DB.
@@ -95,7 +94,7 @@
                        !in_array( $this->trxMode, [ 'DEFERRED', 'IMMEDIATE', 
'EXCLUSIVE' ] )
                ) {
                        $this->trxMode = null;
-                       wfWarn( "Invalid SQLite transaction mode provided." );
+                       $this->queryLogger->warning( "Invalid SQLite 
transaction mode provided." );
                }
 
                $this->lockMgr = new FSLockManager( [
@@ -183,7 +182,7 @@
                }
 
                if ( !$this->mConn ) {
-                       wfDebug( "DB connection error: $err\n" );
+                       $this->queryLogger->debug( "DB connection error: 
$err\n" );
                        throw new DBConnectionError( $this, $err );
                }
 
@@ -726,15 +725,6 @@
        }
 
        /**
-        * @return string User-friendly database information
-        */
-       public function getServerInfo() {
-               return wfMessage( self::getFulltextSearchModule()
-                       ? 'sqlite-has-fts'
-                       : 'sqlite-no-fts', $this->getServerVersion() )->text();
-       }
-
-       /**
         * Get information about a given field
         * Returns false if the field does not exist.
         *
@@ -811,12 +801,11 @@
                        // There is an additional bug regarding sorting this 
data after insert
                        // on older versions of sqlite shipped with ubuntu 12.04
                        // https://phabricator.wikimedia.org/T74367
-                       wfDebugLog(
-                               __CLASS__,
+                       $this->queryLogger->debug(
                                __FUNCTION__ .
-                                       ': Quoting value containing null byte. 
' .
-                                       'For consistency all binary data should 
have been ' .
-                                       'first processed with 
self::encodeBlob()'
+                               ': Quoting value containing null byte. ' .
+                               'For consistency all binary data should have 
been ' .
+                               'first processed with self::encodeBlob()'
                        );
                        return "x'" . bin2hex( $s ) . "'";
                } else {
@@ -977,7 +966,8 @@
                );
                if ( $temporary ) {
                        if ( preg_match( 
'/^\\s*CREATE\\s+VIRTUAL\\s+TABLE\b/i', $sql ) ) {
-                               wfDebug( "Table $oldName is virtual, can't 
create a temporary duplicate.\n" );
+                               $this->queryLogger->debug(
+                                       "Table $oldName is virtual, can't 
create a temporary duplicate.\n" );
                        } else {
                                $sql = str_replace( 'CREATE TABLE', 'CREATE 
TEMPORARY TABLE', $sql );
                        }
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index a8dd103..67e6491 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -3793,8 +3793,6 @@
        "htmlform-user-not-exists": "<strong>$1</strong> does not exist.",
        "htmlform-user-not-valid": "<strong>$1</strong> isn't a valid 
username.",
        "rawmessage": "$1",
-       "sqlite-has-fts": "$1 with full-text search support",
-       "sqlite-no-fts": "$1 without full-text search support",
        "logentry-delete-delete": "$1 {{GENDER:$2|deleted}} page $3",
        "logentry-delete-restore": "$1 {{GENDER:$2|restored}} page $3",
        "logentry-delete-event": "$1 {{GENDER:$2|changed}} visibility of 
{{PLURAL:$5|a log event|$5 log events}} on $3: $4",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index fbf95cc..163b613 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -3977,8 +3977,6 @@
        "htmlform-user-not-exists": "Error message shown if a user with the 
name provided by the user does not exist. $1 is the username.",
        "htmlform-user-not-valid": "Error message shown if the name provided by 
the user isn't a valid username. $1 is the username.",
        "rawmessage": "{{notranslate}} Used to pass arbitrary text as a message 
specifier array",
-       "sqlite-has-fts": "Shown on [[Special:Version]].\nParameters:\n* $1 - 
version",
-       "sqlite-no-fts": "Shown on [[Special:Version]].\nParameters:\n* $1 - 
version",
        "logentry-delete-delete": "{{Logentry|[[Special:Log/delete]]}}",
        "logentry-delete-restore": "{{Logentry|[[Special:Log/delete]]}}",
        "logentry-delete-event": 
"{{Logentry|[[Special:Log/delete]]}}\n{{Logentryparam}}\n* $5 - count of 
affected log events",

-- 
To view, visit https://gerrit.wikimedia.org/r/311312
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I81753621ecd1e7e3b099243b4c4d0f3428bf9ae2
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to