Skip to content

Commit

Permalink
Fixed #25450811: Alert disable memory_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelpichler committed Feb 25, 2012
1 parent 194dfce commit 19e4fc5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/pdepend
15 changes: 13 additions & 2 deletions src/bin/phpmd.php
Expand Up @@ -12,8 +12,19 @@
);
}

// Disable memory_limit
ini_set('memory_limit', -1);
// Allow as much memory as possible by default
if (extension_loaded('suhosin') && is_numeric(ini_get('suhosin.memory_limit'))) {
$limit = ini_get('memory_limit');
if (preg_match('(^(\d+)([BKMGT]))', $limit, $match)) {
$shift = array('B' => 0, 'K' => 10, 'M' => 20, 'G' => 30, 'T' => 40);
$limit = ($match[1] * (1 << $shift[$match[2]]));
}
if (ini_get('suhosin.memory_limit') > $limit) {
ini_set('memory_limit', ini_get('suhosin.memory_limit'));
}
} else {
ini_set('memory_limit', -1);
}

// Check php setup for cli arguments
if (!isset($_SERVER['argv']) && !isset($argv)) {
Expand Down
2 changes: 1 addition & 1 deletion src/conf/package.xml
Expand Up @@ -348,7 +348,7 @@
<package>
<name>PHP_Depend</name>
<channel>pear.pdepend.org</channel>
<min>1.0.2</min>
<min>1.0.3</min>
</package>
<extension>
<name>pcre</name>
Expand Down
13 changes: 12 additions & 1 deletion src/site/docx/changes.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://maven.apache.org/changes/1.0.0"
<document
xmlns="http://maven.apache.org/changes/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">

Expand All @@ -9,6 +10,16 @@
</properties>

<body>
<release version="1.3.2"
date="2012/02/25"
description="This release closes a minor issue in PHP_PMD's
memory handling when it is run in a PHP environment
that uses the Suhosin patch and the suhosin.memory_limit
setting.">
<action date="" dev="mapi" issue="25450811" system="pivotaltracker" type="fix" due-to="Gordon Franke">
Alert disable memory_limit
</action>
</release>
<release version="1.3.1"
date="2012/02/16"
description="The 1.3.1 release of PHPMD closes one critical bug
Expand Down

0 comments on commit 19e4fc5

Please sign in to comment.