Index: trunk/phase3/includes/installer/Update.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | // Array of updates to perform on the database |
11 | 11 | protected $updates = array(); |
12 | 12 | |
13 | | - // Thing we'll need |
| 13 | + // Things we'll need |
14 | 14 | protected $db, $updater; |
15 | 15 | |
16 | 16 | public function __construct( $db ) { |
— | — | @@ -41,6 +41,12 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | 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 | + } |
45 | 51 | foreach( $this->updater->getUpdates() as $version => $updates ) { |
46 | 52 | $appliedUpdates = $this->getAppliedUpdates( $version ); |
47 | 53 | if( !$appliedUpdates || $appliedUpdates != $updates ) { |
— | — | @@ -49,7 +55,7 @@ |
50 | 56 | } |
51 | 57 | } |
52 | 58 | |
53 | | - private function getAppliedUpdates( $version ) { |
| 59 | + protected function getAppliedUpdates( $version ) { |
54 | 60 | $key = "updatelist-$version"; |
55 | 61 | $val = $this->db->selectField( 'updatelog', 'ul_value', |
56 | 62 | array( 'ul_key' => $key ), __METHOD__ ); |
— | — | @@ -61,10 +67,27 @@ |
62 | 68 | } |
63 | 69 | |
64 | 70 | private function setAppliedUpdates( $version, $updates = array() ) { |
| 71 | + if( !$this->canUseNewUpdatelog() ) { |
| 72 | + $this->updates = $this->updater->getUpdates(); |
| 73 | + return; |
| 74 | + } |
65 | 75 | $key = "updatelist-$version"; |
66 | 76 | $this->db->delete( 'updatelog', array( 'ul_key' => $key ), __METHOD__ ); |
67 | 77 | $this->db->insert( 'updatelog', |
68 | 78 | array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ), |
69 | 79 | __METHOD__ ); |
70 | 80 | } |
| 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 | + } |
71 | 94 | } |