*
* @file
*/
+use MediaWiki\MediaWikiServices;
/**
* Class for managing forking command line scripts.
* @ingroup Maintenance
*/
class ForkController {
- protected $children = array(), $childNumber = 0;
+ protected $children = [], $childNumber = 0;
protected $termReceived = false;
protected $flags = 0, $procsToStart = 0;
- protected static $restartableSignals = array(
+ protected static $restartableSignals = [
SIGFPE,
SIGILL,
SIGSEGV,
SIGPIPE,
SIGXCPU,
SIGXFSZ,
- );
+ ];
/**
* Pass this flag to __construct() to cause the class to automatically restart
const RESTART_ON_ERROR = 1;
public function __construct( $numProcs, $flags = 0 ) {
- if ( PHP_SAPI != 'cli' ) {
+ if ( !wfIsCLI() ) {
throw new MWException( "ForkController cannot be used from the web." );
}
$this->procsToStart = $numProcs;
*/
public function start() {
// Trap SIGTERM
- pcntl_signal( SIGTERM, array( $this, 'handleTermSignal' ), false );
+ pcntl_signal( SIGTERM, [ $this, 'handleTermSignal' ], false );
do {
// Start child processes
protected function prepareEnvironment() {
global $wgMemc;
// Don't share DB, storage, or memcached connections
- wfGetLBFactory()->destroyInstance();
+ MediaWikiServices::resetChildProcessServices();
FileBackendGroup::destroySingleton();
LockManagerGroup::destroySingletons();
JobQueueGroup::destroySingletons();