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 / c68957c5e3).
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
This commit is contained in:
parent
621350e4e8
commit
12c61d3e7f
5 changed files with 21 additions and 73 deletions
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Helper class for update.php and upgrade1_5.php.
|
||||
* Helper class for update.php.
|
||||
*
|
||||
* Copyright © 2005 Brion Vibber <brion@pobox.com>
|
||||
* 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. " );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue