From e78dfd6681e760a3a7c0e6ac1a34a667214abda7 Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Wed, 30 Oct 2013 21:11:01 -0400 Subject: Clean up Update Remove some cruft, update some comments. --- lib/class/update.class.php | 122 +++++++++++---------------------------------- 1 file changed, 29 insertions(+), 93 deletions(-) (limited to 'lib/class') diff --git a/lib/class/update.class.php b/lib/class/update.class.php index dcaeceaf..76170c16 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -23,61 +23,34 @@ /** * Update Class * - * this class handles updating from one version of - * ampache to the next. Versions are a 6 digit number - *
- *  220000
- *  ^
- *  Major Revision
- *
- *  220000
- *   ^
- *  Minor Revision
- * 
- * - * The last 4 digits are a build number... - * If Minor can't go over 9 Major can go as high as we want - * + * This class mainly handles schema updates for the database. + * Versions are a monotonically increasing integer: First column(s) are the + * major version, followed by a single column for the minor version and four + * columns for the build number. 3.6 build 1 is 360000; 10.9 build 17 is + * 1090017. */ + class Update { public $key; public $value; public static $versions; // array containing version information - /** - * Update - * Constructor, pulls out information about the desired key - */ - function Update ( $key=0 ) { - - if (!$key) { return false; } - - $this->key = intval($key); - $info = $this->_get_info(); - $this->value = $info['value']; - $this->versions = $this->populate_version(); - - } // constructor - - /** - * _get_info - * gets the information for the zone + /* + * Constructor + * + * This should never be called */ - private function _get_info() { - - $sql = "SELECT * FROM `update_info` WHERE `key`='$this->key'"; - $db_results = Dba::read($sql); - - return Dba::fetch_assoc($db_results); - - } // _get_info + private function __construct() { + // static class + } /** * get_version - * this checks to see what version you are currently running - * because we may not have the update_info table we have to check - * for it's existance first. + * + * This checks to see what version you are currently running. + * Because we may not have the update_info table we have to check + * for its existence first. */ public static function get_version() { @@ -109,69 +82,39 @@ class Update { /** * format_version - * make the version number pretty + * + * Make the version number pretty. */ public static function format_version($data) { - - $new_version = substr($data,0,strlen($data) - 5) . "." . substr($data,strlen($data)-5,1) . " Build:" . - substr($data,strlen($data)-4,strlen($data)); + $new_version = + substr($data, 0, strlen($data) - 5) . '.' . + substr($data, strlen($data) - 5, 1) . ' Build:' . + substr($data, strlen($data) - 4, strlen($data)); return $new_version; - - } // format_version + } /** * need_update - * checks to see if we need to update - * ampache at all + * + * Checks to see if we need to update ampache at all. */ public static function need_update() { - $current_version = self::get_version(); if (!is_array(self::$versions)) { self::$versions = self::populate_version(); } - /* - Go through the versions we have and see if - we need to apply any updates - */ + // Iterate through the versions and see if we need to apply any updates foreach (self::$versions as $update) { if ($update['version'] > $current_version) { return true; } - - } // end foreach version + } return false; - - } // need_update - - /** - * plugins_installed - * This function checks to make sure that there are no plugins - * installed before allowing you to run the update. this is - * to protect the integrity of the database - */ - public static function plugins_installed() { - - /* Pull all version info */ - $sql = "SELECT * FROM `update_info`"; - $db_results = Dba::read($sql); - - while ($results = Dba::fetch_assoc($db_results)) { - - /* We have only one allowed string */ - if ($results['key'] != 'db_version') { - return false; - } - - } // while update_info results - - return true; - - } // plugins_installed + } /** * populate_version @@ -407,13 +350,6 @@ class Update { // Prevent the script from timing out, which could be bad set_time_limit(0); - /* Verify that there are no plugins installed - //FIXME: provide a link to remove all plugins, otherwise this could turn into a catch 22 - if (!$self::plugins_installed()) { - $GLOBALS['error']->add_error('general', T_('Plugins detected, please remove all Plugins and try again')); - return false; - } */ - $methods = array(); $current_version = self::get_version(); -- cgit