MediaWiki REL1_37
MysqlUpdater.php
Go to the documentation of this file.
1<?php
24
33 protected function getCoreUpdateList() {
34 return [
35 // 1.28
36 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
37 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
38 [ 'doRevisionPageRevIndexNonUnique' ],
39 [ 'doNonUniquePlTlIl' ],
40 [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
41 [ 'modifyField', 'recentchanges', 'rc_ip', 'patch-rc_ip_modify.sql' ],
42 [ 'ifTableNotExists', 'actor', 'addIndex', 'archive', 'usertext_timestamp',
43 'patch-rename-ar_usertext_timestamp.sql' ],
44
45 // 1.29
46 [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
47 [ 'dropIndex', 'user_groups', 'ug_user_group', 'patch-user_groups-primary-key.sql' ],
48 [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
49 [ 'ifTableNotExists', 'actor',
50 'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
51
52 // 1.30
53 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
54 [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
55 [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
56 'patch-categorylinks-fix-pk.sql' ],
57 [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
58 'patch-templatelinks-fix-pk.sql' ],
59 [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
60 [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
61 [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
62 [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
63 [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
64 [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
65 [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
66 'patch-module_deps-fix-pk.sql' ],
67 [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
68 [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
69 'patch-querycache_info-fix-pk.sql' ],
70 [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
71 [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
72 'patch-user_former_groups-fix-pk.sql' ],
73 [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
74 'patch-user_properties-fix-pk.sql' ],
75 [ 'addTable', 'comment', 'patch-comment-table.sql' ],
76 [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
77 [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
78 [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
79 [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
80 [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
81 [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
82 [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
83 [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
84 [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
85 [ 'setDefault', 'revision', 'rev_comment', '' ],
86
87 // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
88 [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
89
90 [ 'migrateComments' ],
91 [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
92 'patch-l10n_cache-primary-key.sql' ],
93 [ 'doUnsignedSyncronisation' ],
94
95 // 1.31
96 [ 'addTable', 'slots', 'patch-slots.sql' ],
97 [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
98 [ 'addTable', 'content', 'patch-content.sql' ],
99 [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
100 [ 'addTable', 'content_models', 'patch-content_models.sql' ],
101 [ 'migrateArchiveText' ],
102 [ 'addTable', 'actor', 'patch-actor-table.sql' ],
103 [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
104 [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
105 [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
106 [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
107 [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
108 [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
109 [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
110 [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
111 [ 'migrateActors' ],
112
113 // Adds a default value to the rev_text_id field to allow Multi Content
114 // Revisions migration to happen where rows will have to be added to the
115 // revision table with no rev_text_id.
116 [ 'setDefault', 'revision', 'rev_text_id', 0 ],
117 [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
118 [ 'populateArchiveRevId' ],
119 [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
120 'patch-recentchanges-nttindex.sql' ],
121
122 // 1.32
123 [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
124 [ 'populateExternallinksIndex60' ],
125 [ 'dropDefault', 'externallinks', 'el_index_60' ],
126 [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
127 [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
128 [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
129 [ 'populateContentTables' ],
130 [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
131 [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
132 [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
133 [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
134 'patch-page_props-fix-pk.sql' ],
135 [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
136 'patch-protected_titles-fix-pk.sql' ],
137 [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
138 'patch-site_identifiers-fix-pk.sql' ],
139 [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
140 [ 'dropTable', 'transcache' ],
141 [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
142 [ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
143 [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
144 [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
145 [ 'migrateImageCommentTemp' ],
146
147 // 1.33
148 [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
149 [ 'dropTable', 'valid_tag' ],
150 [ 'dropTable', 'tag_summary' ],
151 [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
152 [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
153 [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
154 [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
155 [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
156 [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
157 [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
158 [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
159 [ 'modifyTable', 'job', 'patch-job-params-mediumblob.sql' ],
160
161 // 1.34
162 [ 'dropIndex', 'archive', 'ar_usertext_timestamp',
163 'patch-drop-archive-ar_usertext_timestamp.sql' ],
164 [ 'dropIndex', 'archive', 'usertext_timestamp', 'patch-drop-archive-usertext_timestamp.sql' ],
165 [ 'dropField', 'archive', 'ar_user', 'patch-drop-archive-user-fields.sql' ],
166 [ 'dropField', 'ipblocks', 'ip_by', 'patch-drop-ipblocks-user-fields.sql' ],
167 [ 'dropIndex', 'image', 'img_user_timestamp', 'patch-drop-image-img_user_timestamp.sql' ],
168 [ 'dropField', 'image', 'img_user', 'patch-drop-image-user-fields.sql' ],
169 [ 'dropField', 'oldimage', 'oi_user', 'patch-drop-oldimage-user-fields.sql' ],
170 [ 'dropField', 'filearchive', 'fa_user', 'patch-drop-filearchive-user-fields.sql' ],
171 [ 'dropField', 'recentchanges', 'rc_user', 'patch-drop-recentchanges-user-fields.sql' ],
172 [ 'dropField', 'logging', 'log_user', 'patch-drop-logging-user-fields.sql' ],
173 [ 'addIndex', 'user_newtalk', 'un_user_ip', 'patch-rename-mysql-user_newtalk-indexes.sql' ],
174
175 // 1.35
176 [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
177 [ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
178 [ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
179 'patch-ipblocks-rename-ipb_address.sql' ],
180 [ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
181 [ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
182 [ 'doLanguageLinksLengthSync' ],
183 [ 'doFixIpbAddressUniqueIndex' ],
184 [ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
185 [ 'modifyField', 'sites', 'site_global_key', 'patch-sites-site_global_key.sql' ],
186 [ 'modifyField', 'iwlinks', 'iwl_prefix', 'patch-extend-iwlinks-iwl_prefix.sql' ],
187
188 // 1.36
189 [ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
190 [ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
191 [ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
192 [ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
193 [ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
194 [ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
195 [ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
196 [ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
197 [ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
198 [ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
199 [ 'modifyField', 'user_newtalk', 'user_last_timestamp',
200 'patch-user_newtalk-user_last_timestamp-binary.sql'
201 ],
202 [ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
203 [ 'dropDefault', 'protected_titles', 'pt_expiry' ],
204 [ 'dropDefault', 'ip_changes', 'ipc_rev_timestamp' ],
205 [ 'dropDefault', 'revision_actor_temp', 'revactor_timestamp' ],
206 [ 'modifyField', 'ipblocks_restrictions', 'ir_type', 'patch-ipblocks_restrictions-ir_type.sql' ],
207 [ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
208 'patch-watchlist-namespace_title-rename-index.sql' ],
209 [ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
210 [ 'modifyField', 'job', 'job_timestamp', 'patch-job_job_timestamp.sql' ],
211 [ 'modifyField', 'job', 'job_token_timestamp', 'patch-job_job_token_timestamp.sql' ],
212 [ 'modifyField', 'watchlist', 'wl_notificationtimestamp', 'patch-watchlist-wl_notificationtimestamp.sql' ],
213 [ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id.sql' ],
214 [ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id.sql' ],
215 [ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
216 [ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
217 [ 'modifyField', 'uploadstash', 'us_timestamp', 'patch-uploadstash-us_timestamp.sql' ],
218 [ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
219 'patch-user_properties-rename-index.sql' ],
220 [ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
221 [ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
222 [ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
223 [ 'dropDefault', 'filearchive', 'fa_deleted_timestamp' ],
224 [ 'dropDefault', 'filearchive', 'fa_timestamp' ],
225 [ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
226 [ 'dropDefault', 'oldimage', 'oi_timestamp' ],
227 [ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
228 [ 'dropDefault', 'ipblocks', 'ipb_timestamp' ],
229 [ 'dropDefault', 'ipblocks', 'ipb_expiry' ],
230 [ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
231 'patch-archive-rename-name_title_timestamp-index.sql' ],
232 [ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
233 [ 'dropDefault', 'image', 'img_timestamp' ],
234 [ 'modifyField', 'image', 'img_timestamp', 'patch-image-img_timestamp.sql' ],
235 [ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
236 'patch-site_identifiers-rename-indexes.sql' ],
237 [ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
238 [ 'dropDefault', 'recentchanges', 'rc_timestamp' ],
239 [ 'modifyField', 'recentchanges', 'rc_timestamp', 'patch-recentchanges-rc_timestamp.sql' ],
240 [ 'modifyField', 'recentchanges', 'rc_id', 'patch-recentchanges-rc_id.sql' ],
241 [ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
242 'patch-recentchanges-rc_new_name_timestamp.sql' ],
243 [ 'dropDefault', 'archive', 'ar_timestamp' ],
244 [ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
245 [ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
246 [ 'dropDefault', 'page', 'page_touched' ],
247 [ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
248
249 // 1.37
250 [ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
251 'patch-revision-rename-index.sql' ],
252 [ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
253 [ 'dropDefault', 'revision', 'rev_timestamp' ],
254 [ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
255 [ 'renameIndex', 'page', 'name_title', 'page_name_title', false, 'patch-page-rename-name_title-index.sql' ],
256 [ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
257 'patch-change_tag-rename-indexes.sql' ],
258 ];
259 }
260
270 protected function checkBin( $table, $field, $patchFile ) {
271 if ( !$this->doTable( $table ) ) {
272 return true;
273 }
274
276 $fieldInfo = $this->db->fieldInfo( $table, $field );
277 if ( $fieldInfo->isBinary() ) {
278 $this->output( "...$table table has correct $field encoding.\n" );
279 } else {
280 $this->applyPatch( $patchFile, false, "Fixing $field encoding on $table table" );
281 }
282 }
283
292 protected function indexHasField( $table, $index, $field ) {
293 $info = $this->db->indexInfo( $table, $index, __METHOD__ );
294 if ( $info ) {
295 foreach ( $info as $row ) {
296 if ( $row->Column_name == $field ) {
297 $this->output( "...index $index on table $table includes field $field.\n" );
298 return true;
299 }
300 }
301 }
302 $this->output( "...index $index on table $table has no field $field; added.\n" );
303
304 return false;
305 }
306
307 protected function doNonUniquePlTlIl() {
308 $info = $this->db->indexInfo( 'pagelinks', 'pl_namespace', __METHOD__ );
309 if ( is_array( $info ) && $info[0]->Non_unique ) {
310 $this->output( "...pl_namespace, tl_namespace, il_to indices are already non-UNIQUE.\n" );
311
312 return true;
313 }
314 if ( $this->skipSchema ) {
315 $this->output( "...skipping schema change (making pl_namespace, tl_namespace " .
316 "and il_to indices non-UNIQUE).\n" );
317
318 return false;
319 }
320
321 return $this->applyPatch(
322 'patch-pl-tl-il-nonunique.sql',
323 false,
324 'Making pl_namespace, tl_namespace and il_to indices non-UNIQUE'
325 );
326 }
327
328 protected function doLanguageLinksLengthSync() {
329 $sync = [
330 [ 'table' => 'l10n_cache', 'field' => 'lc_lang', 'file' => 'patch-l10n_cache-lc_lang-35.sql' ],
331 [ 'table' => 'langlinks', 'field' => 'll_lang', 'file' => 'patch-langlinks-ll_lang-35.sql' ],
332 [ 'table' => 'sites', 'field' => 'site_language', 'file' => 'patch-sites-site_language-35.sql' ],
333 ];
334
335 foreach ( $sync as $s ) {
336 $table = $this->db->tableName( $s['table'] );
337 $field = $s['field'];
338 $res = $this->db->query( "SHOW COLUMNS FROM $table LIKE '$field'", __METHOD__ );
339 $row = $this->db->fetchObject( $res );
340
341 if ( $row && $row->Type !== "varbinary(35)" ) {
342 $this->applyPatch(
343 $s['file'],
344 false,
345 "Updating length of $field in $table"
346 );
347 } else {
348 $this->output( "...$field is up-to-date.\n" );
349 }
350 }
351 }
352
353 protected function doFixIpbAddressUniqueIndex() {
354 if ( !$this->doTable( 'ipblocks' ) ) {
355 return;
356 }
357
358 if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
359 $this->output( "...ipb_address_unique index up-to-date.\n" );
360 return;
361 }
362
363 $this->applyPatch(
364 'patch-ipblocks-fix-ipb_address_unique.sql',
365 false,
366 'Removing ipb_anon_only column from ipb_address_unique index'
367 );
368 }
369
370 protected function doUnsignedSyncronisation() {
371 $sync = [
372 [ 'table' => 'bot_passwords', 'field' => 'bp_user', 'file' => 'patch-bot_passwords-bp_user-unsigned.sql' ],
373 [ 'table' => 'change_tag', 'field' => 'ct_log_id', 'file' => 'patch-change_tag-ct_log_id-unsigned.sql' ],
374 [ 'table' => 'change_tag', 'field' => 'ct_rev_id', 'file' => 'patch-change_tag-ct_rev_id-unsigned.sql' ],
375 [ 'table' => 'page_restrictions', 'field' => 'pr_user',
376 'file' => 'patch-page_restrictions-pr_user-unsigned.sql' ],
377 [ 'table' => 'user_newtalk', 'field' => 'user_id', 'file' => 'patch-user_newtalk-user_id-unsigned.sql' ],
378 [ 'table' => 'user_properties', 'field' => 'up_user',
379 'file' => 'patch-user_properties-up_user-unsigned.sql' ],
380 [ 'table' => 'change_tag', 'field' => 'ct_rc_id', 'file' => 'patch-change_tag-ct_rc_id-unsigned.sql' ]
381 ];
382
383 foreach ( $sync as $s ) {
384 if ( !$this->doTable( $s['table'] ) ) {
385 continue;
386 }
387
388 $info = $this->db->fieldInfo( $s['table'], $s['field'] );
389 if ( $info === false ) {
390 continue;
391 }
392 $fullName = "{$s['table']}.{$s['field']}";
393 if ( $info->isUnsigned() ) {
394 $this->output( "...$fullName is already unsigned int.\n" );
395
396 continue;
397 }
398
399 $this->applyPatch(
400 $s['file'],
401 false,
402 "Making $fullName into an unsigned int"
403 );
404 }
405
406 return true;
407 }
408
409 protected function doRevisionPageRevIndexNonUnique() {
410 if ( !$this->doTable( 'revision' ) ) {
411 return true;
412 } elseif ( !$this->db->indexExists( 'revision', 'rev_page_id', __METHOD__ ) ) {
413 $this->output( "...rev_page_id index not found on revision.\n" );
414 return true;
415 }
416
417 if ( !$this->db->indexUnique( 'revision', 'rev_page_id', __METHOD__ ) ) {
418 $this->output( "...rev_page_id index already non-unique.\n" );
419 return true;
420 }
421
422 return $this->applyPatch(
423 'patch-revision-page-rev-index-nonunique.sql',
424 false,
425 'Making rev_page_id index non-unique'
426 );
427 }
428
429 public function getSchemaVars() {
430 global $wgDBTableOptions;
431
432 $vars = [];
433 $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $wgDBTableOptions );
434 $vars['wgDBTableOptions'] = str_replace(
435 'CHARSET=mysql4',
436 'CHARSET=binary',
437 $vars['wgDBTableOptions']
438 );
439
440 return $vars;
441 }
442
450 protected function dropDefault( $table, $field ) {
451 $updateKey = "$table-$field-dropDefault";
452
453 if ( $this->updateRowExists( $updateKey ) ) {
454 return;
455 }
456
457 $info = $this->db->fieldInfo( $table, $field );
458 if ( $info && $info->defaultValue() !== false ) {
459 $this->output( "Removing '$table.$field' default value.\n" );
460 $table = $this->db->tableName( $table );
461 $ret = $this->db->query( "ALTER TABLE $table ALTER COLUMN $field DROP DEFAULT", __METHOD__ );
462
463 if ( $ret ) {
464 $this->insertUpdateRow( $updateKey );
465 }
466 }
467 }
468
477 protected function setDefault( $table, $field, $default ) {
478 $info = $this->db->fieldInfo( $table, $field );
479 if ( $info && $info->defaultValue() !== $default ) {
480 $this->output( "Changing '$table.$field' default value.\n" );
481 $table = $this->db->tableName( $table );
482 $this->db->query(
483 "ALTER TABLE $table ALTER COLUMN $field SET DEFAULT "
484 . $this->db->addQuotes( $default ), __METHOD__
485 );
486 }
487 }
488
489}
$wgDBTableOptions
MySQL table options to use during installation or update.
Class for handling database updates.
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
output( $str)
Output some text.
insertUpdateRow( $key, $val=null)
Helper function: Add a key to the updatelog table.
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
doTable( $name)
Returns whether updates should be executed on the database table $name.
dropDefault( $table, $field)
Drop a default value from a field.
getSchemaVars()
Get appropriate schema variables in the current database connection.
setDefault( $table, $field, $default)
Set a default value for a field.
checkBin( $table, $field, $patchFile)
MW 1.4 betas were missing the 'binary' marker from logging.log_title, which caused a MySQL collation ...
getCoreUpdateList()
Get an array of updates to perform on the database.
doRevisionPageRevIndexNonUnique()
indexHasField( $table, $index, $field)
Check whether an index contain a field.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s