summaryrefslogtreecommitdiff
path: root/maintenance/Maintenance.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/Maintenance.php')
-rw-r--r--maintenance/Maintenance.php60
1 files changed, 30 insertions, 30 deletions
diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php
index 69d11313..a13453df 100644
--- a/maintenance/Maintenance.php
+++ b/maintenance/Maintenance.php
@@ -109,6 +109,12 @@ abstract class Maintenance {
private $mDb = null;
/**
+ * Used when creating separate schema files.
+ * @var resource
+ */
+ public $fileHandle;
+
+ /**
* List of all the core maintenance scripts. This is added
* to scripts added by extensions in $wgMaintenanceScripts
* and returned by getMaintenanceScripts()
@@ -336,7 +342,7 @@ abstract class Maintenance {
*/
protected function error( $err, $die = 0 ) {
$this->outputChanneled( false );
- if ( php_sapi_name() == 'cli' ) {
+ if ( PHP_SAPI == 'cli' ) {
fwrite( STDERR, $err . "\n" );
} else {
print $err;
@@ -482,19 +488,11 @@ abstract class Maintenance {
$this->error( 'Cannot get command line arguments, register_argc_argv is set to false', true );
}
- if ( version_compare( phpversion(), '5.2.4' ) >= 0 ) {
- // Send PHP warnings and errors to stderr instead of stdout.
- // This aids in diagnosing problems, while keeping messages
- // out of redirected output.
- if ( ini_get( 'display_errors' ) ) {
- ini_set( 'display_errors', 'stderr' );
- }
-
- // Don't touch the setting on earlier versions of PHP,
- // as setting it would disable output if you'd wanted it.
-
- // Note that exceptions are also sent to stderr when
- // command-line mode is on, regardless of PHP version.
+ // Send PHP warnings and errors to stderr instead of stdout.
+ // This aids in diagnosing problems, while keeping messages
+ // out of redirected output.
+ if ( ini_get( 'display_errors' ) ) {
+ ini_set( 'display_errors', 'stderr' );
}
$this->loadParamsAndArgs();
@@ -515,8 +513,11 @@ abstract class Maintenance {
define( 'MEDIAWIKI', true );
$wgCommandLineMode = true;
+
# Turn off output buffering if it's on
- @ob_end_flush();
+ while( ob_get_level() > 0 ) {
+ ob_end_flush();
+ }
$this->validateParamsAndArgs();
}
@@ -922,7 +923,7 @@ abstract class Maintenance {
if ( !is_readable( $settingsFile ) ) {
$this->error( "A copy of your installation's LocalSettings.php\n" .
"must exist and be readable in the source directory.\n" .
- "Use --conf to specify it." , true );
+ "Use --conf to specify it.", true );
}
$wgCommandLineMode = true;
return $settingsFile;
@@ -938,13 +939,9 @@ abstract class Maintenance {
$dbw = $this->getDB( DB_MASTER );
$dbw->begin( __METHOD__ );
- $tbl_arc = $dbw->tableName( 'archive' );
- $tbl_rev = $dbw->tableName( 'revision' );
- $tbl_txt = $dbw->tableName( 'text' );
-
# Get "active" text records from the revisions table
$this->output( 'Searching for active text records in revisions table...' );
- $res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" );
+ $res = $dbw->select( 'revision', 'rev_text_id', array(), __METHOD__, array( 'DISTINCT' ) );
foreach ( $res as $row ) {
$cur[] = $row->rev_text_id;
}
@@ -952,16 +949,19 @@ abstract class Maintenance {
# Get "active" text records from the archive table
$this->output( 'Searching for active text records in archive table...' );
- $res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" );
+ $res = $dbw->select( 'archive', 'ar_text_id', array(), __METHOD__, array( 'DISTINCT' ) );
foreach ( $res as $row ) {
- $cur[] = $row->ar_text_id;
+ # old pre-MW 1.5 records can have null ar_text_id's.
+ if ( $row->ar_text_id !== null ) {
+ $cur[] = $row->ar_text_id;
+ }
}
$this->output( "done.\n" );
# Get the IDs of all text records not in these sets
$this->output( 'Searching for inactive text records...' );
- $set = implode( ', ', $cur );
- $res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" );
+ $cond = 'old_id NOT IN ( ' . $dbw->makeList( $cur ) . ' )';
+ $res = $dbw->select( 'text', 'old_id', array( $cond ), __METHOD__, array( 'DISTINCT' ) );
$old = array();
foreach ( $res as $row ) {
$old[] = $row->old_id;
@@ -975,8 +975,7 @@ abstract class Maintenance {
# Delete as appropriate
if ( $delete && $count ) {
$this->output( 'Deleting...' );
- $set = implode( ', ', $old );
- $dbw->query( "DELETE FROM $tbl_txt WHERE old_id IN ( $set )" );
+ $dbw->delete( 'text', array( 'old_id' => $old ), __METHOD__ );
$this->output( "done.\n" );
}
@@ -1068,7 +1067,7 @@ abstract class Maintenance {
*/
private function lockSearchindex( &$db ) {
$write = array( 'searchindex' );
- $read = array( 'page', 'revision', 'text', 'interwiki', 'l10n_cache' );
+ $read = array( 'page', 'revision', 'text', 'interwiki', 'l10n_cache', 'user' );
$db->lockTables( $read, $write, __CLASS__ . '::' . __METHOD__ );
}
@@ -1144,7 +1143,8 @@ abstract class Maintenance {
$title = $titleObj->getPrefixedDBkey();
$this->output( "$title..." );
# Update searchindex
- $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getText() );
+ # TODO: pass the Content object to SearchUpdate, let the search engine decide how to deal with it.
+ $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getContent()->getTextForSearchIndex() );
$u->doUpdate();
$this->output( "\n" );
}
@@ -1208,7 +1208,7 @@ abstract class Maintenance {
$encPrompt = wfEscapeShellArg( $prompt );
$command = "read -er -p $encPrompt && echo \"\$REPLY\"";
$encCommand = wfEscapeShellArg( $command );
- $line = wfShellExec( "$bash -c $encCommand", $retval );
+ $line = wfShellExec( "$bash -c $encCommand", $retval, array(), array( 'walltime' => 0 ) );
if ( $retval == 0 ) {
return $line;