Add $fname to tableExists
authorSam Reed <reedy@users.mediawiki.org>
Thu, 10 Nov 2011 20:39:23 +0000 (20:39 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 10 Nov 2011 20:39:23 +0000 (20:39 +0000)
Pass $fname/__METHOD__ in in upstream callers

includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/installer/DatabaseInstaller.php
includes/installer/DatabaseUpdater.php
includes/installer/MysqlInstaller.php
includes/installer/MysqlUpdater.php

index 4d56a5c..02839c3 100644 (file)
@@ -1528,13 +1528,14 @@ abstract class DatabaseBase implements DatabaseType {
         * Query whether a given table exists
         *
         * @param $table string
+        * @param $fname string
         *
         * @return bool
         */
-       function tableExists( $table ) {
+       function tableExists( $table, $fname = __METHOD__ ) {
                $table = $this->tableName( $table );
                $old = $this->ignoreErrors( true );
-               $res = $this->query( "SELECT 1 FROM $table LIMIT 1", __METHOD__ );
+               $res = $this->query( "SELECT 1 FROM $table LIMIT 1", $fname );
                $this->ignoreErrors( $old );
 
                return (bool)$res;
@@ -3311,7 +3312,7 @@ abstract class DatabaseBase implements DatabaseType {
         * @since 1.18
         */
        public function dropTable( $tableName, $fName = 'DatabaseBase::dropTable' ) {
-               if( !$this->tableExists( $tableName ) ) {
+               if( !$this->tableExists( $tableName, $fName ) ) {
                        return false;
                }
                $sql = "DROP TABLE " . $this->tableName( $tableName );
index 2f225d5..67ca80a 100644 (file)
@@ -492,7 +492,7 @@ class DatabaseIbm_db2 extends DatabaseBase {
         * Queries whether a given table exists
         * @return boolean
         */
-       public function tableExists( $table ) {
+       public function tableExists( $table, $fname = __METHOD__ ) {
                $schema = $this->mSchema;
 
                $sql = "SELECT COUNT( * ) FROM SYSIBM.SYSTABLES ST WHERE ST.NAME = '" .
index cbdf89c..339c59b 100644 (file)
@@ -631,7 +631,7 @@ class DatabaseMssql extends DatabaseBase {
                return $version;
        }
 
-       function tableExists ( $table, $schema = false ) {
+       function tableExists ( $table, , $fname = __METHOD__, $schema = false ) {
                $res = sqlsrv_query( $this->mConn, "SELECT * FROM information_schema.tables
                        WHERE table_type='BASE TABLE' AND table_name = '$table'" );
                if ( $res === false ) {
index 734cdae..687ebf3 100644 (file)
@@ -787,7 +787,7 @@ class DatabaseMysql extends DatabaseBase {
         * @return bool|ResultWrapper
         */
        public function dropTable( $tableName, $fName = 'DatabaseMysql::dropTable' ) {
-               if( !$this->tableExists( $tableName ) ) {
+               if( !$this->tableExists( $tableName, $fName ) ) {
                        return false;
                }
                return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName );
index cafd1e9..664e7da 100644 (file)
@@ -856,7 +856,7 @@ class DatabaseOracle extends DatabaseBase {
        /**
         * Query whether a given table exists (in the given schema, or the default mw one if not given)
         */
-       function tableExists( $table ) {
+       function tableExists( $table, $fname = __METHOD__ ) {
                $table = $this->tableName( $table );
                $table = $this->addQuotes( strtoupper( $this->removeIdentifierQuotes( $table ) ) );
                $owner = $this->addQuotes( strtoupper( $this->mDBname ) );
@@ -1316,9 +1316,9 @@ class DatabaseOracle extends DatabaseBase {
        public function getSearchEngine() {
                return 'SearchOracle';
        }
-       
+
        public function getInfinity() {
                return '31-12-2030 12:00:00.000000';
        }
-       
+
 } // end DatabaseOracle class
index d991680..f51640d 100644 (file)
@@ -771,7 +771,7 @@ class DatabasePostgres extends DatabaseBase {
         * For backward compatibility, this function checks both tables and
         * views.
         */
-       function tableExists( $table, $schema = false ) {
+       function tableExists( $table, $fname = __METHOD__, $schema = false ) {
                return $this->relationExists( $table, array( 'r', 'v' ), $schema );
        }
 
index 6e002ec..fca8661 100644 (file)
@@ -148,7 +148,7 @@ abstract class DatabaseInstaller {
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 
-               if( $this->db->tableExists( 'user' ) ) {
+               if( $this->db->tableExists( 'user', __METHOD__ ) ) {
                        $status->warning( 'config-install-tables-exist' );
                        $this->enableLB();
                        return $status;
@@ -466,7 +466,7 @@ abstract class DatabaseInstaller {
                if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) {
                        return false;
                }
-               return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' );
+               return $this->db->tableExists( 'cur', __METHOD__ ) || $this->db->tableExists( 'revision', __METHOD__ );
        }
 
        /**
index 7410594..4f6e7a9 100644 (file)
@@ -315,7 +315,7 @@ abstract class DatabaseUpdater {
         * @return boolean
         */
        protected function canUseNewUpdatelog() {
-               return $this->db->tableExists( 'updatelog' ) &&
+               return $this->db->tableExists( 'updatelog', __METHOD__ ) &&
                        $this->db->fieldExists( 'updatelog', 'ul_value' );
        }
 
@@ -399,7 +399,7 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function addTable( $name, $patch, $fullpath = false ) {
-               if ( $this->db->tableExists( $name ) ) {
+               if ( $this->db->tableExists( $name, __METHOD__ ) ) {
                        $this->output( "...$name table already exists.\n" );
                } else {
                        $this->output( "Creating $name table..." );
@@ -416,7 +416,7 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function addField( $table, $field, $patch, $fullpath = false ) {
-               if ( !$this->db->tableExists( $table ) ) {
+               if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...$table table does not exist, skipping new field patch\n" );
                } elseif ( $this->db->fieldExists( $table, $field ) ) {
                        $this->output( "...have $field field in $table table.\n" );
@@ -486,7 +486,7 @@ abstract class DatabaseUpdater {
         * @param $fullpath bool
         */
        protected function dropTable( $table, $patch, $fullpath = false ) {
-               if ( $this->db->tableExists( $table ) ) {
+               if ( $this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "Dropping table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "ok\n" );
@@ -505,7 +505,7 @@ abstract class DatabaseUpdater {
         */
        public function modifyField( $table, $field, $patch, $fullpath = false ) {
                $updateKey = "$table-$field-$patch";
-               if ( !$this->db->tableExists( $table ) ) {
+               if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...$table table does not exist, skipping modify field patch\n" );
                } elseif ( !$this->db->fieldExists( $table, $field ) ) {
                        $this->output( "...$field field does not exist in $table table, skipping modify field patch\n" );
index 43587ca..eed004a 100644 (file)
@@ -164,7 +164,7 @@ class MysqlInstaller extends DatabaseInstaller {
                $conn->selectDB( $this->getVar( 'wgDBname' ) );
 
                # Determine existing default character set
-               if ( $conn->tableExists( "revision" ) ) {
+               if ( $conn->tableExists( "revision", __METHOD__ ) ) {
                        $revision = $conn->buildLike( $this->getVar( 'wgDBprefix' ) . 'revision' );
                        $res = $conn->query( "SHOW TABLE STATUS $revision", __METHOD__ );
                        $row = $conn->fetchObject( $res );
index ad6f7fa..1e323f2 100644 (file)
@@ -243,7 +243,7 @@ class MysqlUpdater extends DatabaseUpdater {
        protected function doInterwikiUpdate() {
                global $IP;
 
-               if ( $this->db->tableExists( "interwiki" ) ) {
+               if ( $this->db->tableExists( "interwiki", __METHOD__ ) ) {
                        $this->output( "...already have interwiki table\n" );
                        return;
                }
@@ -315,7 +315,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        function doSchemaRestructuring() {
-               if ( $this->db->tableExists( 'page' ) ) {
+               if ( $this->db->tableExists( 'page', __METHOD__ ) ) {
                        $this->output( "...page table already exists.\n" );
                        return;
                }
@@ -506,7 +506,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doPagelinksUpdate() {
-               if ( $this->db->tableExists( 'pagelinks' ) ) {
+               if ( $this->db->tableExists( 'pagelinks', __METHOD__ ) ) {
                        $this->output( "...already have pagelinks table.\n" );
                        return;
                }
@@ -555,7 +555,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doUserGroupsUpdate() {
-               if ( $this->db->tableExists( 'user_groups' ) ) {
+               if ( $this->db->tableExists( 'user_groups', __METHOD__ ) ) {
                        $info = $this->db->fieldInfo( 'user_groups', 'ug_group' );
                        if ( $info->type() == 'int' ) {
                                $oldug = $this->db->tableName( 'user_groups' );
@@ -582,7 +582,7 @@ class MysqlUpdater extends DatabaseUpdater {
                $this->applyPatch( 'patch-user_groups.sql' );
                $this->output( "ok\n" );
 
-               if ( !$this->db->tableExists( 'user_rights' ) ) {
+               if ( !$this->db->tableExists( 'user_rights', __METHOD__ ) ) {
                        if ( $this->db->fieldExists( 'user', 'user_rights' ) ) {
                                $this->output( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
                                $this->db->applyPatch( 'patch-user_rights.sql' );
@@ -651,7 +651,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doTemplatelinksUpdate() {
-               if ( $this->db->tableExists( 'templatelinks' ) ) {
+               if ( $this->db->tableExists( 'templatelinks', __METHOD__ ) ) {
                        $this->output( "...templatelinks table already exists\n" );
                        return;
                }
@@ -709,7 +709,7 @@ class MysqlUpdater extends DatabaseUpdater {
         * -- Andrew Garrett, January 2007.
         */
        protected function doRestrictionsUpdate() {
-               if ( $this->db->tableExists( 'page_restrictions' ) ) {
+               if ( $this->db->tableExists( 'page_restrictions', __METHOD__ ) ) {
                        $this->output( "...page_restrictions table already exists.\n" );
                        return;
                }
@@ -760,7 +760,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doMaybeProfilingMemoryUpdate() {
-               if ( !$this->db->tableExists( 'profiling' ) ) {
+               if ( !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
                        // Simply ignore
                } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory' ) ) {
                        $this->output( "...profiling table has pf_memory field.\n" );