r69251 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69250‎ | r69251 | r69252 >
Date:12:31, 11 July 2010
Author:demon
Status:ok
Tags:
Comment:
Cleanup to r69187: forgot to safeguard against ul_value or updatelog itself not existing.
Modified paths:
  • /trunk/phase3/includes/installer/Update.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Update.php
@@ -9,7 +9,7 @@
1010 // Array of updates to perform on the database
1111 protected $updates = array();
1212
13 - // Thing we'll need
 13+ // Things we'll need
1414 protected $db, $updater;
1515
1616 public function __construct( $db ) {
@@ -41,6 +41,12 @@
4242 }
4343
4444 protected function loadUpdates() {
 45+ // If the updatelog table hasn't been upgraded, we can't use the new
 46+ // style of recording our steps. Run all to be safe
 47+ if( !$this->canUseNewUpdatelog() ) {
 48+ $this->updates = $this->updater->getUpdates();
 49+ return;
 50+ }
4551 foreach( $this->updater->getUpdates() as $version => $updates ) {
4652 $appliedUpdates = $this->getAppliedUpdates( $version );
4753 if( !$appliedUpdates || $appliedUpdates != $updates ) {
@@ -49,7 +55,7 @@
5056 }
5157 }
5258
53 - private function getAppliedUpdates( $version ) {
 59+ protected function getAppliedUpdates( $version ) {
5460 $key = "updatelist-$version";
5561 $val = $this->db->selectField( 'updatelog', 'ul_value',
5662 array( 'ul_key' => $key ), __METHOD__ );
@@ -61,10 +67,27 @@
6268 }
6369
6470 private function setAppliedUpdates( $version, $updates = array() ) {
 71+ if( !$this->canUseNewUpdatelog() ) {
 72+ $this->updates = $this->updater->getUpdates();
 73+ return;
 74+ }
6575 $key = "updatelist-$version";
6676 $this->db->delete( 'updatelog', array( 'ul_key' => $key ), __METHOD__ );
6777 $this->db->insert( 'updatelog',
6878 array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ),
6979 __METHOD__ );
7080 }
 81+
 82+ /**
 83+ * Updatelog was changed in 1.17 to have a ul_value column so we can record
 84+ * more information about what kind of updates we've done (that's what this
 85+ * class does). Pre-1.17 wikis won't have this column, and really old wikis
 86+ * might not even have updatelog at all
 87+ *
 88+ * @return boolean
 89+ */
 90+ protected function canUseNewUpdatelog() {
 91+ return $this->db->tableExists( 'updatelog' ) &&
 92+ $this->db->fieldExists( 'updatelog', 'ul_value' );
 93+ }
7194 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r69252Followup r69251, copy+paste faildemon12:34, 11 July 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69187Refactor a lot of updaters.inc into some classes in the installer code. Still...demon14:57, 8 July 2010

Status & tagging log