r74891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74890‎ | r74891 | r74892 >
Date:10:18, 17 October 2010
Author:maxsem
Status:ok
Tags:
Comment:
And while I'm at it, one more tweak to --memory-limit: use 'max' instead of -1 for clarity
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -351,7 +351,7 @@
352352 $this->addOption( 'conf', 'Location of LocalSettings.php, if not default', false, true );
353353 $this->addOption( 'wiki', 'For specifying the wiki ID', false, true );
354354 $this->addOption( 'globals', 'Output globals at the end of processing for debugging' );
355 - $this->addOption( 'memory-limit', 'Set a specific memory limit for the script, -1 for no limit or "default" to avoid changing it' );
 355+ $this->addOption( 'memory-limit', 'Set a specific memory limit for the script, "max" for no limit or "default" to avoid changing it' );
356356 // If we support a DB, show the options
357357 if ( $this->getDbType() > 0 ) {
358358 $this->addOption( 'dbuser', 'The DB user to use for this script', false, true );
@@ -469,16 +469,22 @@
470470 * to disable the limits)
471471 */
472472 public function memoryLimit() {
473 - return $this->getOption( 'memory-limit', -1 );
 473+ $limit = $this->getOption( 'memory-limit', 'max' );
 474+ $limit = trim( $limit, "\" '" ); // trim quotes in case someone misunderstood
 475+ return $limit;
474476 }
475477
476478 /**
477479 * Adjusts PHP's memory limit to better suit our needs, if needed.
478480 */
479481 protected function adjustMemoryLimit() {
480 - if ( $this->memoryLimit() != 'default' ) {
481 - ini_set( 'memory_limit', $this->memoryLimit() );
 482+ $limit = $this->memoryLimit();
 483+ if ( $limit == 'max' ) {
 484+ $limit = -1; // no memory limit
482485 }
 486+ if ( $limit != 'default' ) {
 487+ ini_set( 'memory_limit', $limit );
 488+ }
483489 }
484490
485491 /**

Status & tagging log