From: Sam Reed Date: Thu, 10 Nov 2011 20:39:23 +0000 (+0000) Subject: Add $fname to tableExists X-Git-Tag: 1.31.0-rc.0~26585 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=9814e6b075f0b146708ad880de208c9f2dc15c20;p=lhc%2Fweb%2Fwiklou.git Add $fname to tableExists Pass $fname/__METHOD__ in in upstream callers --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 4d56a5cfe4..02839c33ec 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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 ); diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index 2f225d530e..67ca80a4ae 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -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 = '" . diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index cbdf89ca73..339c59bd0c 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -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 ) { diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 734cdae3d9..687ebf3eb6 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -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 ); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index cafd1e94c2..664e7da609 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -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 diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index d991680fe9..f51640da5a 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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 ); } diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 6e002ec77f..fca866190f 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -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__ ); } /** diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 74105943d9..4f6e7a9dd6 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -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" ); diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 43587ca104..eed004a5e3 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -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 ); diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index ad6f7fa327..1e323f2d51 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -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" );