diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 186458e0e3a4f90e24a5ca3e7913d18d6b14e928..fea6b94615416fc349a2e5fcd4b13330705e4633 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -59,7 +59,7 @@ class installer_base { } public function simple_query($query, $answers, $default, $name = '') { - global $autoinstall; + global $autoinstall, $autoupdate; $finished = false; do { if($name != '' && $autoinstall[$name] != '') { @@ -104,7 +104,7 @@ class installer_base { } public function free_query($query, $default, $name = '') { - global $autoinstall; + global $autoinstall, $autoupdate; if($name != '' && $autoinstall[$name] != '') { if($autoinstall[$name] == 'default') { $input = $default; diff --git a/interface/lib/classes/aps_crawler.inc.php b/interface/lib/classes/aps_crawler.inc.php index 99db77bdbf7a822f188613d8aee255bdc55bd669..a8fe812d28b8fcdf3f1428566675c5394bf8d624 100644 --- a/interface/lib/classes/aps_crawler.inc.php +++ b/interface/lib/classes/aps_crawler.inc.php @@ -261,10 +261,13 @@ class ApsCrawler extends ApsBase // Get all known apps from the database and the highest known version // Note: A dirty hack is used for numerical sorting of the VARCHAR field Version: +0 -> cast // A longer but typesafe way would be: ORDER BY CAST(REPLACE(Version, '.', '') AS UNSIGNED) DESC - $existing_apps = $app->db->queryAllRecords("SELECT * FROM ( - SELECT name AS Name, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion - FROM aps_packages ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC - ) as Versions GROUP BY name"); + $existing_apps = array(); + $tmpres = $app->db->query("SELECT name as `Name`, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion FROM aps_packages ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(version,'.0.0.0'),'.',4)) DESC, `release` DESC"); + while($tmp = $tmpres->get()) { + if(!array_key_exists($tmp['Name'], $existing_apps)) $existing_apps[$tmp['Name']] = $tmp; + } + $tmpres->free(); + unset($tmp); //var_dump($existing_apps); // Used for statistics later @@ -492,6 +495,23 @@ class ApsCrawler extends ApsBase $app->log($this->log_prefix.'Processed '.$apps_in_repo. ' apps from the repo. Downloaded '.$apps_updated. ' updates, '.$apps_downloaded.' new apps'); + + $prevapp = ''; + $res = $app->db->query("SELECT `id`, `name`, `version`, `release`, `package_status` FROM `aps_packages` WHERE 1 ORDER BY `name` ASC, INET_ATON(SUBSTRING_INDEX(CONCAT(version,'.0.0.0'),'.',4)) DESC, `release` DESC"); + while($curapp = $res->get()) { + if($curapp['name'] != $prevapp) { + $prevapp = $curapp['name']; + continue; + } + if($curapp['package_status'] != PACKAGE_OUTDATED) { + $app->log($this->log_prefix.'Tagging ' . $curapp['name'] . ' ' . $curapp['version'] . '-' . $curapp['release'] . ' as outdated.'); + $app->db->query("UPDATE `aps_packages` SET `package_status` = ? WHERE `id` = ?", PACKAGE_OUTDATED, $curapp['id']); + $app->db->datalogUpdate('aps_packages', array("package_status" => PACKAGE_OUTDATED), 'id', $curapp['id']); + } + } + $res->free(); + unset($curapp); + unset($prevapp); } catch(Exception $e) diff --git a/interface/lib/classes/aps_guicontroller.inc.php b/interface/lib/classes/aps_guicontroller.inc.php index ab7f3f4dafeae0904189781d27fa5a61db912b46..16dd9e82f1666d03ac59f163ee8fe813498f5840 100644 --- a/interface/lib/classes/aps_guicontroller.inc.php +++ b/interface/lib/classes/aps_guicontroller.inc.php @@ -166,7 +166,7 @@ class ApsGUIController extends ApsBase FROM aps_packages WHERE name = (SELECT name FROM aps_packages WHERE id = ?) AND package_status = 2 - ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC", $id); + ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(version,'.0.0.0'),'.',4)) DESC, `release` DESC", $id); if(!empty($result) && ($id != $result['id'])) return $result['id']; diff --git a/server/lib/classes/aps_installer.inc.php b/server/lib/classes/aps_installer.inc.php index 5270a5ae9ed0b6d035a6b3aecc2155b36e65c7ca..9b601d90b341d5f7722da5468a55e74d1961da24 100644 --- a/server/lib/classes/aps_installer.inc.php +++ b/server/lib/classes/aps_installer.inc.php @@ -306,7 +306,7 @@ class ApsInstaller extends ApsBase $db_id = parent::getXPathValue($sxe, '//db:id'); if(empty($db_id)) return; // No database needed - $mysqlver_res = $app->db->queryOneRecord('SELECT VERSION() as ver;'); + $mysqlver_res = $app->db->queryOneRecord('SELECT VERSION() as ver'); $mysqlver = $mysqlver_res['ver']; $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_password' AND instance_id = ?", $task['instance_id']);