2010-07-08 14:57:19 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* MySQL-specific updater.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-08-21 18:20:09 +00:00
|
|
|
*/
|
2020-01-10 00:00:51 +00:00
|
|
|
use Wikimedia\Rdbms\MySQLField;
|
2010-07-20 11:35:38 +00:00
|
|
|
|
2010-07-08 14:57:19 +00:00
|
|
|
/**
|
2010-07-29 18:36:39 +00:00
|
|
|
* Mysql update list and mysql-specific update functions.
|
2010-12-16 11:20:39 +00:00
|
|
|
*
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-29 18:36:39 +00:00
|
|
|
* @since 1.17
|
2019-09-12 19:40:57 +00:00
|
|
|
* @property Wikimedia\Rdbms\DatabaseMysqlBase $db
|
2010-07-08 14:57:19 +00:00
|
|
|
*/
|
2010-07-20 22:28:50 +00:00
|
|
|
class MysqlUpdater extends DatabaseUpdater {
|
|
|
|
|
protected function getCoreUpdateList() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2016-11-18 19:54:28 +00:00
|
|
|
// 1.29
|
|
|
|
|
[ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
|
2017-02-01 14:57:09 +00:00
|
|
|
[ 'dropIndex', 'user_groups', 'ug_user_group', 'patch-user_groups-primary-key.sql' ],
|
User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.
When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.
Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.
NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.
The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.
The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.
There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
extension) has a change of parameter.
Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-12 06:07:56 +00:00
|
|
|
[ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
|
2019-11-21 20:47:13 +00:00
|
|
|
[ 'ifTableNotExists', 'actor',
|
|
|
|
|
'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
|
2017-07-20 14:43:50 +00:00
|
|
|
|
|
|
|
|
// 1.30
|
2017-02-07 18:19:10 +00:00
|
|
|
[ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
|
2017-08-09 21:34:09 +00:00
|
|
|
[ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
|
2017-08-04 12:43:50 +00:00
|
|
|
[ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
|
|
|
|
|
'patch-categorylinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
|
|
|
|
|
'patch-templatelinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
|
|
|
|
|
'patch-module_deps-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
|
|
|
|
|
'patch-querycache_info-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
|
|
|
|
|
'patch-user_former_groups-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
|
|
|
|
|
'patch-user_properties-fix-pk.sql' ],
|
2017-06-06 17:39:14 +00:00
|
|
|
[ 'addTable', 'comment', 'patch-comment-table.sql' ],
|
2019-08-15 13:36:53 +00:00
|
|
|
[ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
|
|
|
|
|
[ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
|
|
|
|
|
[ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
|
2019-09-27 16:22:11 +00:00
|
|
|
[ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
|
2019-08-15 13:36:53 +00:00
|
|
|
[ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
|
|
|
|
|
[ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
|
|
|
|
|
[ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
|
|
|
|
|
[ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
|
|
|
|
|
[ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
|
2020-11-02 08:58:42 +00:00
|
|
|
[ 'setDefault', 'revision', 'rev_comment', '' ],
|
2018-03-07 15:40:27 +00:00
|
|
|
|
|
|
|
|
// This field was added in 1.31, but is put here so it can be used by 'migrateComments'
|
|
|
|
|
[ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
|
|
|
|
|
|
2017-06-06 17:39:14 +00:00
|
|
|
[ 'migrateComments' ],
|
2016-10-28 14:33:32 +00:00
|
|
|
[ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
|
|
|
|
|
'patch-l10n_cache-primary-key.sql' ],
|
2017-04-26 16:08:51 +00:00
|
|
|
[ 'doUnsignedSyncronisation' ],
|
2017-09-18 15:00:26 +00:00
|
|
|
|
|
|
|
|
// 1.31
|
|
|
|
|
[ 'addTable', 'slots', 'patch-slots.sql' ],
|
2018-03-06 14:42:43 +00:00
|
|
|
[ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
|
2017-09-18 15:00:26 +00:00
|
|
|
[ 'addTable', 'content', 'patch-content.sql' ],
|
|
|
|
|
[ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
|
|
|
|
|
[ 'addTable', 'content_models', 'patch-content_models.sql' ],
|
2017-11-28 21:13:09 +00:00
|
|
|
[ 'migrateArchiveText' ],
|
2017-09-12 17:12:29 +00:00
|
|
|
[ 'addTable', 'actor', 'patch-actor-table.sql' ],
|
2019-09-28 14:48:19 +00:00
|
|
|
[ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
|
|
|
|
|
[ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
|
|
|
|
|
[ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
|
|
|
|
|
[ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
|
|
|
|
|
[ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
|
|
|
|
|
[ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
|
|
|
|
|
[ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
|
|
|
|
|
[ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
|
2017-09-12 17:12:29 +00:00
|
|
|
[ 'migrateActors' ],
|
2020-11-02 08:58:42 +00:00
|
|
|
|
|
|
|
|
// Adds a default value to the rev_text_id field to allow Multi Content
|
|
|
|
|
// Revisions migration to happen where rows will have to be added to the
|
|
|
|
|
// revision table with no rev_text_id.
|
|
|
|
|
[ 'setDefault', 'revision', 'rev_text_id', 0 ],
|
2017-05-08 19:31:54 +00:00
|
|
|
[ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
|
2018-01-04 19:35:13 +00:00
|
|
|
[ 'populateArchiveRevId' ],
|
2018-03-22 19:46:49 +00:00
|
|
|
[ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
|
|
|
|
|
'patch-recentchanges-nttindex.sql' ],
|
2018-05-04 17:29:53 +00:00
|
|
|
|
|
|
|
|
// 1.32
|
|
|
|
|
[ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
|
2016-11-18 20:42:11 +00:00
|
|
|
[ 'populateExternallinksIndex60' ],
|
2020-11-02 08:58:42 +00:00
|
|
|
[ 'dropDefault', 'externallinks', 'el_index_60' ],
|
2018-04-27 17:10:36 +00:00
|
|
|
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
|
2018-05-11 19:16:37 +00:00
|
|
|
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
|
2018-04-27 17:11:01 +00:00
|
|
|
[ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
|
2018-07-10 17:09:37 +00:00
|
|
|
[ 'populateContentTables' ],
|
2018-07-11 14:36:27 +00:00
|
|
|
[ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
|
|
|
|
|
[ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
|
2018-07-04 19:13:07 +00:00
|
|
|
[ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
|
|
|
|
|
'patch-page_props-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
|
|
|
|
|
'patch-protected_titles-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
|
|
|
|
|
'patch-site_identifiers-fix-pk.sql' ],
|
2018-08-02 19:12:07 +00:00
|
|
|
[ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
|
2018-08-28 17:44:03 +00:00
|
|
|
[ 'dropTable', 'transcache' ],
|
2018-08-28 21:32:55 +00:00
|
|
|
[ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
|
2020-12-21 04:09:08 +00:00
|
|
|
[ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
|
2018-06-18 14:26:20 +00:00
|
|
|
[ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
|
|
|
|
|
[ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
|
2018-03-07 16:40:56 +00:00
|
|
|
[ 'migrateImageCommentTemp' ],
|
2018-11-14 20:20:11 +00:00
|
|
|
|
2020-01-19 21:41:19 +00:00
|
|
|
// 1.33
|
2018-11-14 20:20:11 +00:00
|
|
|
[ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
|
2018-12-12 19:20:42 +00:00
|
|
|
[ 'dropTable', 'valid_tag' ],
|
|
|
|
|
[ 'dropTable', 'tag_summary' ],
|
2020-07-08 16:28:19 +00:00
|
|
|
[ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
|
|
|
|
|
[ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
|
|
|
|
|
[ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
|
|
|
|
|
[ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
|
|
|
|
|
[ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
|
2019-04-01 16:05:08 +00:00
|
|
|
[ 'modifyTable', 'job', 'patch-job-params-mediumblob.sql' ],
|
2019-07-23 17:40:52 +00:00
|
|
|
|
|
|
|
|
// 1.34
|
2019-09-18 15:32:13 +00:00
|
|
|
[ 'dropIndex', 'archive', 'ar_usertext_timestamp',
|
|
|
|
|
'patch-drop-archive-ar_usertext_timestamp.sql' ],
|
|
|
|
|
[ 'dropIndex', 'archive', 'usertext_timestamp', 'patch-drop-archive-usertext_timestamp.sql' ],
|
2020-07-08 13:39:56 +00:00
|
|
|
[ 'dropField', 'archive', 'ar_user', 'patch-drop-archive-user-fields.sql' ],
|
|
|
|
|
[ 'dropField', 'ipblocks', 'ip_by', 'patch-drop-ipblocks-user-fields.sql' ],
|
2020-12-07 03:19:38 +00:00
|
|
|
[ 'dropIndex', 'image', 'img_user_timestamp', 'patch-drop-image-img_user_timestamp.sql' ],
|
2020-07-08 13:39:56 +00:00
|
|
|
[ 'dropField', 'image', 'img_user', 'patch-drop-image-user-fields.sql' ],
|
|
|
|
|
[ 'dropField', 'oldimage', 'oi_user', 'patch-drop-oldimage-user-fields.sql' ],
|
|
|
|
|
[ 'dropField', 'filearchive', 'fa_user', 'patch-drop-filearchive-user-fields.sql' ],
|
|
|
|
|
[ 'dropField', 'recentchanges', 'rc_user', 'patch-drop-recentchanges-user-fields.sql' ],
|
|
|
|
|
[ 'dropField', 'logging', 'log_user', 'patch-drop-logging-user-fields.sql' ],
|
2019-09-18 16:44:15 +00:00
|
|
|
[ 'addIndex', 'user_newtalk', 'un_user_ip', 'patch-rename-mysql-user_newtalk-indexes.sql' ],
|
2020-02-07 19:15:46 +00:00
|
|
|
|
|
|
|
|
// 1.35
|
|
|
|
|
[ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
|
2020-03-18 23:33:48 +00:00
|
|
|
[ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
|
2020-04-21 21:51:33 +00:00
|
|
|
[ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
|
|
|
|
|
'patch-ipblocks-rename-ipb_address.sql' ],
|
2019-11-21 20:47:13 +00:00
|
|
|
[ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
|
|
|
|
|
[ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
|
2020-05-21 01:25:17 +00:00
|
|
|
[ 'doLanguageLinksLengthSync' ],
|
2020-05-04 20:16:03 +00:00
|
|
|
[ 'doFixIpbAddressUniqueIndex' ],
|
2020-08-09 19:05:37 +00:00
|
|
|
[ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
|
2020-08-15 00:50:33 +00:00
|
|
|
[ 'modifyField', 'sites', 'site_global_key', 'patch-sites-site_global_key.sql' ],
|
2021-02-27 21:35:59 +00:00
|
|
|
[ 'modifyField', 'iwlinks', 'iwl_prefix', 'patch-extend-iwlinks-iwl_prefix.sql' ],
|
2020-08-25 15:29:14 +00:00
|
|
|
|
|
|
|
|
// 1.36
|
2020-08-09 19:05:37 +00:00
|
|
|
[ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
|
2020-08-15 19:01:57 +00:00
|
|
|
[ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
|
2020-08-22 12:57:42 +00:00
|
|
|
[ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
|
2020-08-22 20:51:25 +00:00
|
|
|
[ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
|
2020-08-29 17:00:04 +00:00
|
|
|
[ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
|
2020-08-29 17:25:15 +00:00
|
|
|
[ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
|
2020-09-05 18:33:21 +00:00
|
|
|
[ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
|
2020-09-26 13:39:59 +00:00
|
|
|
[ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
|
2020-09-26 14:39:53 +00:00
|
|
|
[ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
|
2020-10-18 09:43:04 +00:00
|
|
|
[ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
|
2020-10-22 15:10:46 +00:00
|
|
|
[ 'modifyField', 'user_newtalk', 'user_last_timestamp',
|
|
|
|
|
'patch-user_newtalk-user_last_timestamp-binary.sql'
|
|
|
|
|
],
|
2020-10-27 05:55:50 +00:00
|
|
|
[ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
|
2020-11-12 04:23:20 +00:00
|
|
|
[ 'dropDefault', 'protected_titles', 'pt_expiry' ],
|
|
|
|
|
[ 'dropDefault', 'ip_changes', 'ipc_rev_timestamp' ],
|
|
|
|
|
[ 'dropDefault', 'revision_actor_temp', 'revactor_timestamp' ],
|
2020-11-16 13:58:29 +00:00
|
|
|
[ 'modifyField', 'ipblocks_restrictions', 'ir_type', 'patch-ipblocks_restrictions-ir_type.sql' ],
|
2020-11-16 14:24:24 +00:00
|
|
|
[ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
|
|
|
|
|
'patch-watchlist-namespace_title-rename-index.sql' ],
|
2020-11-18 05:50:39 +00:00
|
|
|
[ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
|
|
|
|
|
[ 'modifyField', 'job', 'job_timestamp', 'patch-job_job_timestamp.sql' ],
|
|
|
|
|
[ 'modifyField', 'job', 'job_token_timestamp', 'patch-job_job_token_timestamp.sql' ],
|
2020-11-21 22:47:34 +00:00
|
|
|
[ 'modifyField', 'watchlist', 'wl_notificationtimestamp', 'patch-watchlist-wl_notificationtimestamp.sql' ],
|
2020-08-09 15:45:51 +00:00
|
|
|
[ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id.sql' ],
|
|
|
|
|
[ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id.sql' ],
|
2020-11-28 11:16:20 +00:00
|
|
|
[ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
|
2020-12-06 00:12:01 +00:00
|
|
|
[ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
|
2020-12-13 17:45:53 +00:00
|
|
|
[ 'modifyField', 'uploadstash', 'us_timestamp', 'patch-uploadstash-us_timestamp.sql' ],
|
2020-12-14 16:37:53 +00:00
|
|
|
[ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
|
|
|
|
|
'patch-user_properties-rename-index.sql' ],
|
2020-12-15 04:16:54 +00:00
|
|
|
[ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
|
2020-12-13 01:52:49 +00:00
|
|
|
[ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
|
2020-12-20 21:42:14 +00:00
|
|
|
[ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
|
|
|
|
|
[ 'dropDefault', 'filearchive', 'fa_deleted_timestamp' ],
|
|
|
|
|
[ 'dropDefault', 'filearchive', 'fa_timestamp' ],
|
2021-01-16 19:42:23 +00:00
|
|
|
[ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
|
|
|
|
|
[ 'dropDefault', 'oldimage', 'oi_timestamp' ],
|
2020-10-23 13:11:39 +00:00
|
|
|
[ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
|
2021-01-23 05:02:25 +00:00
|
|
|
[ 'dropDefault', 'ipblocks', 'ipb_timestamp' ],
|
|
|
|
|
[ 'dropDefault', 'ipblocks', 'ipb_expiry' ],
|
2021-01-23 09:00:00 +00:00
|
|
|
[ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
|
|
|
|
|
'patch-archive-rename-name_title_timestamp-index.sql' ],
|
2021-01-28 19:13:03 +00:00
|
|
|
[ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
|
|
|
|
|
[ 'dropDefault', 'image', 'img_timestamp' ],
|
2021-03-04 20:18:21 +00:00
|
|
|
[ 'modifyField', 'image', 'img_timestamp', 'patch-image-img_timestamp.sql' ],
|
2020-12-21 12:52:44 +00:00
|
|
|
[ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
|
|
|
|
|
'patch-site_identifiers-rename-indexes.sql' ],
|
2021-02-26 12:52:22 +00:00
|
|
|
[ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
|
|
|
|
|
[ 'dropDefault', 'recentchanges', 'rc_timestamp' ],
|
|
|
|
|
[ 'modifyField', 'recentchanges', 'rc_timestamp', 'patch-recentchanges-rc_timestamp.sql' ],
|
2021-02-27 18:24:25 +00:00
|
|
|
[ 'modifyField', 'recentchanges', 'rc_id', 'patch-recentchanges-rc_id.sql' ],
|
2021-02-27 18:37:49 +00:00
|
|
|
[ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
|
|
|
|
|
'patch-recentchanges-rc_new_name_timestamp.sql' ],
|
2021-03-13 19:49:25 +00:00
|
|
|
[ 'dropDefault', 'archive', 'ar_timestamp' ],
|
|
|
|
|
[ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
|
2020-11-23 04:33:36 +00:00
|
|
|
[ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
|
|
|
|
|
[ 'dropDefault', 'page', 'page_touched' ],
|
2021-03-27 09:28:18 +00:00
|
|
|
[ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
|
2021-03-22 14:42:19 +00:00
|
|
|
|
|
|
|
|
// 1.37
|
|
|
|
|
[ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
|
|
|
|
|
'patch-revision-rename-index.sql' ],
|
2021-02-24 15:44:24 +00:00
|
|
|
[ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
|
2021-03-21 15:32:35 +00:00
|
|
|
[ 'dropDefault', 'revision', 'rev_timestamp' ],
|
2021-04-24 10:42:10 +00:00
|
|
|
[ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
|
2021-03-24 18:23:09 +00:00
|
|
|
[ 'renameIndex', 'page', 'name_title', 'page_name_title', false, 'patch-page-rename-name_title-index.sql' ],
|
2020-12-21 04:09:08 +00:00
|
|
|
[ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
|
|
|
|
|
'patch-change_tag-rename-indexes.sql' ],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-07-08 14:57:19 +00:00
|
|
|
}
|
2010-08-17 13:36:59 +00:00
|
|
|
|
2010-09-12 16:24:03 +00:00
|
|
|
/**
|
2021-01-30 22:06:09 +00:00
|
|
|
* MW 1.4 betas were missing the 'binary' marker from logging.log_title,
|
|
|
|
|
* which caused a MySQL collation mismatch error.
|
2010-09-12 16:24:03 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $table Table name
|
|
|
|
|
* @param string $field Field name to check
|
|
|
|
|
* @param string $patchFile Path to the patch to correct the field
|
|
|
|
|
* @return bool
|
2010-09-12 16:24:03 +00:00
|
|
|
*/
|
|
|
|
|
protected function checkBin( $table, $field, $patchFile ) {
|
2012-12-27 17:37:40 +00:00
|
|
|
if ( !$this->doTable( $table ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:42:34 +00:00
|
|
|
/** @var MySQLField $fieldInfo */
|
2013-10-17 00:03:01 +00:00
|
|
|
$fieldInfo = $this->db->fieldInfo( $table, $field );
|
|
|
|
|
if ( $fieldInfo->isBinary() ) {
|
2010-10-01 15:11:06 +00:00
|
|
|
$this->output( "...$table table has correct $field encoding.\n" );
|
2010-09-12 16:24:03 +00:00
|
|
|
} else {
|
2012-08-29 08:07:10 +00:00
|
|
|
$this->applyPatch( $patchFile, false, "Fixing $field encoding on $table table" );
|
2010-09-12 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether an index contain a field
|
|
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $table Table name
|
|
|
|
|
* @param string $index Index name to check
|
|
|
|
|
* @param string $field Field that should be in the index
|
|
|
|
|
* @return bool
|
2010-09-12 16:24:03 +00:00
|
|
|
*/
|
|
|
|
|
protected function indexHasField( $table, $index, $field ) {
|
|
|
|
|
$info = $this->db->indexInfo( $table, $index, __METHOD__ );
|
|
|
|
|
if ( $info ) {
|
|
|
|
|
foreach ( $info as $row ) {
|
|
|
|
|
if ( $row->Column_name == $field ) {
|
2011-11-19 17:39:56 +00:00
|
|
|
$this->output( "...index $index on table $table includes field $field.\n" );
|
2010-09-12 16:24:03 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-19 17:39:56 +00:00
|
|
|
$this->output( "...index $index on table $table has no field $field; added.\n" );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-09-12 16:24:03 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-21 01:25:17 +00:00
|
|
|
protected function doLanguageLinksLengthSync() {
|
|
|
|
|
$sync = [
|
2021-02-13 20:41:47 +00:00
|
|
|
[ 'table' => 'l10n_cache', 'field' => 'lc_lang', 'file' => 'patch-l10n_cache-lc_lang-35.sql' ],
|
|
|
|
|
[ 'table' => 'langlinks', 'field' => 'll_lang', 'file' => 'patch-langlinks-ll_lang-35.sql' ],
|
|
|
|
|
[ 'table' => 'sites', 'field' => 'site_language', 'file' => 'patch-sites-site_language-35.sql' ],
|
2020-05-21 01:25:17 +00:00
|
|
|
];
|
2011-02-01 18:58:32 +00:00
|
|
|
|
2020-05-21 01:25:17 +00:00
|
|
|
foreach ( $sync as $s ) {
|
|
|
|
|
$table = $this->db->tableName( $s['table'] );
|
|
|
|
|
$field = $s['field'];
|
2020-06-07 19:06:40 +00:00
|
|
|
$res = $this->db->query( "SHOW COLUMNS FROM $table LIKE '$field'", __METHOD__ );
|
2020-05-21 01:25:17 +00:00
|
|
|
$row = $this->db->fetchObject( $res );
|
|
|
|
|
|
|
|
|
|
if ( $row && $row->Type !== "varbinary(35)" ) {
|
|
|
|
|
$this->applyPatch(
|
2021-02-13 20:41:47 +00:00
|
|
|
$s['file'],
|
2020-05-21 01:25:17 +00:00
|
|
|
false,
|
|
|
|
|
"Updating length of $field in $table"
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( "...$field is up-to-date.\n" );
|
|
|
|
|
}
|
2011-02-01 18:58:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-17 17:35:52 +00:00
|
|
|
|
2020-05-04 20:16:03 +00:00
|
|
|
protected function doFixIpbAddressUniqueIndex() {
|
2020-10-07 15:54:45 +00:00
|
|
|
if ( !$this->doTable( 'ipblocks' ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 20:16:03 +00:00
|
|
|
if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
|
|
|
|
|
$this->output( "...ipb_address_unique index up-to-date.\n" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->applyPatch(
|
|
|
|
|
'patch-ipblocks-fix-ipb_address_unique.sql',
|
|
|
|
|
false,
|
|
|
|
|
'Removing ipb_anon_only column from ipb_address_unique index'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-26 16:08:51 +00:00
|
|
|
protected function doUnsignedSyncronisation() {
|
|
|
|
|
$sync = [
|
2021-02-13 21:49:27 +00:00
|
|
|
[ 'table' => 'bot_passwords', 'field' => 'bp_user', 'file' => 'patch-bot_passwords-bp_user-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'change_tag', 'field' => 'ct_log_id', 'file' => 'patch-change_tag-ct_log_id-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'change_tag', 'field' => 'ct_rev_id', 'file' => 'patch-change_tag-ct_rev_id-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'page_restrictions', 'field' => 'pr_user',
|
|
|
|
|
'file' => 'patch-page_restrictions-pr_user-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'user_newtalk', 'field' => 'user_id', 'file' => 'patch-user_newtalk-user_id-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'user_properties', 'field' => 'up_user',
|
|
|
|
|
'file' => 'patch-user_properties-up_user-unsigned.sql' ],
|
|
|
|
|
[ 'table' => 'change_tag', 'field' => 'ct_rc_id', 'file' => 'patch-change_tag-ct_rc_id-unsigned.sql' ]
|
2017-04-26 16:08:51 +00:00
|
|
|
];
|
2015-02-15 18:29:38 +00:00
|
|
|
|
2017-04-26 16:08:51 +00:00
|
|
|
foreach ( $sync as $s ) {
|
|
|
|
|
if ( !$this->doTable( $s['table'] ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2015-02-15 18:29:38 +00:00
|
|
|
|
2017-04-26 16:08:51 +00:00
|
|
|
$info = $this->db->fieldInfo( $s['table'], $s['field'] );
|
|
|
|
|
if ( $info === false ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$fullName = "{$s['table']}.{$s['field']}";
|
|
|
|
|
if ( $info->isUnsigned() ) {
|
|
|
|
|
$this->output( "...$fullName is already unsigned int.\n" );
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->applyPatch(
|
2021-02-13 21:49:27 +00:00
|
|
|
$s['file'],
|
2017-04-26 16:08:51 +00:00
|
|
|
false,
|
|
|
|
|
"Making $fullName into an unsigned int"
|
|
|
|
|
);
|
2015-02-15 18:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
2017-04-26 16:08:51 +00:00
|
|
|
return true;
|
2015-02-15 18:29:38 +00:00
|
|
|
}
|
2016-04-11 21:01:43 +00:00
|
|
|
|
2016-09-21 20:39:00 +00:00
|
|
|
public function getSchemaVars() {
|
|
|
|
|
global $wgDBTableOptions;
|
|
|
|
|
|
|
|
|
|
$vars = [];
|
|
|
|
|
$vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $wgDBTableOptions );
|
|
|
|
|
$vars['wgDBTableOptions'] = str_replace(
|
|
|
|
|
'CHARSET=mysql4',
|
|
|
|
|
'CHARSET=binary',
|
|
|
|
|
$vars['wgDBTableOptions']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $vars;
|
|
|
|
|
}
|
2020-11-02 08:58:42 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Drop a default value from a field
|
|
|
|
|
*
|
|
|
|
|
* @since 1.36
|
|
|
|
|
* @param string $table
|
|
|
|
|
* @param string $field
|
|
|
|
|
*/
|
|
|
|
|
protected function dropDefault( $table, $field ) {
|
2021-09-22 15:45:33 +00:00
|
|
|
$updateKey = "$table-$field-dropDefault";
|
|
|
|
|
|
|
|
|
|
if ( $this->updateRowExists( $updateKey ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 08:58:42 +00:00
|
|
|
$info = $this->db->fieldInfo( $table, $field );
|
|
|
|
|
if ( $info && $info->defaultValue() !== false ) {
|
2021-09-22 15:45:33 +00:00
|
|
|
$this->output( "Removing '$table.$field' default value.\n" );
|
2020-11-11 16:20:35 +00:00
|
|
|
$table = $this->db->tableName( $table );
|
2021-09-22 15:45:33 +00:00
|
|
|
$ret = $this->db->query( "ALTER TABLE $table ALTER COLUMN $field DROP DEFAULT", __METHOD__ );
|
|
|
|
|
|
|
|
|
|
if ( $ret ) {
|
|
|
|
|
$this->insertUpdateRow( $updateKey );
|
|
|
|
|
}
|
2020-11-02 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set a default value for a field
|
|
|
|
|
*
|
|
|
|
|
* @since 1.36
|
|
|
|
|
* @param string $table
|
|
|
|
|
* @param string $field
|
|
|
|
|
* @param mixed $default
|
|
|
|
|
*/
|
|
|
|
|
protected function setDefault( $table, $field, $default ) {
|
|
|
|
|
$info = $this->db->fieldInfo( $table, $field );
|
|
|
|
|
if ( $info && $info->defaultValue() !== $default ) {
|
2021-09-22 15:45:33 +00:00
|
|
|
$this->output( "Changing '$table.$field' default value.\n" );
|
2020-11-11 16:20:35 +00:00
|
|
|
$table = $this->db->tableName( $table );
|
2020-11-02 08:58:42 +00:00
|
|
|
$this->db->query(
|
|
|
|
|
"ALTER TABLE $table ALTER COLUMN $field SET DEFAULT "
|
|
|
|
|
. $this->db->addQuotes( $default ), __METHOD__
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 14:57:19 +00:00
|
|
|
}
|