From: Chad Horohoe Date: Sun, 11 Jul 2010 12:31:44 +0000 (+0000) Subject: Cleanup to r69187: forgot to safeguard against ul_value or updatelog itself not existing. X-Git-Tag: 1.31.0-rc.0~36167 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=0f9f00c26502d729d03b6340e279da9894aaa853;p=lhc%2Fweb%2Fwiklou.git Cleanup to r69187: forgot to safeguard against ul_value or updatelog itself not existing. --- diff --git a/includes/installer/Update.php b/includes/installer/Update.php index 3192c9e747..2fcaeb0431 100644 --- a/includes/installer/Update.php +++ b/includes/installer/Update.php @@ -9,7 +9,7 @@ class Update { // Array of updates to perform on the database protected $updates = array(); - // Thing we'll need + // Things we'll need protected $db, $updater; public function __construct( $db ) { @@ -41,6 +41,12 @@ class Update { } protected function loadUpdates() { + // If the updatelog table hasn't been upgraded, we can't use the new + // style of recording our steps. Run all to be safe + if( !$this->canUseNewUpdatelog() ) { + $this->updates = $this->updater->getUpdates(); + return; + } foreach( $this->updater->getUpdates() as $version => $updates ) { $appliedUpdates = $this->getAppliedUpdates( $version ); if( !$appliedUpdates || $appliedUpdates != $updates ) { @@ -49,7 +55,7 @@ class Update { } } - private function getAppliedUpdates( $version ) { + protected function getAppliedUpdates( $version ) { $key = "updatelist-$version"; $val = $this->db->selectField( 'updatelog', 'ul_value', array( 'ul_key' => $key ), __METHOD__ ); @@ -61,10 +67,27 @@ class Update { } private function setAppliedUpdates( $version, $updates = array() ) { + if( !$this->canUseNewUpdatelog() ) { + $this->updates = $this->updater->getUpdates(); + return; + } $key = "updatelist-$version"; $this->db->delete( 'updatelog', array( 'ul_key' => $key ), __METHOD__ ); $this->db->insert( 'updatelog', array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ), __METHOD__ ); } + + /** + * Updatelog was changed in 1.17 to have a ul_value column so we can record + * more information about what kind of updates we've done (that's what this + * class does). Pre-1.17 wikis won't have this column, and really old wikis + * might not even have updatelog at all + * + * @return boolean + */ + protected function canUseNewUpdatelog() { + return $this->db->tableExists( 'updatelog' ) && + $this->db->fieldExists( 'updatelog', 'ul_value' ); + } }