Index: trunk/phase3/maintenance/runJobs.php |
— | — | @@ -36,6 +36,11 @@ |
37 | 37 | $this->addOption( 'procs', 'Number of processes to use', false, true ); |
38 | 38 | $wgUseNormalUser = true; |
39 | 39 | } |
| 40 | + |
| 41 | + public function memoryLimit() { |
| 42 | + // Don't eat all memory on the machine if we get a bad job. |
| 43 | + return "150M"; |
| 44 | + } |
40 | 45 | |
41 | 46 | public function execute() { |
42 | 47 | global $wgTitle; |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -333,7 +333,7 @@ |
334 | 334 | } |
335 | 335 | |
336 | 336 | # Set the memory limit |
337 | | - ini_set( 'memory_limit', -1 ); |
| 337 | + ini_set( 'memory_limit', $this->memoryLimit() ); |
338 | 338 | |
339 | 339 | # Set max execution time to 0 (no limit). PHP.net says that |
340 | 340 | # "When running PHP from the command line the default setting is 0." |
— | — | @@ -362,6 +362,15 @@ |
363 | 363 | $this->maybeHelp(); |
364 | 364 | $this->validateParamsAndArgs(); |
365 | 365 | } |
| 366 | + |
| 367 | + /** |
| 368 | + * Normally we disable the memory_limit when running admin scripts. |
| 369 | + * Some scripts may wish to actually set a limit, however, to avoid |
| 370 | + * blowing up unexpectedly. |
| 371 | + */ |
| 372 | + public function memoryLimit() { |
| 373 | + return -1; |
| 374 | + } |
366 | 375 | |
367 | 376 | /** |
368 | 377 | * Clear all params and arguments. |
Index: trunk/phase3/maintenance/rebuildLocalisationCache.php |
— | — | @@ -37,12 +37,14 @@ |
38 | 38 | $this->addOption( 'force', 'Rebuild all files, even ones not out of date' ); |
39 | 39 | $this->addOption( 'threads', 'Fork more than one thread', false, true ); |
40 | 40 | } |
| 41 | + |
| 42 | + public function memoryLimit() { |
| 43 | + return '200M'; |
| 44 | + } |
41 | 45 | |
42 | 46 | public function execute() { |
43 | 47 | global $wgLocalisationCacheConf; |
44 | 48 | |
45 | | - ini_set( 'memory_limit', '200M' ); |
46 | | - |
47 | 49 | $force = $this->hasOption('force'); |
48 | 50 | $threads = $this->getOption( 'threads', 1 ); |
49 | 51 | if( $threads < 1 || $threads != intval( $threads ) ) { |
Index: trunk/phase3/maintenance/gearman/gearmanWorker.php |
— | — | @@ -4,6 +4,8 @@ |
5 | 5 | require( dirname(__FILE__).'/../commandLine.inc' ); |
6 | 6 | require( dirname(__FILE__).'/gearman.inc' ); |
7 | 7 | |
| 8 | +ini_set('memory_limit', '150M' ); |
| 9 | + |
8 | 10 | if ( isset( $options['procs'] ) ) { |
9 | 11 | $procs = $options['procs']; |
10 | 12 | if ( $procs < 1 || $procs > 1000 ) { |