Fixed update server and added memory limit check
authorAlexander Ebert <ebert@woltlab.com>
Mon, 14 Jan 2013 22:47:02 +0000 (23:47 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 14 Jan 2013 22:47:02 +0000 (23:47 +0100)
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php
wcfsetup/setup/db/install.sql
wcfsetup/setup/template/stepShowSystemRequirements.tpl

index f4feeb7c358c36d3ab9ed00a565a5f19a663792a..e5458420700dfa463fe7d73859b00c51c0c5c379 100644 (file)
@@ -39,7 +39,7 @@ define('ENABLE_BENCHMARK', 0);
  * 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
@@ -394,6 +394,10 @@ class WCFSetup extends WCF {
                // 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'
@@ -401,6 +405,46 @@ class WCFSetup extends WCF {
                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.
         */
index bb17c2ce30c590c7e385a60a10114800cad7bcd9..dbc26ff7d19532572730e957855a8dacbb3eb1eb 100644 (file)
@@ -121,7 +121,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                
                // 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.");
@@ -350,8 +350,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                                                $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']
                                                ));
@@ -360,8 +360,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                                                // 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,
@@ -458,7 +458,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                        // 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(
index 0eeea7ef75f44f78f58ac5268ec5ca4a17e487f1..ac4b08c4f00ddca41085e6cbec688a31b6bd6ff2 100644 (file)
@@ -498,7 +498,7 @@ CREATE TABLE wcf1_package_update_version (
        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)
 );
 
@@ -860,6 +860,8 @@ ALTER TABLE wcf1_package_update_fromversion ADD FOREIGN KEY (packageUpdateVersio
 
 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;
index 2577a405bdc2578d0ab41038bb71cf9fe7fedaed..1b6d0512260718f0b2e5f1fec9d0796778a0ae72 100644 (file)
 </header>
 
 <div class="container containerPadding marginTop">
+       <fieldset>
+               <legend>{lang}wcf.global.systemRequirements.memoryLimit{/lang}</legend>
+               <dl>
+                       <dt>{lang}wcf.global.systemRequirements.element.recommended{/lang} &gt; 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>