Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -43,21 +43,6 @@ |
44 | 44 | return (bool)$row; |
45 | 45 | } |
46 | 46 | |
47 | | -function add_table( $name, $patch, $fullpath = false ) { |
48 | | - global $wgDatabase; |
49 | | - if ( $wgDatabase->tableExists( $name ) ) { |
50 | | - wfOut( "...$name table already exists.\n" ); |
51 | | - } else { |
52 | | - wfOut( "Creating $name table..." ); |
53 | | - if ( $fullpath ) { |
54 | | - $wgDatabase->sourceFile( $patch ); |
55 | | - } else { |
56 | | - $wgDatabase->sourceFile( archive( $patch ) ); |
57 | | - } |
58 | | - wfOut( "ok\n" ); |
59 | | - } |
60 | | -} |
61 | | - |
62 | 47 | function modify_field( $table, $field, $patch, $fullpath = false ) { |
63 | 48 | global $wgDatabase; |
64 | 49 | if ( !$wgDatabase->tableExists( $table ) ) { |
— | — | @@ -508,43 +493,6 @@ |
509 | 494 | } |
510 | 495 | } |
511 | 496 | |
512 | | -function do_namespace_size() { |
513 | | - $tables = array( |
514 | | - 'page' => 'page', |
515 | | - 'archive' => 'ar', |
516 | | - 'recentchanges' => 'rc', |
517 | | - 'watchlist' => 'wl', |
518 | | - 'querycache' => 'qc', |
519 | | - 'logging' => 'log', |
520 | | - ); |
521 | | - foreach ( $tables as $table => $prefix ) { |
522 | | - do_namespace_size_on( $table, $prefix ); |
523 | | - flush(); |
524 | | - } |
525 | | -} |
526 | | - |
527 | | -function do_namespace_size_on( $table, $prefix ) { |
528 | | - global $wgDatabase, $wgDBtype; |
529 | | - if ( $wgDBtype != 'mysql' ) |
530 | | - return; |
531 | | - $field = $prefix . '_namespace'; |
532 | | - |
533 | | - $tablename = $wgDatabase->tableName( $table ); |
534 | | - $result = $wgDatabase->query( "SHOW COLUMNS FROM $tablename LIKE '$field'" ); |
535 | | - $info = $wgDatabase->fetchObject( $result ); |
536 | | - |
537 | | - if ( substr( $info->Type, 0, 3 ) == 'int' ) { |
538 | | - wfOut( "...$field is already a full int ($info->Type).\n" ); |
539 | | - } else { |
540 | | - wfOut( "Promoting $field from $info->Type to int... " ); |
541 | | - |
542 | | - $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
543 | | - $wgDatabase->query( $sql ); |
544 | | - |
545 | | - wfOut( "ok\n" ); |
546 | | - } |
547 | | -} |
548 | | - |
549 | 497 | function do_pagelinks_update() { |
550 | 498 | global $wgDatabase; |
551 | 499 | if ( $wgDatabase->tableExists( 'pagelinks' ) ) { |
Index: trunk/phase3/includes/installer/DatabaseUpdater.php |
— | — | @@ -52,6 +52,9 @@ |
53 | 53 | $this->getOldGlobalUpdates() ); |
54 | 54 | foreach ( $this->updates as $params ) { |
55 | 55 | $func = array_shift( $params ); |
| 56 | + if( method_exists( $this, $func ) ) { |
| 57 | + $func = array( $this, $func ); |
| 58 | + } |
56 | 59 | call_user_func_array( $func, $params ); |
57 | 60 | flush(); |
58 | 61 | } |
— | — | @@ -107,7 +110,7 @@ |
108 | 111 | |
109 | 112 | foreach ( $wgExtNewTables as $tableRecord ) { |
110 | 113 | $updates[] = array( |
111 | | - 'add_table', $tableRecord[0], $tableRecord[1], true |
| 114 | + 'addTable', $tableRecord[0], $tableRecord[1], true |
112 | 115 | ); |
113 | 116 | } |
114 | 117 | |
— | — | @@ -146,6 +149,26 @@ |
147 | 150 | * @return Array |
148 | 151 | */ |
149 | 152 | protected abstract function getCoreUpdateList(); |
| 153 | + |
| 154 | + /** |
| 155 | + * Add a new table to the database |
| 156 | + * @param $name String Name of the new table |
| 157 | + * @param $patch String Path to the patch file |
| 158 | + * @param $fullpath Boolean Whether to treat $fullPath as a relative or not |
| 159 | + */ |
| 160 | + protected function addTable( $name, $patch, $fullpath = false ) { |
| 161 | + if ( $this->db->tableExists( $name ) ) { |
| 162 | + wfOut( "...$name table already exists.\n" ); |
| 163 | + } else { |
| 164 | + wfOut( "Creating $name table..." ); |
| 165 | + if ( $fullpath ) { |
| 166 | + $this->db->sourceFile( $patch ); |
| 167 | + } else { |
| 168 | + $this->db->sourceFile( archive( $patch ) ); |
| 169 | + } |
| 170 | + wfOut( "ok\n" ); |
| 171 | + } |
| 172 | + } |
150 | 173 | } |
151 | 174 | |
152 | 175 | class OracleUpdater extends DatabaseUpdater { |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -15,14 +15,14 @@ |
16 | 16 | array( 'add_field', 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ), |
17 | 17 | array( 'do_interwiki_update' ), |
18 | 18 | array( 'do_index_update' ), |
19 | | - array( 'add_table', 'hitcounter', 'patch-hitcounter.sql' ), |
| 19 | + array( 'addTable', 'hitcounter', 'patch-hitcounter.sql' ), |
20 | 20 | array( 'add_field', 'recentchanges', 'rc_type', 'patch-rc_type.sql' ), |
21 | 21 | |
22 | 22 | // 1.3 |
23 | 23 | array( 'add_field', 'user', 'user_real_name', 'patch-user-realname.sql' ), |
24 | | - array( 'add_table', 'querycache', 'patch-querycache.sql' ), |
25 | | - array( 'add_table', 'objectcache', 'patch-objectcache.sql' ), |
26 | | - array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ), |
| 24 | + array( 'addTable', 'querycache', 'patch-querycache.sql' ), |
| 25 | + array( 'addTable', 'objectcache', 'patch-objectcache.sql' ), |
| 26 | + array( 'addTable', 'categorylinks', 'patch-categorylinks.sql' ), |
27 | 27 | array( 'do_old_links_update' ), |
28 | 28 | array( 'fix_ancient_imagelinks' ), |
29 | 29 | array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ), |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | array( 'do_image_name_unique_update' ), |
33 | 33 | array( 'add_field', 'recentchanges', 'rc_id', 'patch-rc_id.sql' ), |
34 | 34 | array( 'add_field', 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ), |
35 | | - array( 'add_table', 'logging', 'patch-logging.sql' ), |
| 35 | + array( 'addTable', 'logging', 'patch-logging.sql' ), |
36 | 36 | array( 'add_field', 'user', 'user_token', 'patch-user_token.sql' ), |
37 | 37 | array( 'do_watchlist_update' ), |
38 | 38 | array( 'do_user_update' ), |
— | — | @@ -49,17 +49,17 @@ |
50 | 50 | array( 'add_field', 'image', 'img_metadata', 'patch-img_metadata.sql' ), |
51 | 51 | array( 'add_field', 'user', 'user_email_token', 'patch-user_email_token.sql' ), |
52 | 52 | array( 'add_field', 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ), |
53 | | - array( 'do_namespace_size' ), |
| 53 | + array( 'doNamespaceSize' ), |
54 | 54 | array( 'add_field', 'image', 'img_media_type', 'patch-img_media_type.sql' ), |
55 | 55 | array( 'do_pagelinks_update' ), |
56 | 56 | array( 'do_drop_img_type' ), |
57 | 57 | array( 'do_user_unique_update' ), |
58 | 58 | array( 'do_user_groups_update' ), |
59 | 59 | array( 'add_field', 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ), |
60 | | - array( 'add_table', 'user_newtalk', 'patch-usernewtalk2.sql' ), |
61 | | - array( 'add_table', 'transcache', 'patch-transcache.sql' ), |
| 60 | + array( 'addTable', 'user_newtalk', 'patch-usernewtalk2.sql' ), |
| 61 | + array( 'addTable', 'transcache', 'patch-transcache.sql' ), |
62 | 62 | array( 'add_field', 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ), |
63 | | - array( 'add_table', 'trackbacks', 'patch-trackbacks.sql' ), |
| 63 | + array( 'addTable', 'trackbacks', 'patch-trackbacks.sql' ), |
64 | 64 | |
65 | 65 | // 1.6 |
66 | 66 | array( 'do_watchlist_null' ), |
— | — | @@ -68,19 +68,19 @@ |
69 | 69 | array( 'do_page_random_update' ), |
70 | 70 | array( 'add_field', 'user', 'user_registration', 'patch-user_registration.sql' ), |
71 | 71 | array( 'do_templatelinks_update' ), |
72 | | - array( 'add_table', 'externallinks', 'patch-externallinks.sql' ), |
73 | | - array( 'add_table', 'job', 'patch-job.sql' ), |
| 72 | + array( 'addTable', 'externallinks', 'patch-externallinks.sql' ), |
| 73 | + array( 'addTable', 'job', 'patch-job.sql' ), |
74 | 74 | array( 'add_field', 'site_stats', 'ss_images', 'patch-ss_images.sql' ), |
75 | | - array( 'add_table', 'langlinks', 'patch-langlinks.sql' ), |
76 | | - array( 'add_table', 'querycache_info', 'patch-querycacheinfo.sql' ), |
77 | | - array( 'add_table', 'filearchive', 'patch-filearchive.sql' ), |
| 75 | + array( 'addTable', 'langlinks', 'patch-langlinks.sql' ), |
| 76 | + array( 'addTable', 'querycache_info', 'patch-querycacheinfo.sql' ), |
| 77 | + array( 'addTable', 'filearchive', 'patch-filearchive.sql' ), |
78 | 78 | array( 'add_field', 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ), |
79 | 79 | array( 'do_rc_indices_update' ), |
80 | 80 | |
81 | 81 | // 1.9 |
82 | 82 | array( 'add_field', 'user', 'user_newpass_time', 'patch-user_newpass_time.sql' ), |
83 | | - array( 'add_table', 'redirect', 'patch-redirect.sql' ), |
84 | | - array( 'add_table', 'querycachetwo', 'patch-querycachetwo.sql' ), |
| 83 | + array( 'addTable', 'redirect', 'patch-redirect.sql' ), |
| 84 | + array( 'addTable', 'querycachetwo', 'patch-querycachetwo.sql' ), |
85 | 85 | array( 'add_field', 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ), |
86 | 86 | array( 'do_backlinking_indices_update' ), |
87 | 87 | array( 'add_field', 'recentchanges', 'rc_old_len', 'patch-rc_len.sql' ), |
— | — | @@ -110,13 +110,13 @@ |
111 | 111 | array( 'add_field', 'image', 'img_sha1', 'patch-img_sha1.sql' ), |
112 | 112 | |
113 | 113 | // 1.12 |
114 | | - array( 'add_table', 'protected_titles', 'patch-protected_titles.sql' ), |
| 114 | + array( 'addTable', 'protected_titles', 'patch-protected_titles.sql' ), |
115 | 115 | |
116 | 116 | // 1.13 |
117 | 117 | array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ), |
118 | | - array( 'add_table', 'page_props', 'patch-page_props.sql' ), |
119 | | - array( 'add_table', 'updatelog', 'patch-updatelog.sql' ), |
120 | | - array( 'add_table', 'category', 'patch-category.sql' ), |
| 118 | + array( 'addTable', 'page_props', 'patch-page_props.sql' ), |
| 119 | + array( 'addTable', 'updatelog', 'patch-updatelog.sql' ), |
| 120 | + array( 'addTable', 'category', 'patch-category.sql' ), |
121 | 121 | array( 'do_category_population' ), |
122 | 122 | array( 'add_field', 'archive', 'ar_parent_id', 'patch-ar_parent_id.sql' ), |
123 | 123 | array( 'add_field', 'user_newtalk', 'user_last_timestamp', 'patch-user_last_timestamp.sql' ), |
— | — | @@ -132,17 +132,17 @@ |
133 | 133 | |
134 | 134 | // 1.15 |
135 | 135 | array( 'do_unique_pl_tl_il' ), |
136 | | - array( 'add_table', 'change_tag', 'patch-change_tag.sql' ), |
137 | | - array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ), |
138 | | - array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ), |
| 136 | + array( 'addTable', 'change_tag', 'patch-change_tag.sql' ), |
| 137 | + array( 'addTable', 'tag_summary', 'patch-change_tag.sql' ), |
| 138 | + array( 'addTable', 'valid_tag', 'patch-change_tag.sql' ), |
139 | 139 | |
140 | 140 | // 1.16 |
141 | | - array( 'add_table', 'user_properties', 'patch-user_properties.sql' ), |
142 | | - array( 'add_table', 'log_search', 'patch-log_search.sql' ), |
| 141 | + array( 'addTable', 'user_properties', 'patch-user_properties.sql' ), |
| 142 | + array( 'addTable', 'log_search', 'patch-log_search.sql' ), |
143 | 143 | array( 'do_log_search_population' ), |
144 | 144 | array( 'add_field', 'logging', 'log_user_text', 'patch-log_user_text.sql' ), |
145 | | - array( 'add_table', 'l10n_cache', 'patch-l10n_cache.sql' ), |
146 | | - array( 'add_table', 'external_user', 'patch-external_user.sql' ), |
| 145 | + array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ), |
| 146 | + array( 'addTable', 'external_user', 'patch-external_user.sql' ), |
147 | 147 | array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ), |
148 | 148 | array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ), |
149 | 149 | array( 'add_field', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ), |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | array( 'do_populate_rev_len' ), |
154 | 154 | |
155 | 155 | // 1.17 |
156 | | - array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ), |
| 156 | + array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ), |
157 | 157 | array( 'add_index', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ), |
158 | 158 | array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ), |
159 | 159 | array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ), |
— | — | @@ -162,4 +162,33 @@ |
163 | 163 | array( 'do_collation_update' ), |
164 | 164 | ); |
165 | 165 | } |
| 166 | + |
| 167 | + protected function doNamespaceSize() { |
| 168 | + $tables = array( |
| 169 | + 'page' => 'page', |
| 170 | + 'archive' => 'ar', |
| 171 | + 'recentchanges' => 'rc', |
| 172 | + 'watchlist' => 'wl', |
| 173 | + 'querycache' => 'qc', |
| 174 | + 'logging' => 'log', |
| 175 | + ); |
| 176 | + foreach ( $tables as $table => $prefix ) { |
| 177 | + $field = $prefix . '_namespace'; |
| 178 | + |
| 179 | + $tablename = $this->db->tableName( $table ); |
| 180 | + $result = $this->db->query( "SHOW COLUMNS FROM $tablename LIKE '$field'" ); |
| 181 | + $info = $this->db->fetchObject( $result ); |
| 182 | + |
| 183 | + if ( substr( $info->Type, 0, 3 ) == 'int' ) { |
| 184 | + wfOut( "...$field is already a full int ($info->Type).\n" ); |
| 185 | + } else { |
| 186 | + wfOut( "Promoting $field from $info->Type to int... " ); |
| 187 | + |
| 188 | + $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
| 189 | + $this->db->query( $sql ); |
| 190 | + |
| 191 | + wfOut( "ok\n" ); |
| 192 | + } |
| 193 | + } |
| 194 | + } |
166 | 195 | } |
Index: trunk/phase3/includes/installer/SqliteUpdater.php |
— | — | @@ -17,17 +17,17 @@ |
18 | 18 | array( 'sqlite_initial_indexes' ), |
19 | 19 | |
20 | 20 | // 1.15 |
21 | | - array( 'add_table', 'change_tag', 'patch-change_tag.sql' ), |
22 | | - array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ), |
23 | | - array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ), |
| 21 | + array( 'addTable', 'change_tag', 'patch-change_tag.sql' ), |
| 22 | + array( 'addTable', 'tag_summary', 'patch-change_tag.sql' ), |
| 23 | + array( 'addTable', 'valid_tag', 'patch-change_tag.sql' ), |
24 | 24 | |
25 | 25 | // 1.16 |
26 | | - array( 'add_table', 'user_properties', 'patch-user_properties.sql' ), |
27 | | - array( 'add_table', 'log_search', 'patch-log_search.sql' ), |
| 26 | + array( 'addTable', 'user_properties', 'patch-user_properties.sql' ), |
| 27 | + array( 'addTable', 'log_search', 'patch-log_search.sql' ), |
28 | 28 | array( 'do_log_search_population' ), |
29 | 29 | array( 'add_field', 'logging', 'log_user_text', 'patch-log_user_text.sql' ), |
30 | | - array( 'add_table', 'l10n_cache', 'patch-l10n_cache.sql' ), |
31 | | - array( 'add_table', 'external_user', 'patch-external_user.sql' ), |
| 30 | + array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ), |
| 31 | + array( 'addTable', 'external_user', 'patch-external_user.sql' ), |
32 | 32 | array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ), |
33 | 33 | array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ), |
34 | 34 | array( 'add_field', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ), |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | array( 'sqlite_setup_searchindex' ), |
37 | 37 | |
38 | 38 | // 1.17 |
39 | | - array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ), |
| 39 | + array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ), |
40 | 40 | array( 'add_index', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ), |
41 | 41 | array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ), |
42 | 42 | array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ), |