X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=04aa3a5e0352ff3ca454fba28384b6fa16c6c87c;hb=7f67c5566d37549e0297caa6c78b6de5dc2eaa6e;hp=a0ffcb2b155f7676fd2150e1ed655e466fb390ee;hpb=579d6e75554610c03d1096d61bf1d4b2f680468c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index a0ffcb2b15..04aa3a5e03 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -20,12 +20,10 @@ * @defgroup Maintenance Maintenance */ -// Make sure we're on PHP5.3.3 or better -if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.3' ) < 0 ) { - // We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+ - require_once dirname( __FILE__ ) . '/../includes/PHPVersionError.php'; - wfPHPVersionError( 'cli' ); -} +// Bail on old versions of PHP, or if composer has not been run yet to install +// dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+. +require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php'; +wfEntryPointCheck( 'cli' ); /** * @defgroup MaintenanceArchive Maintenance archives @@ -38,6 +36,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,17 +601,27 @@ abstract class Maintenance { * Activate the profiler (assuming $wgProfiler is set) */ protected function activateProfiler() { - global $wgProfiler; + global $wgProfiler, $wgProfileLimit, $wgTrxProfilerLimits; $output = $this->getOption( 'profiler' ); - if ( $output && is_array( $wgProfiler ) && isset( $wgProfiler['class'] ) ) { + if ( !$output ) { + return; + } + + if ( is_array( $wgProfiler ) && isset( $wgProfiler['class'] ) ) { $class = $wgProfiler['class']; $profiler = new $class( - array( 'sampling' => 1, 'output' => $output ) + $wgProfiler + array( 'sampling' => 1, 'output' => array( $output ) ) + + $wgProfiler + + array( 'threshold' => $wgProfileLimit ) ); $profiler->setTemplated( true ); Profiler::replaceStubInstance( $profiler ); } + + $trxProfiler = Profiler::instance()->getTransactionProfiler(); + $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) ); + $trxProfiler->setExpectations( $wgTrxProfilerLimits['Maintenance'], __METHOD__ ); } /** @@ -947,10 +957,9 @@ abstract class Maintenance { $wgShowSQLErrors = true; - // @codingStandardsIgnoreStart Allow error suppression. wfSuppressWarnings() - // is not available. - @set_time_limit( 0 ); - // @codingStandardsIgnoreStart + MediaWiki\suppressWarnings(); + set_time_limit( 0 ); + MediaWiki\restoreWarnings(); $this->adjustMemoryLimit(); } @@ -1099,7 +1108,7 @@ abstract class Maintenance { */ 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__ ); }