Commit 04665d034b51d0a2d423a51b31a86a21def4e9e5
1 parent
b14a2b27
Fixed problem with version compare causing recurring 'upgrade your database' error
Committed by: Paul Barrett Reviewed by: Jarrett Jordaan
Showing
5 changed files
with
16 additions
and
16 deletions
lib/dispatcher.inc.php
| ... | ... | @@ -343,8 +343,8 @@ class KTStandardDispatcher extends KTDispatcher { |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | function loginRequired() { |
| 346 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 347 | - if ($oKTConfig->get('allowAnonymousLogin', false)) { | |
| 346 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 347 | + if ($oKTConfig->get('allowAnonymousLogin', false)) { | |
| 348 | 348 | // anonymous logins are now allowed. |
| 349 | 349 | // the anonymous user is -1. |
| 350 | 350 | // |
| ... | ... | @@ -352,9 +352,9 @@ class KTStandardDispatcher extends KTDispatcher { |
| 352 | 352 | |
| 353 | 353 | $oUser =& User::get(-2); |
| 354 | 354 | if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) { |
| 355 | - ; // do nothing - the database integrity would break if we log the user in now. | |
| 355 | + ; // do nothing - the database integrity would break if we log the user in now. | |
| 356 | 356 | } else { |
| 357 | - $session = new Session(); | |
| 357 | + $session = new Session(); | |
| 358 | 358 | $sessionID = $session->create($oUser); |
| 359 | 359 | $this->sessionStatus = $this->session->verify(); |
| 360 | 360 | if ($this->sessionStatus === true) { | ... | ... |
lib/session/Session.inc
| ... | ... | @@ -228,7 +228,7 @@ class Session { |
| 228 | 228 | // Compare the system version and the database version to determine if the database needs to be upgraded. |
| 229 | 229 | $version = KTUtil::getSystemSetting('databaseVersion'); |
| 230 | 230 | |
| 231 | - if ($default->systemVersion != $version) { | |
| 231 | + if (trim($default->systemVersion) != trim($version)) { | |
| 232 | 232 | if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded"); |
| 233 | 233 | $_SESSION['errormessage']['login'] = sprintf(_kt('Database incompatibility error: <br> Please ensure that you have completed the database upgrade procedure. <br> Please <a href=%s>click here</a> to complete.'),'setup/upgrade.php'); |
| 234 | 234 | return PEAR::raiseError($_SESSION['errormessage']['login']); | ... | ... |
setup/upgrade/lib/UpgradeItems.inc.php
| ... | ... | @@ -269,7 +269,7 @@ class SQLUpgradeItem extends UpgradeItem { |
| 269 | 269 | * |
| 270 | 270 | * STATIC |
| 271 | 271 | */ |
| 272 | - function getUpgrades($origVersion, $currVersion) { | |
| 272 | + public static function getUpgrades($origVersion, $currVersion) { | |
| 273 | 273 | // global $default; |
| 274 | 274 | |
| 275 | 275 | // $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/'; |
| ... | ... | @@ -343,7 +343,7 @@ class SQLUpgradeItem extends UpgradeItem { |
| 343 | 343 | return $ret; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - function _getDetailsFromFileName($path) { | |
| 346 | + public static function _getDetailsFromFileName($path) { | |
| 347 | 347 | // Old format (pre 2.0.6) |
| 348 | 348 | $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches); |
| 349 | 349 | if ($matched != 0) { | ... | ... |
setup/upgrade/lib/upgrade.inc.php
| ... | ... | @@ -92,25 +92,24 @@ function &describeUpgrade ($origVersion, $currVersion) { |
| 92 | 92 | // How to figure out what upgrades to do: |
| 93 | 93 | // |
| 94 | 94 | // 1. Get all SQL upgrades >= origVersion and <= currVersion |
| 95 | - // 2. Get all Function upgrades >= origVersion and <= currVersion | |
| 96 | - // 3. Categorise each into version they upgrade to | |
| 97 | - // 4. Sort each version subgroup into correct order | |
| 95 | + // 2. Categorise each into version they upgrade to | |
| 96 | + // 3. Sort each version subgroup into correct order | |
| 98 | 97 | // 5. Add "recordSubUpgrade" for each version there. |
| 99 | - // 6. Add back into one big list again | |
| 100 | - // 7. Add "recordUpgrade" for whole thing | |
| 98 | + // 5. Add back into one big list again | |
| 99 | + // 6. Add "recordUpgrade" for whole thing | |
| 101 | 100 | |
| 102 | 101 | // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null); |
| 103 | 102 | |
| 104 | 103 | $steps = array(); |
| 105 | 104 | foreach (array('SQLUpgradeItem') as $itemgen) { |
| 106 | 105 | $f = array($itemgen, 'getUpgrades'); |
| 107 | - $ssteps =& call_user_func($f, $origVersion, $currVersion); | |
| 106 | + $ssteps = call_user_func($f, $origVersion, $currVersion); | |
| 108 | 107 | $scount = count($ssteps); |
| 109 | 108 | for ($i = 0; $i < $scount; $i++) { |
| 110 | 109 | $steps[] =& $ssteps[$i]; |
| 111 | 110 | } |
| 112 | 111 | } |
| 113 | - $upgradestep =& new RecordUpgradeItem($currVersion, $origVersion); | |
| 112 | + $upgradestep = new RecordUpgradeItem($currVersion, $origVersion); | |
| 114 | 113 | $steps[] =& $upgradestep; |
| 115 | 114 | $stepcount = count($steps); |
| 116 | 115 | for ($i = 0; $i < $stepcount; $i++) { | ... | ... |
setup/upgrade/steps/upgradeDatabase.php
| ... | ... | @@ -169,15 +169,16 @@ class upgradeDatabase extends Step |
| 169 | 169 | $this->sysVersion = $this->readVersion(); |
| 170 | 170 | $this->temp_variables['systemVersion'] = $this->sysVersion; |
| 171 | 171 | $dconf = $this->util->iniUtilities->getSection('db'); |
| 172 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings'); | |
| 173 | 172 | $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); |
| 173 | + | |
| 174 | + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings'); | |
| 174 | 175 | $result = $this->util->dbUtilities->query($query); |
| 175 | 176 | $assArr = $this->util->dbUtilities->fetchAssoc($result); |
| 176 | 177 | if ($result) { |
| 177 | 178 | $lastVersion = $assArr[0]['value']; |
| 178 | 179 | } |
| 179 | 180 | $currentVersion = $this->sysVersion; |
| 180 | - require_once("lib/upgrade.inc.php"); | |
| 181 | + | |
| 181 | 182 | $upgrades = describeUpgrade($lastVersion, $currentVersion); |
| 182 | 183 | $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; |
| 183 | 184 | $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; | ... | ... |