* Executes the installation of the basic WCF systems.
*
* @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system
// mb string
$system['mbString']['result'] = extension_loaded('mbstring');
+ // memory limit
+ $system['memoryLimit']['value'] = ini_get('memory_limit');
+ $system['memoryLimit']['result'] = $this->compareMemoryLimit();
+
WCF::getTPL()->assign(array(
'system' => $system,
'nextStep' => 'searchWcfDir'
WCF::getTPL()->display('stepShowSystemRequirements');
}
+ /**
+ * Returns true, if memory_limit is set to at least 64 MB
+ *
+ * @return boolean
+ */
+ protected function compareMemoryLimit() {
+ $memoryLimit = ini_get('memory_limit');
+
+ // no limit
+ if ($memoryLimit == -1) {
+ return true;
+ }
+
+ // completely numeric, PHP assumes byte
+ if (is_numeric($memoryLimit)) {
+ $memoryLimit = $memoryLimit / 1024;
+ return ($memoryLimit >= 64);
+ }
+
+ // PHP supports 'K', 'M' and 'G' shorthand notation
+ if (preg_match('^~(\d+)([KMG])~$', $memoryLimit, $matches)) {
+ switch ($matches[2]) {
+ case 'K':
+ $memoryLimit = $matches[1] * 1024;
+ return ($memoryLimit >= 64);
+ break;
+
+ case 'M':
+ return ($matches[1] >= 64);
+ break;
+
+ case 'G':
+ return ($matches[1] >= 1);
+ break;
+ }
+ }
+
+ return false;
+ }
+
/**
* Searches the wcf dir.
*/
// loop through <package> tags inside the <section> tag.
$allNewPackages = array();
- $packages = $xpath->query('/ns:section[@name=\'packages\']/ns:package');
+ $packages = $xpath->query('/ns:section/ns:package');
foreach ($packages as $package) {
if (!Package::isValidPackageName($package->getAttribute('name'))) {
throw new SystemException("'".$package->getAttribute('name')."' is not a valid package name.");
$versionEditor->update(array(
'filename' => $packageFile,
'isAccessible' => ($versionData['isAccessible'] ? 1 : 0),
- 'license' => $versionData['license']['license'],
- 'licenseURL' => $versionData['license']['licenseURL'],
+ 'license' => (isset($versionData['license']['license']) ? $versionData['license']['license'] : ''),
+ 'licenseURL' => (isset($versionData['license']['license']) ? $versionData['license']['licenseURL'] : ''),
'packageDate' => $versionData['packageDate'],
'updateType' => $versionData['updateType']
));
// create new database entry
$version = PackageUpdateVersionEditor::create(array(
'filename' => $packageFile,
- 'license' => $versionData['license']['license'],
- 'licenseURL' => $versionData['license']['licenseURL'],
+ 'license' => (isset($versionData['license']['license']) ? $versionData['license']['license'] : ''),
+ 'licenseURL' => (isset($versionData['license']['license']) ? $versionData['license']['licenseURL'] : ''),
'isAccessible' => ($versionData['isAccessible'] ? 1 : 0),
'packageDate' => $versionData['packageDate'],
'packageUpdateID' => $packageUpdateID,
// insert requirements
$sql = "INSERT INTO wcf".WCF_N."_package_update_optional
(packageUpdateVersionID, package)
- VALUES (?, ?, ?)";
+ VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($requirementInserts as $requirement) {
$statement->execute(array(
filename VARCHAR(255) NOT NULL DEFAULT '',
license VARCHAR(255) NOT NULL DEFAULT '',
licenseURL VARCHAR(255) NOT NULL DEFAULT '',
- accessible TINYINT(1) NOT NULL DEFAULT 1,
+ isAccessible TINYINT(1) NOT NULL DEFAULT 1,
UNIQUE KEY packageUpdateID (packageUpdateID, packageVersion)
);
ALTER TABLE wcf1_package_update_requirement ADD FOREIGN KEY (packageUpdateVersionID) REFERENCES wcf1_package_update_version (packageUpdateVersionID) ON DELETE CASCADE;
+ALTER TABLE wcf1_package_update_optional ADD FOREIGN KEY (packageUpdateVersionID) REFERENCES wcf1_package_update_version (packageUpdateVersionID) ON DELETE CASCADE;
+
ALTER TABLE wcf1_package_update_version ADD FOREIGN KEY (packageUpdateID) REFERENCES wcf1_package_update (packageUpdateID) ON DELETE CASCADE;
ALTER TABLE wcf1_page_menu_item ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
</header>
<div class="container containerPadding marginTop">
+ <fieldset>
+ <legend>{lang}wcf.global.systemRequirements.memoryLimit{/lang}</legend>
+ <dl>
+ <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang} > 64 M</dt>
+ <dd>
+ {lang}wcf.global.systemRequirements.element.yours{/lang} <span class="badge {if !$system.memoryLimit.result}yellow{else}green{/if}">{$system.memoryLimit.value}</span>
+ {if !$system.memoryLimit.result}<small>{lang}wcf.global.systemRequirements.memoryLimit.description{/lang}</small>{/if}
+ </dd>
+ </dl>
+ </fieldset>
+
<fieldset>
<legend>{lang}wcf.global.systemRequirements.uploadMaxFilesize{/lang}</legend>
<dl>