r31598 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31597‎ | r31598 | r31599 >
Date:22:16, 5 March 2008
Author:brion
Status:old (Comments)
Tags:
Comment:
Rearrange the updaters into chronological order, instead of four separate
groups by type with weird ordering within them.

This should make it a lot easier to avoid regressions due to unnoticed
dependencies, like the one we had in 1.11 which broke upgrades from 1.4 or
below, when someone didn't realize there was an ordering problem and moved
one of the updates for aesthetic grouping reasons. :) (r24608)

It also makes it easier to see when past updates were added, since they're
now grouped by version.

Extension updates are still using the 'add table', 'add field', 'add index'
grouping.

I also removed the special-case checks for whether to do updates to the user
table. This was presumably meant for shared-db situations to avoid running
updates multiple times, but there's no need for it as the updates all check
if they've been previously applied.
Modified paths:
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -16,78 +16,125 @@
1717 # Extension updates
1818 require_once( "$IP/includes/Hooks.php" );
1919
20 -$wgRenamedTables = array(
21 -# from to patch file
22 -# array( 'group', 'groups', 'patch-rename-group.sql' ),
 20+/**
 21+ * List of update functions to call on a MySQL-based MediaWiki installation,
 22+ * in sequence. First item is function name, rest are parameters to pass.
 23+ */
 24+$wgMysqlUpdates = array(
 25+ // 1.2
 26+ // update_passwords obsolete
 27+ array( 'add_field', 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
 28+ array( 'add_field', 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
 29+ array( 'do_interwiki_update' ),
 30+ array( 'do_index_update' ),
 31+ // do_linkscc_update obsolete
 32+ array( 'add_table', 'hitcounter', 'patch-hitcounter.sql' ),
 33+ array( 'add_field', 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
 34+
 35+ // 1.3
 36+ array( 'add_field', 'user', 'user_real_name', 'patch-user-realname.sql' ),
 37+ array( 'add_table', 'querycache', 'patch-querycache.sql' ),
 38+ array( 'add_table', 'objectcache', 'patch-objectcache.sql' ),
 39+ array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ),
 40+ // do_linkscc_1_3_update obsolete
 41+ array( 'do_old_links_update' ),
 42+ array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
 43+
 44+ // 1.4
 45+ array( 'do_image_name_unique_update' ),
 46+ array( 'add_field', 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
 47+ array( 'add_field', 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
 48+ array( 'add_table', 'logging', 'patch-logging.sql' ),
 49+ // do_user_rights_update obsolete
 50+ array( 'add_field', 'user', 'user_token', 'patch-user_token.sql' ),
 51+ // old, old_articleid, patch-remove-old-title-namespace.sql obsolete
 52+ // user_groups, patch-userlevels.sql obsolete
 53+ // do_group_update() obsolete
 54+ array( 'do_watchlist_update' ),
 55+ array( 'do_user_update' ),
 56+ // do_copy_newtalk_to_watchlist obsolete
 57+
 58+ // 1.5
 59+ array( 'do_schema_restructuring' ),
 60+ array( 'add_field', 'logging', 'log_params', 'patch-log_params.sql' ),
 61+ array( 'do_logging_encoding' ),
 62+ array( 'add_field', 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
 63+ array( 'add_field', 'page', 'page_len', 'patch-page_len.sql' ),
 64+ array( 'do_inverse_timestamp' ),
 65+ array( 'do_text_id' ),
 66+ array( 'add_field', 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
 67+ array( 'add_field', 'image', 'img_width', 'patch-img_width.sql' ),
 68+ array( 'add_field', 'image', 'img_metadata', 'patch-img_metadata.sql' ),
 69+ array( 'add_field', 'user', 'user_email_token', 'patch-user_email_token.sql' ),
 70+ array( 'add_field', 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ),
 71+ array( 'do_namespace_size' ),
 72+ array( 'add_field', 'image', 'img_media_type', 'patch-img_media_type.sql' ),
 73+ array( 'do_pagelinks_update' ),
 74+ array( 'do_drop_img_type' ),
 75+ array( 'do_user_unique_update' ),
 76+ array( 'do_user_groups_update' ),
 77+ array( 'add_field', 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ),
 78+ array( 'add_table', 'user_newtalk', 'patch-usernewtalk2.sql' ),
 79+ array( 'add_table', 'transcache', 'patch-transcache.sql' ),
 80+ array( 'add_field', 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ),
 81+ array( 'add_table', 'trackbacks', 'patch-trackbacks.sql' ),
 82+
 83+ // 1.6
 84+ array( 'do_watchlist_null' ),
 85+ // do_image_index_update obsolete
 86+ array( 'do_logging_timestamp_index' ),
 87+ array( 'add_field', 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ),
 88+ array( 'do_page_random_update' ),
 89+ array( 'add_field', 'user', 'user_registration','patch-user_registration.sql' ),
 90+ array( 'do_templatelinks_update' ),
 91+ array( 'add_table', 'externallinks', 'patch-externallinks.sql' ),
 92+ array( 'add_table', 'job', 'patch-job.sql' ),
 93+ array( 'add_field', 'site_stats', 'ss_images', 'patch-ss_images.sql' ),
 94+ array( 'add_table', 'langlinks', 'patch-langlinks.sql' ),
 95+ array( 'add_table', 'querycache_info', 'patch-querycacheinfo.sql' ),
 96+ array( 'add_table', 'filearchive', 'patch-filearchive.sql' ),
 97+ array( 'add_field', 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ),
 98+ array( 'do_rc_indices_update' ),
 99+
 100+ // 1.9
 101+ array( 'add_field', 'user', 'user_newpass_time', 'patch-user_newpass_time.sql' ),
 102+ array( 'add_table', 'redirect', 'patch-redirect.sql' ),
 103+ array( 'add_table', 'querycachetwo', 'patch-querycachetwo.sql' ),
 104+ array( 'add_field', 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ),
 105+ array( 'do_backlinking_indices_update' ),
 106+ array( 'add_field', 'recentchanges', 'rc_old_len', 'patch-rc_len.sql' ),
 107+ array( 'add_field', 'user', 'user_editcount', 'patch-user_editcount.sql' ),
 108+
 109+ // 1.10
 110+ array( 'do_restrictions_update' ),
 111+ array( 'add_field', 'logging', 'log_id', 'patch-log_id.sql' ),
 112+ array( 'add_field', 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ),
 113+ array( 'add_field', 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ),
 114+ array( 'add_field', 'revision', 'rev_len', 'patch-rev_len.sql' ),
 115+ array( 'add_field', 'recentchanges', 'rc_deleted', 'patch-rc_deleted.sql' ),
 116+ array( 'add_field', 'logging', 'log_deleted', 'patch-log_deleted.sql' ),
 117+ array( 'add_field', 'archive', 'ar_deleted', 'patch-ar_deleted.sql' ),
 118+ array( 'add_field', 'ipblocks', 'ipb_deleted', 'patch-ipb_deleted.sql' ),
 119+ array( 'add_field', 'filearchive', 'fa_deleted', 'patch-fa_deleted.sql' ),
 120+ array( 'add_field', 'archive', 'ar_len', 'patch-ar_len.sql' ),
 121+
 122+ // 1.11
 123+ array( 'add_field', 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ),
 124+ array( 'do_categorylinks_indices_update' ),
 125+ array( 'add_field', 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql'),
 126+ array( 'do_archive_user_index' ),
 127+ array( 'do_image_user_index' ),
 128+ array( 'do_oldimage_user_index' ),
 129+ array( 'add_field', 'archive', 'ar_page_id', 'patch-archive-page_id.sql'),
 130+ array( 'add_field', 'image', 'img_sha1', 'patch-img_sha1.sql' ),
 131+ array( 'add_table', 'protected_titles', 'patch-protected_titles.sql' ),
 132+
 133+ // 1.13
 134+ array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ),
 135+ array( 'add_table', 'page_props', 'patch-page_props.sql' ),
23136 );
24137
25 -$wgNewTables = array(
26 -# table patch file (in maintenance/archives)
27 - array( 'hitcounter', 'patch-hitcounter.sql' ),
28 - array( 'querycache', 'patch-querycache.sql' ),
29 - array( 'objectcache', 'patch-objectcache.sql' ),
30 - array( 'categorylinks', 'patch-categorylinks.sql' ),
31 - array( 'logging', 'patch-logging.sql' ),
32 - array( 'user_newtalk', 'patch-usernewtalk2.sql' ),
33 - array( 'transcache', 'patch-transcache.sql' ),
34 - array( 'trackbacks', 'patch-trackbacks.sql' ),
35 - array( 'externallinks', 'patch-externallinks.sql' ),
36 - array( 'job', 'patch-job.sql' ),
37 - array( 'langlinks', 'patch-langlinks.sql' ),
38 - array( 'querycache_info', 'patch-querycacheinfo.sql' ),
39 - array( 'filearchive', 'patch-filearchive.sql' ),
40 - array( 'querycachetwo', 'patch-querycachetwo.sql' ),
41 - array( 'redirect', 'patch-redirect.sql' ),
42 - array( 'protected_titles', 'patch-protected_titles.sql' ),
43 - array( 'page_props', 'patch-page_props.sql' ),
44 -);
45138
46 -$wgNewFields = array(
47 -# table field patch file (in maintenance/archives)
48 - array( 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
49 - array( 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
50 - array( 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
51 - array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
52 - array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
53 - array( 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
54 - array( 'recentchanges', 'rc_old_len', 'patch-rc_len.sql' ),
55 - array( 'user', 'user_real_name', 'patch-user-realname.sql' ),
56 - array( 'user', 'user_token', 'patch-user_token.sql' ),
57 - array( 'user', 'user_email_token', 'patch-user_email_token.sql' ),
58 - array( 'user', 'user_registration','patch-user_registration.sql' ),
59 - array( 'logging', 'log_params', 'patch-log_params.sql' ),
60 - array( 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
61 - array( 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ),
62 - array( 'page', 'page_len', 'patch-page_len.sql' ),
63 - array( 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
64 - array( 'image', 'img_width', 'patch-img_width.sql' ),
65 - array( 'image', 'img_metadata', 'patch-img_metadata.sql' ),
66 - array( 'image', 'img_media_type', 'patch-img_media_type.sql' ),
67 - array( 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ),
68 - array( 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ),
69 - array( 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ),
70 - array( 'site_stats', 'ss_images', 'patch-ss_images.sql' ),
71 - array( 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ),
72 - array( 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ),
73 - array( 'user', 'user_newpass_time','patch-user_newpass_time.sql' ),
74 - array( 'user', 'user_editcount', 'patch-user_editcount.sql' ),
75 - array( 'recentchanges', 'rc_deleted', 'patch-rc_deleted.sql' ),
76 - array( 'logging', 'log_id', 'patch-log_id.sql' ),
77 - array( 'logging', 'log_deleted', 'patch-log_deleted.sql' ),
78 - array( 'archive', 'ar_deleted', 'patch-ar_deleted.sql' ),
79 - array( 'ipblocks', 'ipb_deleted', 'patch-ipb_deleted.sql' ),
80 - array( 'filearchive', 'fa_deleted', 'patch-fa_deleted.sql' ),
81 - array( 'revision', 'rev_len', 'patch-rev_len.sql' ),
82 - array( 'archive', 'ar_len', 'patch-ar_len.sql' ),
83 - array( 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ),
84 - array( 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ),
85 - array( 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ),
86 - array( 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql'),
87 - array( 'archive', 'ar_page_id', 'patch-archive-page_id.sql'),
88 - array( 'image', 'img_sha1', 'patch-img_sha1.sql' ),
89 - array( 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ),
90 -);
91 -
92139 # For extensions only, should be populated via hooks
93140 # $wgDBtype should be checked to specifiy the proper file
94141 $wgExtNewTables = array(); // table, dir
@@ -946,26 +993,16 @@
947994 do_postgres_updates();
948995 return;
949996 }
950 -
951 - # Rename tables
952 - foreach ( $wgRenamedTables as $tableRecord ) {
953 - rename_table( $tableRecord[0], $tableRecord[1], $tableRecord[2] );
954 - }
955 -
956 - # Add missing tables
957 - foreach ( $wgNewTables as $tableRecord ) {
958 - add_table( $tableRecord[0], $tableRecord[1] );
 997+
 998+ # Run core updates in sequence...
 999+ global $wgMysqlUpdates;
 1000+ foreach( $wgMysqlUpdates as $params ) {
 1001+ $func = array_shift( $params );
 1002+ call_user_func_array( $func, $params );
9591003 flush();
9601004 }
961 -
962 - # Add missing fields
963 - foreach ( $wgNewFields as $fieldRecord ) {
964 - if ( $fieldRecord[0] != 'user' || $doUser ) {
965 - add_field( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2] );
966 - }
967 - flush();
968 - }
9691005
 1006+ /// @fixme clean up this mess too!
9701007 global $wgExtNewTables, $wgExtNewFields, $wgExtNewIndexes;
9711008 # Add missing extension tables
9721009 foreach ( $wgExtNewTables as $tableRecord ) {
@@ -985,55 +1022,7 @@
9861023 flush();
9871024 }
9881025
989 - # Do schema updates which require special handling
990 - do_interwiki_update(); flush();
991 - do_index_update(); flush();
992 - do_old_links_update(); flush();
993 - do_image_name_unique_update(); flush();
994 - do_watchlist_update(); flush();
995 - if ( $doUser ) {
996 - do_user_update(); flush();
997 - }
998 -###### do_copy_newtalk_to_watchlist(); flush();
999 - do_logging_encoding(); flush();
10001026
1001 - do_schema_restructuring(); flush();
1002 - do_inverse_timestamp(); flush();
1003 - do_text_id(); flush();
1004 - do_namespace_size(); flush();
1005 -
1006 - do_pagelinks_update(); flush();
1007 - do_templatelinks_update(); flush(); // after pagelinks
1008 -
1009 - do_drop_img_type(); flush();
1010 -
1011 - if ( $doUser ) {
1012 - do_user_unique_update(); flush();
1013 - }
1014 - do_user_groups_update(); flush();
1015 -
1016 - do_watchlist_null(); flush();
1017 -
1018 - //do_image_index_update(); flush();
1019 -
1020 - do_logging_timestamp_index(); flush();
1021 -
1022 - do_page_random_update(); flush();
1023 -
1024 - do_rc_indices_update(); flush();
1025 -
1026 - do_backlinking_indices_update(); flush();
1027 -
1028 - do_categorylinks_indices_update(); flush();
1029 -
1030 - do_restrictions_update(); flush ();
1031 -
1032 - do_archive_user_index(); flush ();
1033 -
1034 - do_image_user_index(); flush ();
1035 -
1036 - do_oldimage_user_index(); flush ();
1037 -
10381027 echo "Deleting old default messages (this may take a long time!)..."; flush();
10391028 deleteDefaultMessages();
10401029 echo "Done\n"; flush();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r24608* Move redirect table line up with the others...robchurch03:34, 6 August 2007

Comments

#Comment by 😂 (talk | contribs)   13:45, 21 July 2010

This needs to happen for PG as well. SQLite does it properly, Oracle doesn't have any updaters (but it's at least structured correctly). Postgres is still doing it the old way.

Status & tagging log