Marius Cramer
2015-01-08 89e4329a8068e3631d3f64f6896fa3907c687cf5
install/lib/update.lib.php
@@ -29,10 +29,10 @@
//* Installer patch stub class
class installer_patch_update {
   protected function onBeforeSQL() {
   public function onBeforeSQL() {
   }
   protected function onAfterSQL() {
   public function onAfterSQL() {
   }
}
@@ -153,17 +153,22 @@
      $conf['nginx']['installed'] = false;
   }
   //* Do incremental DB updates only on installed ISPConfig versions > 3.0.3
   if(compare_ispconfig_version('3.0.3', ISPC_APP_VERSION) >= 0) {
   //* Do incremental DB updates only on installed ISPConfig versions >= 3.0.3
   if(version_compare('3.0.3', ISPC_APP_VERSION, '<=')) {
      swriteln($inst->lng('Starting incremental database update.'));
      //* get the version of the db schema from the server table
      $found = true;
      $dev_patch = false;
      while($found == true) {
         $next_db_version = intval($current_db_version + 1);
         if($dev_patch == true) $next_db_version = 'dev_collection';
         else $next_db_version = intval($current_db_version + 1);
         $sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
         $php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php';
         // comma separated list of version numbers were a update has to be done silently
         $silent_update_versions = 'dev_collection,75';
         if(is_file($sql_patch_filename)) {
@@ -186,10 +191,14 @@
            //* Load patch file into database
            if( !empty($conf["mysql"]["admin_password"]) ) {
               system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
               $cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
            } else {
               system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
               $cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
            }
            if(in_array($next_db_version,explode(',',$silent_update_versions))) $cmd .= ' > /dev/null 2> /dev/null';
            system($cmd);
            swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename);
            //* Exec onAfterSQL function
@@ -197,8 +206,12 @@
               $php_patch->onAfterSQL();
            }
            $current_db_version = $next_db_version;
            if($dev_patch == false) $current_db_version = $next_db_version;
            else $found = false;
            if(isset($php_patch)) unset($php_patch);
         } elseif($dev_patch == false) {
            $dev_patch = true;
         } else {
            $found = false;
         }