Added a memoryLimit() method on Maintenance class which allows scripts to override the memory limit; normally we disable the limit but sometimes you actually want to set one to avoid eating up RAM on the machine if something goes awry.
}
# Set the memory limit
- ini_set( 'memory_limit', -1 );
+ ini_set( 'memory_limit', $this->memoryLimit() );
# Set max execution time to 0 (no limit). PHP.net says that
# "When running PHP from the command line the default setting is 0."
$this->maybeHelp();
$this->validateParamsAndArgs();
}
+
+ /**
+ * Normally we disable the memory_limit when running admin scripts.
+ * Some scripts may wish to actually set a limit, however, to avoid
+ * blowing up unexpectedly.
+ */
+ public function memoryLimit() {
+ return -1;
+ }
/**
* Clear all params and arguments.
require( dirname(__FILE__).'/../commandLine.inc' );
require( dirname(__FILE__).'/gearman.inc' );
+ini_set('memory_limit', '150M' );
+
if ( isset( $options['procs'] ) ) {
$procs = $options['procs'];
if ( $procs < 1 || $procs > 1000 ) {
$this->addOption( 'force', 'Rebuild all files, even ones not out of date' );
$this->addOption( 'threads', 'Fork more than one thread', false, true );
}
+
+ public function memoryLimit() {
+ return '200M';
+ }
public function execute() {
global $wgLocalisationCacheConf;
- ini_set( 'memory_limit', '200M' );
-
$force = $this->hasOption('force');
$threads = $this->getOption( 'threads', 1 );
if( $threads < 1 || $threads != intval( $threads ) ) {
$this->addOption( 'procs', 'Number of processes to use', false, true );
$wgUseNormalUser = true;
}
+
+ public function memoryLimit() {
+ // Don't eat all memory on the machine if we get a bad job.
+ return "150M";
+ }
public function execute() {
global $wgTitle;