Skip to content

Commit

Permalink
Fixed issue #7716: Added memory check for minimum 64MB to installer
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Apr 1, 2013
1 parent f79d7ff commit 6bb516b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
25 changes: 25 additions & 0 deletions application/controllers/InstallerController.php
Expand Up @@ -830,6 +830,10 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecurs
if (version_compare(PHP_VERSION, '5.1.6', '<'))
$bProceed = !$data['verror'] = true;

if ($this->return_bytes(ini_get('memory_limit'))/1024/1024<64)
$bProceed = !$data['bMemoryError'] = true;


// mbstring library check
if (!check_PHPFunction('mb_convert_encoding', $data['mbstringPresent']))
$bProceed = false;
Expand Down Expand Up @@ -1232,5 +1236,26 @@ function _dbConnect($aDbConfig = array(), $aData = array())
}
}
}

/**
* This function returns the full number from a PHP ini value
*
* @param string $sValue
*/
function return_bytes($sValue) {
$sValue = trim($sValue);
$last = strtolower($sValue[strlen($sValue)-1]);
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$sValue *= 1024;
case 'm':
$sValue *= 1024;
case 'k':
$sValue *= 1024;
}

return $sValue;
}

}
3 changes: 2 additions & 1 deletion application/controllers/admin/checkintegrity.php
Expand Up @@ -340,7 +340,8 @@ protected function _checkintegrity()
$surveys = Survey::model()->findAll();
$sids = array();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$criteria->addNotInCondition('sid', $sids, 'OR');
$criteria->addNotInCondition('entity_id', $sids, 'OR');
$criteria->addCondition("entity='survey'");

Permission::model()->deleteAll($criteria);

Expand Down
7 changes: 7 additions & 0 deletions application/views/installer/precheck_view.php
Expand Up @@ -59,6 +59,13 @@ function dirReport($dir, $write, $clang)
<td><?php if (isset($verror) && $verror) { ?><span style='font-weight:bold; color: red'><?php $clang->eT("Outdated"); ?>: <?php echo $phpVersion; ?></span>
<?php } else { ?><?php echo $phpVersion ; ?> <?php } ?></td>
</tr>
<tr>
<td><?php $clang->eT("Minimum memory available"); ?></td>
<td>64MB</td>
<td><?php
if (isset($bMemoryError) && $bMemoryError) { ?><span style='font-weight:bold; color: red'><?php $clang->eT("Outdated"); ?>: <?php echo $this->return_bytes(ini_get('memory_limit'))/1024/1024; ?>MB</span>
<?php } else { ?><?php echo $this->return_bytes(ini_get('memory_limit'))/1024/1024; ?>MB <?php } ?></td>
</tr>
<tr>
<td><?php $clang->eT("PHP PDO driver library"); ?></td>
<td><?php $clang->eT("At least one installed"); ?></td>
Expand Down

0 comments on commit 6bb516b

Please sign in to comment.