diff --git a/include/class.config.php b/include/class.config.php index 7123205dd2c24e04bd5dda97ef096f6b5c01cd9e..d01d1be1bf8306cc974cb1f955f857acec23b4dc 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -39,13 +39,9 @@ class Config { $sql='SELECT id, `key`, value FROM '.$this->table .' WHERE `'.$this->section_column.'` = '.db_input($this->section); - if(!($res=db_query($sql)) || !db_num_rows($res)) - return false; - - while ($row = db_fetch_array($res)) - $this->config[$row['key']] = $row; - - return true; + if(($res=db_query($sql)) && db_num_rows($res)) + while ($row = db_fetch_array($res)) + $this->config[$row['key']] = $row; } function getNamespace() { @@ -59,6 +55,7 @@ class Config { return $this->session[$key]; elseif ($default !== null) return $this->set($key, $default); + return null; } function exists($key) { @@ -75,11 +72,11 @@ class Config { } function create($key, $value) { - $res = db_query('INSERT INTO '.$this->table + $sql = 'INSERT INTO '.$this->table .' SET `'.$this->section_column.'`='.db_input($this->section) .', `key`='.db_input($key) - .', value='.db_input($value)); - if (!db_query($res) || !($id=db_insert_id())) + .', value='.db_input($value); + if (!db_query($sql) || !($id=db_insert_id())) return false; $this->config[$key] = array('key'=>$key, 'value'=>$value, 'id'=>$id); @@ -123,6 +120,14 @@ class OsticketConfig extends Config { function OsticketConfig($section=null) { parent::Config($section); + if (count($this->config) == 0) { + // Fallback for osticket < 1.7@852ca89e + $sql='SELECT * FROM '.$this->table.' WHERE id = 1'; + if (($res=db_query($sql)) && db_num_rows($res)) + foreach (db_fetch_array($res) as $key=>$value) + $this->config[$key] = array('value'=>$value); + } + //Get the default time zone // We can't JOIN timezone table above due to upgrade support. if ($this->get('default_timezone_id')) { @@ -146,7 +151,7 @@ class OsticketConfig extends Config { } function isOnline() { - return ($this->get('isonline', false)); + return ($this->get('isonline')); } function isKnowledgebaseEnabled() { @@ -166,19 +171,19 @@ class OsticketConfig extends Config { // 1.7 after namespaced configuration, other namespace if ($section) { $sql='SELECT value FROM '.$this->table - .'WHERE `key` = "schema_signature" and namespace='.db_input($section); + .' WHERE `key` = "schema_signature" and namespace='.db_input($section); if (($res=db_query($sql, false)) && db_num_rows($res)) return db_result($res); } // 1.7 before namespaced configuration $sql='SELECT `schema_signature` FROM '.$this->table - .'WHERE id=1'; + .' WHERE id=1'; if (($res=db_query($sql, false)) && db_num_rows($res)) return db_result($res); // old version 1.6 - return self::getDBVersion(); + return md5(self::getDBVersion()); } function getDBTZoffset() { diff --git a/include/class.migrater.php b/include/class.migrater.php index 93854d797d72c150f71dc13a30831509ee9665c7..ba26d091e31defa230ab4da3f7420d3e044dbaf2 100644 --- a/include/class.migrater.php +++ b/include/class.migrater.php @@ -212,7 +212,7 @@ class AttachmentMigrater { if(!($res=db_query($sql))) return $this->error('Unable to query DB for attached files to migrate!'); - $ost->logDebug('Found '.db_num_rows($res).' attachments to migrate'); + $ost->logDebug("Attachment migration", 'Found '.db_num_rows($res).' attachments to migrate'); if(!db_num_rows($res)) return 0; //Nothing else to do!! diff --git a/include/class.osticket.php b/include/class.osticket.php index cd130e1fff77cba5b07d1da07ec0c9c0c5e24e3b..1a1945218d05ba79ba906d41ddaf8eb4ce942b2a 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -229,7 +229,7 @@ class osTicket { if($email) { $email->sendAlert($to, $subject, $message); } else {//no luck - try the system mail. - Email::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>',$to)); + Mailer::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>',$to)); } //log the alert? Watch out for loops here. diff --git a/include/class.ostsession.php b/include/class.ostsession.php index bad26c1e71e7a8ea385a578f59ac4d0140d084d3..f2be6b18b5ea2ffe9c94beda2cfd896e699e91f4 100644 --- a/include/class.ostsession.php +++ b/include/class.ostsession.php @@ -26,7 +26,7 @@ class osTicketSession { if(!$this->ttl) $this->ttl=SESSION_TTL; - if ($this->read(session_id()) !== false) { + if (!OsticketConfig::getDBVersion()) { //Set handlers. session_set_save_handler( array(&$this, 'open'), diff --git a/include/class.upgrader.php b/include/class.upgrader.php index 8b86b9e5724f07ea3fbb4bf3132a554e79ca7586..8f6fea22342aacb2c2a23da4547f7c9d935a7e47 100644 --- a/include/class.upgrader.php +++ b/include/class.upgrader.php @@ -148,10 +148,11 @@ class Upgrader extends SetupWizard { function readPatchInfo($patch) { $info = array(); - if (preg_match('/\*(.*)\*/', file_get_contents($patch), $matches)) { - if (preg_match('/@([\w\d_-]+)\s+(.*)$/', $matches[0], $matches2)) + if (preg_match(':/\*\*(.*)\*/:s', file_get_contents($patch), $matches)) { + if (preg_match_all('/@([\w\d_-]+)\s+(.*)$/m', $matches[0], + $matches2, PREG_SET_ORDER)) foreach ($matches2 as $match) - $info[$match[0]] = $match[1]; + $info[$match[1]] = $match[2]; } if (!isset($info['version'])) $info['version'] = substr(basename($patch), 9, 8); @@ -249,7 +250,8 @@ class Upgrader extends SetupWizard { if(!($max_time = ini_get('max_execution_time'))) $max_time = 300; //Apache/IIS defaults. - foreach ($patches as $patch) { + // Apply up to five patches at a time + foreach (array_slice($patches, 0, 5) as $patch) { //TODO: check time used vs. max execution - break if need be if (!$this->load_sql_file($patch, $this->getTablePrefix())) return false; diff --git a/include/upgrader/sql/32de1766-75fce769.patch.sql b/include/upgrader/sql/32de1766-852ca89e.patch.sql similarity index 98% rename from include/upgrader/sql/32de1766-75fce769.patch.sql rename to include/upgrader/sql/32de1766-852ca89e.patch.sql index f4bd4b323975692771ca36e7018b7fc9b039235a..ba1768fa33fa041703b22cd3257be91eb886fc45 100644 --- a/include/upgrader/sql/32de1766-75fce769.patch.sql +++ b/include/upgrader/sql/32de1766-852ca89e.patch.sql @@ -1,6 +1,6 @@ /** * @version v1.7.1 - * @signature 75fce76967f1549ffd296a44139dea57 + * @signature 852ca89e1440e736d763b3b87f039bd7 * * - Changes config table to be key/value based and allows for * configuration key clobbering by defining a namespace for the keys. The @@ -18,9 +18,8 @@ CREATE TABLE `%TABLE_PREFIX%_config` ( UNIQUE KEY (`namespace`, `key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -INSERT INTO `%TABLE_PREFIX%_config` (`key`, `value`, `namespace`) VALUES +INSERT INTO `%TABLE_PREFIX%_config` (`key`, `value`, `namespace`) VALUES ('isonline', (SELECT `isonline` FROM `%TABLE_PREFIX%config` WHERE `id` = 1), 'core') -, ('timezone_offset', (SELECT `timezone_offset` FROM `%TABLE_PREFIX%config` WHERE `id` = 1), 'core') , ('enable_daylight_saving', (SELECT `enable_daylight_saving` FROM `%TABLE_PREFIX%config` WHERE `id` = 1), 'core') , ('staff_ip_binding', (SELECT `staff_ip_binding` FROM `%TABLE_PREFIX%config` WHERE `id` = 1), 'core') , ('staff_max_logins', (SELECT `staff_max_logins` FROM `%TABLE_PREFIX%config` WHERE `id` = 1), 'core') @@ -120,5 +119,5 @@ ALTER TABLE `%TABLE_PREFIX%_config` RENAME TO `%TABLE_PREFIX%config`; -- Finished with patch UPDATE `%TABLE_PREFIX%config` - SET `value` = '75fce76967f1549ffd296a44139dea57' + SET `value` = '852ca89e1440e736d763b3b87f039bd7' WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/main.inc.php b/main.inc.php index 7c6a9c2f711b448e0c2174ba2e113e6755e63f3b..69ec71bde3045b4f22d0c7ffef5d93f01621f742 100644 --- a/main.inc.php +++ b/main.inc.php @@ -76,7 +76,7 @@ #Current version && schema signature (Changes from version to version) define('THIS_VERSION','1.7.0+'); //Shown on admin panel - define('SCHEMA_SIGNATURE', '75fce76967f1549ffd296a44139dea57'); //MD5 signature of the db schema. (used to trigger upgrades) + define('SCHEMA_SIGNATURE', '852ca89e1440e736d763b3b87f039bd7'); //MD5 signature of the db schema. (used to trigger upgrades) #load config info $configfile=''; if(file_exists(ROOT_DIR.'ostconfig.php')) //Old installs prior to v 1.6 RC5 diff --git a/setup/inc/sql/osTicket-mysql.sql b/setup/inc/sql/osTicket-mysql.sql index 66f081d4a3685215084d04bb1f2cfe46b3970df1..6ad1a1810f2248ac2c840a10c50e313c541e896b 100644 --- a/setup/inc/sql/osTicket-mysql.sql +++ b/setup/inc/sql/osTicket-mysql.sql @@ -91,7 +91,6 @@ CREATE TABLE `%TABLE_PREFIX%config` ( INSERT INTO `%TABLE_PREFIX%config` (`namespace`, `key`, `value`) VALUES ('core', 'isonline', '0'), - ('core', 'timezone_offset', '0.0'), ('core', 'enable_daylight_saving', '0'), ('core', 'staff_ip_binding', '1'), ('core', 'staff_max_logins', '4'), diff --git a/setup/inc/sql/osTicket-mysql.sql.md5 b/setup/inc/sql/osTicket-mysql.sql.md5 index 772bbd1097ceb3d4a881b84b03143ce69cc70e60..d55c64b4a73863e0de3bb0b52805535251c07dfe 100644 --- a/setup/inc/sql/osTicket-mysql.sql.md5 +++ b/setup/inc/sql/osTicket-mysql.sql.md5 @@ -1 +1 @@ -75fce76967f1549ffd296a44139dea57 +852ca89e1440e736d763b3b87f039bd7