From 12c61d3e7f2c0f04e046ce35c4aace2ec46c9b98 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Wed, 7 Aug 2013 23:18:34 -0400 Subject: [PATCH] Remove remaining calls to MWInit methods ... as well as the require_once statements in includes/WebStart.php and maintenance/doMaintenance.php, now that the autoloader lists MWInit (since r85807 / c68957c5e3ada65806294bc9bc5938aa18c6e50c). Also removed code paths in maintenance/userDupes.inc that seem to be dead (class_exists( 'Revision' ) should always be true) and useless global/require_once statements in languages/Language.php. Follows-up Ic3e769f1fbad4f7ad26dd819406796fee48c6b45. Change-Id: I48fd6810fdb923b3065ae98024912eb18d394415 --- includes/WebStart.php | 3 -- languages/Language.php | 14 ++++---- maintenance/Maintenance.php | 6 ++-- maintenance/doMaintenance.php | 10 +++--- maintenance/userDupes.inc | 61 +++++------------------------------ 5 files changed, 21 insertions(+), 73 deletions(-) diff --git a/includes/WebStart.php b/includes/WebStart.php index f840a5ed78..58c953af4a 100644 --- a/includes/WebStart.php +++ b/includes/WebStart.php @@ -91,9 +91,6 @@ if ( $IP === false ) { } } -# Get MWInit class -require_once "$IP/includes/Init.php"; - # Start the autoloader, so that extensions can derive classes from core files require_once "$IP/includes/AutoLoader.php"; diff --git a/languages/Language.php b/languages/Language.php index 86639a3ae7..356726ff9d 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -30,10 +30,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { exit( 1 ); } -# Read language names -global $wgLanguageNames; -require_once __DIR__ . '/Names.php'; - if ( function_exists( 'mb_strtoupper' ) ) { mb_internal_encoding( 'UTF-8' ); } @@ -232,7 +228,7 @@ class Language { // Check if there is a language class for the code $class = self::classFromCode( $code ); self::preloadLanguageClass( $class ); - if ( MWInit::classExists( $class ) ) { + if ( class_exists( $class ) ) { $lang = new $class; return $lang; } @@ -246,7 +242,7 @@ class Language { $class = self::classFromCode( $fallbackCode ); self::preloadLanguageClass( $class ); - if ( MWInit::classExists( $class ) ) { + if ( class_exists( $class ) ) { $lang = Language::newFromCode( $fallbackCode ); $lang->setCode( $code ); return $lang; @@ -396,7 +392,8 @@ class Language { } if ( $coreLanguageNames === null ) { - include MWInit::compiledPath( 'languages/Names.php' ); + global $IP; + include "$IP/languages/Names.php"; } if ( isset( $coreLanguageNames[$tag] ) @@ -878,7 +875,8 @@ class Language { static $coreLanguageNames; if ( $coreLanguageNames === null ) { - include MWInit::compiledPath( 'languages/Names.php' ); + global $IP; + include "$IP/languages/Names.php"; } $names = array(); diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index e29ffd992b..0023c6d8ad 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -453,11 +453,11 @@ abstract class Maintenance { */ public function runChild( $maintClass, $classFile = null ) { // Make sure the class is loaded first - if ( !MWInit::classExists( $maintClass ) ) { + if ( !class_exists( $maintClass ) ) { if ( $classFile ) { require_once $classFile; } - if ( !MWInit::classExists( $maintClass ) ) { + if ( !class_exists( $maintClass ) ) { $this->error( "Cannot spawn child: $maintClass" ); } } @@ -1171,7 +1171,7 @@ abstract class Maintenance { * @return bool */ public static function posix_isatty( $fd ) { - if ( !MWInit::functionExists( 'posix_isatty' ) ) { + if ( !function_exists( 'posix_isatty' ) ) { return !$fd; } else { return posix_isatty( $fd ); diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php index 69b4b9cab1..3bd508cbfe 100644 --- a/maintenance/doMaintenance.php +++ b/maintenance/doMaintenance.php @@ -53,8 +53,6 @@ $maintenance->setup(); // to $maintenance->mSelf. Keep that here for b/c $self = $maintenance->getName(); -# Get the MWInit class -require_once "$IP/includes/Init.php"; # Start the autoloader, so that extensions can derive classes from core files require_once "$IP/includes/AutoLoader.php"; # Stub the profiler @@ -68,7 +66,7 @@ if ( file_exists( "$IP/StartProfiler.php" ) ) { // Some other requires require_once "$IP/includes/Defines.php"; -require_once MWInit::compiledPath( 'includes/DefaultSettings.php' ); +require_once "$IP/includes/DefaultSettings.php"; # Load composer's autoloader if present if ( is_readable( "$IP/vendor/autoload.php" ) ) { @@ -86,7 +84,7 @@ if ( defined( 'MW_CONFIG_CALLBACK' ) ) { # Maybe a hook? global $cluster; $cluster = 'pmtpa'; - require MWInit::interpretedPath( '../wmf-config/wgConf.php' ); + require "$IP/../wmf-config/wgConf.php"; } // Require the configuration (probably LocalSettings.php) require $maintenance->loadSettings(); @@ -95,7 +93,7 @@ if ( defined( 'MW_CONFIG_CALLBACK' ) ) { if ( $maintenance->getDbType() === Maintenance::DB_ADMIN && is_readable( "$IP/AdminSettings.php" ) ) { - require MWInit::interpretedPath( 'AdminSettings.php' ); + require "$IP/AdminSettings.php"; } if ( $maintenance->getDbType() === Maintenance::DB_NONE ) { @@ -105,7 +103,7 @@ if ( $maintenance->getDbType() === Maintenance::DB_NONE ) { } $maintenance->finalSetup(); // Some last includes -require_once MWInit::compiledPath( 'includes/Setup.php' ); +require_once "$IP/includes/Setup.php"; // Much much faster startup than creating a title object $wgTitle = null; diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index 6fb29be905..8bd80c9786 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -1,6 +1,6 @@ * http://www.mediawiki.org/ @@ -158,11 +158,7 @@ class UserDupes { * @access private */ function lock() { - if ( $this->newSchema() ) { - $set = array( 'user', 'revision' ); - } else { - $set = array( 'user', 'cur', 'old' ); - } + $set = array( 'user', 'revision' ); $names = array_map( array( $this, 'lockTable' ), $set ); $tables = implode( ',', $names ); @@ -173,14 +169,6 @@ class UserDupes { return $this->db->tableName( $table ) . ' WRITE'; } - /** - * @return bool - * @access private - */ - function newSchema() { - return MWInit::classExists( 'Revision' ); - } - /** * @access private */ @@ -266,27 +254,10 @@ class UserDupes { * @access private */ function editCount( $userid ) { - if ( $this->newSchema() ) { - return $this->editCountOn( 'revision', 'rev_user', $userid ); - } else { - return $this->editCountOn( 'cur', 'cur_user', $userid ) + - $this->editCountOn( 'old', 'old_user', $userid ); - } - } - - /** - * Count the number of hits on a given table for this account. - * @param $table string - * @param $field string - * @param $userid int - * @return int - * @access private - */ - function editCountOn( $table, $field, $userid ) { return intval( $this->db->selectField( - $table, + 'revision', 'COUNT(*)', - array( $field => $userid ), + array( 'rev_user' => $userid ), __METHOD__ ) ); } @@ -296,26 +267,10 @@ class UserDupes { * @access private */ function reassignEdits( $from, $to ) { - $set = $this->newSchema() - ? array( 'revision' => 'rev_user' ) - : array( 'cur' => 'cur_user', 'old' => 'old_user' ); - foreach ( $set as $table => $field ) { - $this->reassignEditsOn( $table, $field, $from, $to ); - } - } - - /** - * @param $table string - * @param $field string - * @param $from int - * @param $to int - * @access private - */ - function reassignEditsOn( $table, $field, $from, $to ) { - $this->out( "reassigning on $table... " ); - $this->db->update( $table, - array( $field => $to ), - array( $field => $from ), + $this->out( 'reassigning... ' ); + $this->db->update( 'revision', + array( 'rev_user' => $to ), + array( 'rev_user' => $from ), __METHOD__ ); $this->out( "ok. " ); } -- 2.20.1