Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | class ArticleFeedbackHooks { |
11 | | - |
| 11 | + |
12 | 12 | protected static $modules = array( |
13 | 13 | 'ext.articleFeedback.startup' => array( |
14 | 14 | 'scripts' => 'ext.articleFeedback/ext.articleFeedback.startup.js', |
— | — | @@ -121,11 +121,15 @@ |
122 | 122 | ), |
123 | 123 | ), |
124 | 124 | ); |
125 | | - |
| 125 | + |
126 | 126 | /* Static Methods */ |
127 | | - |
| 127 | + |
128 | 128 | /** |
129 | 129 | * LoadExtensionSchemaUpdates hook |
| 130 | + * |
| 131 | + * @param $updater DatabaseUpdater |
| 132 | + * |
| 133 | + * @return bool |
130 | 134 | */ |
131 | 135 | public static function loadExtensionSchemaUpdates( $updater = null ) { |
132 | 136 | if ( $updater === null ) { |
— | — | @@ -137,44 +141,42 @@ |
138 | 142 | } else { |
139 | 143 | $dir = dirname( __FILE__ ); |
140 | 144 | $db = $updater->getDB(); |
141 | | - if ( !$db->tableExists( 'article_feedback' ) ) { |
| 145 | + |
| 146 | + if ( $db->tableExists( 'article_assessment' ) ) { |
142 | 147 | // Rename tables |
143 | | - if ( $db->tableExists( 'article_assessment' ) ) { |
144 | | - $updater->addExtensionUpdate( array( |
145 | | - 'addTable', |
146 | | - 'article_feedback', |
147 | | - $dir . '/sql/RenameTables.sql', |
148 | | - true |
149 | | - ) ); |
150 | | - } else { |
151 | | - // Initial install tables |
152 | | - $updater->addExtensionUpdate( array( |
153 | | - 'addTable', |
154 | | - 'article_feedback', |
155 | | - $dir . '/sql/ArticleFeedback.sql', |
156 | | - true |
157 | | - ) ); |
158 | | - } |
159 | | - } |
160 | | - if ( !$db->fieldExists( 'article_feedback', 'aa_design_bucket', __METHOD__ ) ) { |
161 | 148 | $updater->addExtensionUpdate( array( |
162 | | - 'addField', |
| 149 | + 'addTable', |
163 | 150 | 'article_feedback', |
164 | | - 'aa_design_bucket', |
165 | | - $dir . '/sql/AddRatingBucket.sql', |
| 151 | + $dir . '/sql/RenameTables.sql', |
166 | 152 | true |
167 | 153 | ) ); |
168 | | - } |
169 | | - if ( !$db->fieldExists( 'article_feedback_properties', 'afp_value_text', __METHOD__ ) ) { |
| 154 | + } else { |
| 155 | + // Initial install tables |
170 | 156 | $updater->addExtensionUpdate( array( |
171 | | - 'addField', |
172 | | - 'article_feedback_properties', |
173 | | - 'afp_value_text', |
174 | | - $dir . '/sql/AddPropertiesValueText.sql', |
| 157 | + 'addTable', |
| 158 | + 'article_feedback', |
| 159 | + $dir . '/sql/ArticleFeedback.sql', |
175 | 160 | true |
176 | 161 | ) ); |
177 | 162 | } |
| 163 | + |
178 | 164 | $updater->addExtensionUpdate( array( |
| 165 | + 'addField', |
| 166 | + 'article_feedback', |
| 167 | + 'aa_design_bucket', |
| 168 | + $dir . '/sql/AddRatingBucket.sql', |
| 169 | + true |
| 170 | + ) ); |
| 171 | + |
| 172 | + $updater->addExtensionUpdate( array( |
| 173 | + 'addField', |
| 174 | + 'article_feedback_properties', |
| 175 | + 'afp_value_text', |
| 176 | + $dir . '/sql/AddPropertiesValueText.sql', |
| 177 | + true |
| 178 | + ) ); |
| 179 | + |
| 180 | + $updater->addExtensionUpdate( array( |
179 | 181 | 'addTable', |
180 | 182 | 'article_feedback_properties', |
181 | 183 | $dir . '/sql/AddPropertiesTable.sql', |
— | — | @@ -196,53 +198,30 @@ |
197 | 199 | $dir . '/sql/AddRevisionsTable.sql', |
198 | 200 | true |
199 | 201 | ) ); |
200 | | - |
201 | | - if ( $db->tableExists( 'article_feedback_stats_highs_lows') ) { |
202 | | - if ( !$db->tableExists( 'article_feedback_stats_types' )) { |
203 | | - // add article_feedback_stats_type if necessaray |
204 | | - $updater->addExtensionUpdate( array( |
205 | | - 'addTable', |
206 | | - 'article_feedback_stats_types', |
207 | | - $dir . '/sql/AddArticleFeedbackStatsTypeTable.sql', |
208 | | - true |
209 | | - ) ); |
210 | | - } |
211 | | - |
212 | | - $updater->addExtensionUpdate( array( |
213 | | - 'addTable', |
214 | | - 'article_feedback_stats', |
215 | | - $dir . '/sql/AddArticleFeedbackStatsTable.sql', |
216 | | - true |
217 | | - ) ); |
218 | | - |
219 | | - // migrate article_feedback_stats_highs_lows to article_feedback_stats |
220 | | - $updater->addExtensionUpdate( array( |
221 | | - 'applyPatch', |
222 | | - $dir . '/sql/MigrateArticleFeedbackStatsHighsLows.sql', |
223 | | - true |
224 | | - ) ); |
225 | | - } else { |
226 | | - // add article_feedback_stats and article_feedback_stats_type |
227 | | - if ( !$db->tableExists( 'article_feedback_stats_types' )) { |
228 | | - $updater->addExtensionUpdate( array( |
229 | | - 'addTable', |
230 | | - 'article_feedback_stats_types', |
231 | | - $dir . '/sql/AddArticleFeedbackStatsTypeTable.sql', |
232 | | - true |
233 | | - ) ); |
234 | | - } |
235 | | - |
236 | | - if ( !$db->tableExists( 'article_feedback_stats' )) { |
237 | | - $updater->addExtensionUpdate( array( |
238 | | - 'addTable', |
239 | | - 'article_feedback_stats', |
240 | | - $dir . '/sql/AddArticleFeedbackStatsTable.sql', |
241 | | - true |
242 | | - ) ); |
243 | | - } |
244 | | - } |
245 | | - |
| 202 | + |
| 203 | + // add article_feedback_stats_type if necessaray |
246 | 204 | $updater->addExtensionUpdate( array( |
| 205 | + 'addTable', |
| 206 | + 'article_feedback_stats_types', |
| 207 | + $dir . '/sql/AddArticleFeedbackStatsTypeTable.sql', |
| 208 | + true |
| 209 | + ) ); |
| 210 | + |
| 211 | + $updater->addExtensionUpdate( array( |
| 212 | + 'addTable', |
| 213 | + 'article_feedback_stats', |
| 214 | + $dir . '/sql/AddArticleFeedbackStatsTable.sql', |
| 215 | + true |
| 216 | + ) ); |
| 217 | + |
| 218 | + // migrate article_feedback_stats_highs_lows to article_feedback_stats |
| 219 | + $updater->addExtensionUpdate( array( |
| 220 | + 'applyPatch', |
| 221 | + $dir . '/sql/MigrateArticleFeedbackStatsHighsLows.sql', |
| 222 | + true |
| 223 | + ) ); |
| 224 | + |
| 225 | + $updater->addExtensionUpdate( array( |
247 | 226 | 'addIndex', |
248 | 227 | 'article_feedback', |
249 | 228 | 'article_feedback_timestamp', |
— | — | @@ -252,7 +231,7 @@ |
253 | 232 | } |
254 | 233 | return true; |
255 | 234 | } |
256 | | - |
| 235 | + |
257 | 236 | /** |
258 | 237 | * ParserTestTables hook |
259 | 238 | */ |
— | — | @@ -264,7 +243,7 @@ |
265 | 244 | $tables[] = 'article_feedback_properties'; |
266 | 245 | return true; |
267 | 246 | } |
268 | | - |
| 247 | + |
269 | 248 | /** |
270 | 249 | * BeforePageDisplay hook |
271 | 250 | */ |
— | — | @@ -272,7 +251,7 @@ |
273 | 252 | $out->addModules( 'ext.articleFeedback.startup' ); |
274 | 253 | return true; |
275 | 254 | } |
276 | | - |
| 255 | + |
277 | 256 | /* |
278 | 257 | * ResourceLoaderRegisterModules hook |
279 | 258 | */ |
— | — | @@ -287,7 +266,7 @@ |
288 | 267 | } |
289 | 268 | return true; |
290 | 269 | } |
291 | | - |
| 270 | + |
292 | 271 | /* |
293 | 272 | * ResourceLoaderGetConfigVars hook |
294 | 273 | */ |
— | — | @@ -309,7 +288,7 @@ |
310 | 289 | $vars['wgArticleFeedbackWhatsThisPage'] = wfMsgForContent( 'articlefeedback-form-panel-explanation-link' ); |
311 | 290 | return true; |
312 | 291 | } |
313 | | - |
| 292 | + |
314 | 293 | /** |
315 | 294 | * Add the preference in the user preferences with the GetPreferences hook. |
316 | 295 | * @param $user User |