Permalink
Browse files

sourceforge [1588942] Allow memory_limit setting in phpdocumentor.ini

git-svn-id: http://svn.php.net/repository/pear/packages/PhpDocumentor/trunk@226957 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent ccbe6ca commit da4bf5ac95ddd4bf54335233d7897dcdc6c3fa90 Chuck Burgess committed Jan 10, 2007
Showing with 25 additions and 5 deletions.
  1. +4 −0 phpDocumentor.ini
  2. +21 −5 phpDocumentor/Setup.inc.php
View
@@ -20,6 +20,10 @@ Program_Root =
;[_phpDocumentor_setting]
;useconfig = default
+;; set max memory usage size to be very high, to avoid it crashing it the middle of its run
+;; due to using a boatload of memory
+;;memory_limit = 512M
+
[_phpDocumentor_phpfile_exts]
php
php3
@@ -179,11 +179,7 @@ function phpDocumentor_setup()
{
phpDocumentor_out("time_limit cannot be set since your in safe_mode, please edit time_limit in your php.ini to allow enough time for phpDocumentor to run");
}
- $x = str_replace('M', '', ini_get('memory_limit'));
- if ($x < 256) {
- ini_set("memory_limit","256M");
- }
-
+
$phpver = phpversion();
$phpdocver = PHPDOCUMENTOR_VER;
if (isset($_GET['interface'])) {
@@ -194,6 +190,7 @@ function phpDocumentor_setup()
phpDocumentor_out("phpDocumentor version $phpdocver\n\n");
$this->parseIni();
+ $this->setMemoryLimit();
if (tokenizer_ext)
{
@@ -391,6 +388,25 @@ function checkIgnoreTag($tagname, $inline = false)
if ($inline) $tagname = '{'.$tagname.'}';
return in_array($tagname, $_phpDocumentor_setting['ignoretags']);
}
+
+ /**
+ * Allow a memory_limit setting in phpDocumentor.ini to override php.ini or default memory limit
+ */
+ function setMemoryLimit() {
+ global $_phpDocumentor_options;
+ $DEFAULT_MEMORY_SIZE_MINIMUM = 256;
+
+ if (isset($_phpDocumentor_options['memory_limit'])) {
+ // PhpDoc memory_limit from phpDocumentor.ini overrides all other considerations
+ $memory_setting_to_use = str_replace('M', '', $_phpDocumentor_options['memory_limit']);
+ } else {
+ // PHP memory_limit from php.ini must be at least the default minimum
+ $php_ini_setting = str_replace('M', '', ini_get('memory_limit'));
+ $memory_setting_to_use = ($php_ini_setting > $DEFAULT_MEMORY_SIZE_MINIMUM) ? $php_ini_setting : $DEFAULT_MEMORY_SIZE_MINIMUM;
+ }
+ ini_set("memory_limit", $memory_setting_to_use . "M");
+ phpDocumentor_out("Maximum memory usage set at " . $memory_setting_to_use . "M...\n");
+ }
function setJavadocDesc()
{

0 comments on commit da4bf5a

Please sign in to comment.