X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=af14bb36fc6154ceafdc1d8ff2bdf39f281e5722;hb=9e921490b4ac3459adcac65e5f93b5d9921e5465;hp=108fe9f12ef236d6c4d47a9db45c7b3b68eb54e7;hpb=7f191fbe513912d70b6380084438991d8beecce9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 108fe9f12e..50b8a01275 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -38,6 +38,8 @@ define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless $maintClass = false; +use MediaWiki\Logger\LoggerFactory; + /** * Abstract maintenance class for quickly writing and churning out * maintenance scripts with minimal effort. All that _must_ be defined @@ -601,10 +603,10 @@ abstract class Maintenance { * Activate the profiler (assuming $wgProfiler is set) */ protected function activateProfiler() { - global $wgProfiler; + global $wgProfiler, $wgTrxProfilerLimits; $output = $this->getOption( 'profiler' ); - if ( $output && is_array( $wgProfiler ) ) { + if ( $output && is_array( $wgProfiler ) && isset( $wgProfiler['class'] ) ) { $class = $wgProfiler['class']; $profiler = new $class( array( 'sampling' => 1, 'output' => $output ) + $wgProfiler @@ -612,6 +614,10 @@ abstract class Maintenance { $profiler->setTemplated( true ); Profiler::replaceStubInstance( $profiler ); } + + $trxProfiler = Profiler::instance()->getTransactionProfiler(); + $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) ); + $trxProfiler->setExpectations( $wgTrxProfilerLimits['Maintenance'], __METHOD__ ); } /** @@ -696,6 +702,9 @@ abstract class Maintenance { } $options[$option] = $param; } + } elseif ( $arg == '-' ) { + # Lonely "-", often used to indicate stdin or stdout. + $args[] = $arg; } elseif ( substr( $arg, 0, 1 ) == '-' ) { # Short options $argLength = strlen( $arg ); @@ -1073,7 +1082,7 @@ abstract class Maintenance { * * @return DatabaseBase */ - protected function &getDB( $db, $groups = array(), $wiki = false ) { + protected function getDB( $db, $groups = array(), $wiki = false ) { if ( is_null( $this->mDb ) ) { return wfGetDB( $db, $groups, $wiki ); } else { @@ -1086,7 +1095,7 @@ abstract class Maintenance { * * @param DatabaseBase $db Database object to be used */ - public function setDB( &$db ) { + public function setDB( $db ) { $this->mDb = $db; } @@ -1094,9 +1103,9 @@ abstract class Maintenance { * Lock the search index * @param DatabaseBase &$db */ - private function lockSearchindex( &$db ) { + private function lockSearchindex( $db ) { $write = array( 'searchindex' ); - $read = array( 'page', 'revision', 'text', 'interwiki', 'l10n_cache', 'user' ); + $read = array( 'page', 'revision', 'text', 'interwiki', 'l10n_cache', 'user', 'page_restrictions' ); $db->lockTables( $read, $write, __CLASS__ . '::' . __METHOD__ ); } @@ -1104,7 +1113,7 @@ abstract class Maintenance { * Unlock the tables * @param DatabaseBase &$db */ - private function unlockSearchindex( &$db ) { + private function unlockSearchindex( $db ) { $db->unlockTables( __CLASS__ . '::' . __METHOD__ ); } @@ -1113,7 +1122,7 @@ abstract class Maintenance { * Since the lock is low-priority, queued reads will be able to complete * @param DatabaseBase &$db */ - private function relockSearchindex( &$db ) { + private function relockSearchindex( $db ) { $this->unlockSearchindex( $db ); $this->lockSearchindex( $db ); } @@ -1207,7 +1216,13 @@ abstract class Maintenance { } if ( $isatty && function_exists( 'readline' ) ) { - return readline( $prompt ); + $resp = readline( $prompt ); + if ( $resp === null ) { + // Workaround for https://github.com/facebook/hhvm/issues/4776 + return false; + } else { + return $resp; + } } else { if ( $isatty ) { $st = self::readlineEmulation( $prompt ); @@ -1321,7 +1336,7 @@ abstract class LoggedUpdateMaintenance extends Maintenance { } /** - * Message to show the the update log was unable to log the completion of this update + * Message to show that the update log was unable to log the completion of this update * @return string */ protected function updatelogFailedMessage() {