$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
* 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
$profiler->setTemplated( true );
Profiler::replaceStubInstance( $profiler );
}
+
+ $trxProfiler = Profiler::instance()->getTransactionProfiler();
+ $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) );
+ $trxProfiler->setExpectations( $wgTrxProfilerLimits['Maintenance'], __METHOD__ );
}
/**
}
$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 );
*
* @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 {
*
* @param DatabaseBase $db Database object to be used
*/
- public function setDB( &$db ) {
+ public function setDB( $db ) {
$this->mDb = $db;
}
* 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__ );
}
* Unlock the tables
* @param DatabaseBase &$db
*/
- private function unlockSearchindex( &$db ) {
+ private function unlockSearchindex( $db ) {
$db->unlockTables( __CLASS__ . '::' . __METHOD__ );
}
* 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 );
}
}
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 );
}
/**
- * 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() {