MediaWiki  1.33.0
PostgresUpdater.php
Go to the documentation of this file.
1 <?php
25 
33 
37  protected $db;
38 
44  protected function getCoreUpdateList() {
45  return [
46  # rename tables 1.7.3
47  # r15791 Change reserved word table names "user" and "text"
48  [ 'renameTable', 'user', 'mwuser' ],
49  [ 'renameTable', 'text', 'pagecontent' ],
50  [ 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey' ],
51  [ 'renameIndex', 'mwuser', 'user_user_name_key', 'mwuser_user_name_key' ],
52  [ 'renameIndex', 'pagecontent', 'text_pkey', 'pagecontent_pkey' ],
53 
54  # renamed sequences
55  [ 'renameSequence', 'ipblocks_ipb_id_val', 'ipblocks_ipb_id_seq' ],
56  [ 'renameSequence', 'rev_rev_id_val', 'revision_rev_id_seq' ],
57  [ 'renameSequence', 'text_old_id_val', 'text_old_id_seq' ],
58  [ 'renameSequence', 'rc_rc_id_seq', 'recentchanges_rc_id_seq' ],
59  [ 'renameSequence', 'log_log_id_seq', 'logging_log_id_seq' ],
60  [ 'renameSequence', 'pr_id_val', 'page_restrictions_pr_id_seq' ],
61  [ 'renameSequence', 'us_id_seq', 'uploadstash_us_id_seq' ],
62 
63  # since r58263
64  [ 'renameSequence', 'category_id_seq', 'category_cat_id_seq' ],
65 
66  # new sequences if not renamed above
67  [ 'addSequence', 'logging', false, 'logging_log_id_seq' ],
68  [ 'addSequence', 'page_restrictions', false, 'page_restrictions_pr_id_seq' ],
69  [ 'addSequence', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ],
70  [ 'addSequence', 'archive', false, 'archive_ar_id_seq' ],
71  [ 'addSequence', 'externallinks', false, 'externallinks_el_id_seq' ],
72  [ 'addSequence', 'watchlist', false, 'watchlist_wl_id_seq' ],
73  [ 'addSequence', 'change_tag', false, 'change_tag_ct_id_seq' ],
74 
75  # new tables
76  [ 'addTable', 'category', 'patch-category.sql' ],
77  [ 'addTable', 'page', 'patch-page.sql' ],
78  [ 'addTable', 'querycachetwo', 'patch-querycachetwo.sql' ],
79  [ 'addTable', 'page_props', 'patch-page_props.sql' ],
80  [ 'addTable', 'page_restrictions', 'patch-page_restrictions.sql' ],
81  [ 'addTable', 'profiling', 'patch-profiling.sql' ],
82  [ 'addTable', 'protected_titles', 'patch-protected_titles.sql' ],
83  [ 'addTable', 'redirect', 'patch-redirect.sql' ],
84  [ 'addTable', 'updatelog', 'patch-updatelog.sql' ],
85  [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
86  [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
87  [ 'addTable', 'log_search', 'patch-log_search.sql' ],
88  [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
89  [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
90  [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
91  [ 'addTable', 'uploadstash', 'patch-uploadstash.sql' ],
92  [ 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ],
93  [ 'addTable', 'sites', 'patch-sites.sql' ],
94  [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
95 
96  # Needed before new field
97  [ 'convertArchive2' ],
98 
99  # new fields
100  [ 'addPgField', 'updatelog', 'ul_value', 'TEXT' ],
101  [ 'addPgField', 'archive', 'ar_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
102  [ 'addPgField', 'archive', 'ar_len', 'INTEGER' ],
103  [ 'addPgField', 'archive', 'ar_page_id', 'INTEGER' ],
104  [ 'addPgField', 'archive', 'ar_parent_id', 'INTEGER' ],
105  [ 'addPgField', 'archive', 'ar_content_model', 'TEXT' ],
106  [ 'addPgField', 'archive', 'ar_content_format', 'TEXT' ],
107  [ 'addPgField', 'categorylinks', 'cl_sortkey_prefix', "TEXT NOT NULL DEFAULT ''" ],
108  [ 'addPgField', 'categorylinks', 'cl_collation', "TEXT NOT NULL DEFAULT 0" ],
109  [ 'addPgField', 'categorylinks', 'cl_type', "TEXT NOT NULL DEFAULT 'page'" ],
110  [ 'addPgField', 'image', 'img_sha1', "TEXT NOT NULL DEFAULT ''" ],
111  [ 'addPgField', 'ipblocks', 'ipb_allow_usertalk', 'SMALLINT NOT NULL DEFAULT 0' ],
112  [ 'addPgField', 'ipblocks', 'ipb_anon_only', 'SMALLINT NOT NULL DEFAULT 0' ],
113  [ 'addPgField', 'ipblocks', 'ipb_by_text', "TEXT NOT NULL DEFAULT ''" ],
114  [ 'addPgField', 'ipblocks', 'ipb_block_email', 'SMALLINT NOT NULL DEFAULT 0' ],
115  [ 'addPgField', 'ipblocks', 'ipb_create_account', 'SMALLINT NOT NULL DEFAULT 1' ],
116  [ 'addPgField', 'ipblocks', 'ipb_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
117  [ 'addPgField', 'ipblocks', 'ipb_enable_autoblock', 'SMALLINT NOT NULL DEFAULT 1' ],
118  [ 'addPgField', 'ipblocks', 'ipb_parent_block_id',
119  'INTEGER DEFAULT NULL REFERENCES ipblocks(ipb_id) ' .
120  'ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED' ],
121  [ 'addPgField', 'filearchive', 'fa_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
122  [ 'addPgField', 'filearchive', 'fa_sha1', "TEXT NOT NULL DEFAULT ''" ],
123  [ 'addPgField', 'logging', 'log_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
124  [ 'addPgField', 'logging', 'log_id',
125  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ],
126  [ 'addPgField', 'logging', 'log_params', 'TEXT' ],
127  [ 'addPgField', 'mwuser', 'user_editcount', 'INTEGER' ],
128  [ 'addPgField', 'mwuser', 'user_newpass_time', 'TIMESTAMPTZ' ],
129  [ 'addPgField', 'oldimage', 'oi_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
130  [ 'addPgField', 'oldimage', 'oi_major_mime', "TEXT NOT NULL DEFAULT 'unknown'" ],
131  [ 'addPgField', 'oldimage', 'oi_media_type', 'TEXT' ],
132  [ 'addPgField', 'oldimage', 'oi_metadata', "BYTEA NOT NULL DEFAULT ''" ],
133  [ 'addPgField', 'oldimage', 'oi_minor_mime', "TEXT NOT NULL DEFAULT 'unknown'" ],
134  [ 'addPgField', 'oldimage', 'oi_sha1', "TEXT NOT NULL DEFAULT ''" ],
135  [ 'addPgField', 'page', 'page_content_model', 'TEXT' ],
136  [ 'addPgField', 'page_restrictions', 'pr_id',
137  "INTEGER NOT NULL UNIQUE DEFAULT nextval('page_restrictions_pr_id_seq')" ],
138  [ 'addPgField', 'profiling', 'pf_memory', 'NUMERIC(18,10) NOT NULL DEFAULT 0' ],
139  [ 'addPgField', 'recentchanges', 'rc_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
140  [ 'addPgField', 'recentchanges', 'rc_log_action', 'TEXT' ],
141  [ 'addPgField', 'recentchanges', 'rc_log_type', 'TEXT' ],
142  [ 'addPgField', 'recentchanges', 'rc_logid', 'INTEGER NOT NULL DEFAULT 0' ],
143  [ 'addPgField', 'recentchanges', 'rc_new_len', 'INTEGER' ],
144  [ 'addPgField', 'recentchanges', 'rc_old_len', 'INTEGER' ],
145  [ 'addPgField', 'recentchanges', 'rc_params', 'TEXT' ],
146  [ 'addPgField', 'redirect', 'rd_interwiki', 'TEXT NULL' ],
147  [ 'addPgField', 'redirect', 'rd_fragment', 'TEXT NULL' ],
148  [ 'addPgField', 'revision', 'rev_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
149  [ 'addPgField', 'revision', 'rev_len', 'INTEGER' ],
150  [ 'addPgField', 'revision', 'rev_parent_id', 'INTEGER DEFAULT NULL' ],
151  [ 'addPgField', 'revision', 'rev_content_model', 'TEXT' ],
152  [ 'addPgField', 'revision', 'rev_content_format', 'TEXT' ],
153  [ 'addPgField', 'site_stats', 'ss_active_users', "INTEGER DEFAULT '-1'" ],
154  [ 'addPgField', 'user_newtalk', 'user_last_timestamp', 'TIMESTAMPTZ' ],
155  [ 'addPgField', 'logging', 'log_user_text', "TEXT NOT NULL DEFAULT ''" ],
156  [ 'addPgField', 'logging', 'log_page', 'INTEGER' ],
157  [ 'addPgField', 'interwiki', 'iw_api', "TEXT NOT NULL DEFAULT ''" ],
158  [ 'addPgField', 'interwiki', 'iw_wikiid', "TEXT NOT NULL DEFAULT ''" ],
159  [ 'addPgField', 'revision', 'rev_sha1', "TEXT NOT NULL DEFAULT ''" ],
160  [ 'addPgField', 'archive', 'ar_sha1', "TEXT NOT NULL DEFAULT ''" ],
161  [ 'addPgField', 'uploadstash', 'us_chunk_inx', "INTEGER NULL" ],
162  [ 'addPgField', 'job', 'job_timestamp', "TIMESTAMPTZ" ],
163  [ 'addPgField', 'job', 'job_random', "INTEGER NOT NULL DEFAULT 0" ],
164  [ 'addPgField', 'job', 'job_attempts', "INTEGER NOT NULL DEFAULT 0" ],
165  [ 'addPgField', 'job', 'job_token', "TEXT NOT NULL DEFAULT ''" ],
166  [ 'addPgField', 'job', 'job_token_timestamp', "TIMESTAMPTZ" ],
167  [ 'addPgField', 'job', 'job_sha1', "TEXT NOT NULL DEFAULT ''" ],
168  [ 'addPgField', 'archive', 'ar_id',
169  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('archive_ar_id_seq')" ],
170  [ 'addPgField', 'externallinks', 'el_id',
171  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('externallinks_el_id_seq')" ],
172  [ 'addPgField', 'uploadstash', 'us_props', "BYTEA" ],
173 
174  # type changes
175  [ 'changeField', 'archive', 'ar_deleted', 'smallint', '' ],
176  [ 'changeField', 'archive', 'ar_minor_edit', 'smallint',
177  'ar_minor_edit::smallint DEFAULT 0' ],
178  [ 'changeField', 'filearchive', 'fa_deleted', 'smallint', '' ],
179  [ 'changeField', 'filearchive', 'fa_height', 'integer', '' ],
180  [ 'changeField', 'filearchive', 'fa_metadata', 'bytea', "decode(fa_metadata,'escape')" ],
181  [ 'changeField', 'filearchive', 'fa_size', 'integer', '' ],
182  [ 'changeField', 'filearchive', 'fa_width', 'integer', '' ],
183  [ 'changeField', 'filearchive', 'fa_storage_group', 'text', '' ],
184  [ 'changeField', 'filearchive', 'fa_storage_key', 'text', '' ],
185  [ 'changeField', 'image', 'img_metadata', 'bytea', "decode(img_metadata,'escape')" ],
186  [ 'changeField', 'image', 'img_size', 'integer', '' ],
187  [ 'changeField', 'image', 'img_width', 'integer', '' ],
188  [ 'changeField', 'image', 'img_height', 'integer', '' ],
189  [ 'changeField', 'interwiki', 'iw_local', 'smallint', 'iw_local::smallint' ],
190  [ 'changeField', 'interwiki', 'iw_trans', 'smallint', 'iw_trans::smallint DEFAULT 0' ],
191  [ 'changeField', 'ipblocks', 'ipb_auto', 'smallint', 'ipb_auto::smallint DEFAULT 0' ],
192  [ 'changeField', 'ipblocks', 'ipb_anon_only', 'smallint',
193  "CASE WHEN ipb_anon_only=' ' THEN 0 ELSE ipb_anon_only::smallint END DEFAULT 0" ],
194  [ 'changeField', 'ipblocks', 'ipb_create_account', 'smallint',
195  "CASE WHEN ipb_create_account=' ' THEN 0 ELSE ipb_create_account::smallint END DEFAULT 1" ],
196  [ 'changeField', 'ipblocks', 'ipb_enable_autoblock', 'smallint',
197  "CASE WHEN ipb_enable_autoblock=' ' THEN 0 ELSE ipb_enable_autoblock::smallint END DEFAULT 1" ],
198  [ 'changeField', 'ipblocks', 'ipb_block_email', 'smallint',
199  "CASE WHEN ipb_block_email=' ' THEN 0 ELSE ipb_block_email::smallint END DEFAULT 0" ],
200  [ 'changeField', 'ipblocks', 'ipb_address', 'text', 'ipb_address::text' ],
201  [ 'changeField', 'ipblocks', 'ipb_deleted', 'smallint', 'ipb_deleted::smallint DEFAULT 0' ],
202  [ 'changeField', 'mwuser', 'user_token', 'text', '' ],
203  [ 'changeField', 'mwuser', 'user_email_token', 'text', '' ],
204  [ 'changeField', 'objectcache', 'keyname', 'text', '' ],
205  [ 'changeField', 'oldimage', 'oi_height', 'integer', '' ],
206  [ 'changeField', 'oldimage', 'oi_metadata', 'bytea', "decode(img_metadata,'escape')" ],
207  [ 'changeField', 'oldimage', 'oi_size', 'integer', '' ],
208  [ 'changeField', 'oldimage', 'oi_width', 'integer', '' ],
209  [ 'changeField', 'page', 'page_is_redirect', 'smallint',
210  'page_is_redirect::smallint DEFAULT 0' ],
211  [ 'changeField', 'page', 'page_is_new', 'smallint', 'page_is_new::smallint DEFAULT 0' ],
212  [ 'changeField', 'querycache', 'qc_value', 'integer', '' ],
213  [ 'changeField', 'querycachetwo', 'qcc_value', 'integer', '' ],
214  [ 'changeField', 'recentchanges', 'rc_bot', 'smallint', 'rc_bot::smallint DEFAULT 0' ],
215  [ 'changeField', 'recentchanges', 'rc_deleted', 'smallint', '' ],
216  [ 'changeField', 'recentchanges', 'rc_minor', 'smallint', 'rc_minor::smallint DEFAULT 0' ],
217  [ 'changeField', 'recentchanges', 'rc_new', 'smallint', 'rc_new::smallint DEFAULT 0' ],
218  [ 'changeField', 'recentchanges', 'rc_type', 'smallint', 'rc_type::smallint DEFAULT 0' ],
219  [ 'changeField', 'recentchanges', 'rc_patrolled', 'smallint',
220  'rc_patrolled::smallint DEFAULT 0' ],
221  [ 'changeField', 'revision', 'rev_deleted', 'smallint', 'rev_deleted::smallint DEFAULT 0' ],
222  [ 'changeField', 'revision', 'rev_minor_edit', 'smallint',
223  'rev_minor_edit::smallint DEFAULT 0' ],
224  [ 'changeField', 'templatelinks', 'tl_namespace', 'smallint', 'tl_namespace::smallint' ],
225  [ 'changeField', 'user_newtalk', 'user_ip', 'text', 'host(user_ip)' ],
226  [ 'changeField', 'uploadstash', 'us_image_bits', 'smallint', '' ],
227  [ 'changeField', 'profiling', 'pf_time', 'float', '' ],
228  [ 'changeField', 'profiling', 'pf_memory', 'float', '' ],
229 
230  # null changes
231  [ 'changeNullableField', 'oldimage', 'oi_bits', 'NULL' ],
232  [ 'changeNullableField', 'oldimage', 'oi_timestamp', 'NULL' ],
233  [ 'changeNullableField', 'oldimage', 'oi_major_mime', 'NULL' ],
234  [ 'changeNullableField', 'oldimage', 'oi_minor_mime', 'NULL' ],
235  [ 'changeNullableField', 'image', 'img_metadata', 'NOT NULL' ],
236  [ 'changeNullableField', 'filearchive', 'fa_metadata', 'NOT NULL' ],
237  [ 'changeNullableField', 'recentchanges', 'rc_cur_id', 'NULL' ],
238  [ 'changeNullableField', 'recentchanges', 'rc_cur_time', 'NULL' ],
239 
240  [ 'checkOiDeleted' ],
241 
242  # New indexes
243  [ 'addPgIndex', 'archive', 'archive_user_text', '(ar_user_text)' ],
244  [ 'addPgIndex', 'image', 'img_sha1', '(img_sha1)' ],
245  [ 'addPgIndex', 'ipblocks', 'ipb_parent_block_id', '(ipb_parent_block_id)' ],
246  [ 'addPgIndex', 'oldimage', 'oi_sha1', '(oi_sha1)' ],
247  [ 'addPgIndex', 'page', 'page_mediawiki_title', '(page_title) WHERE page_namespace = 8' ],
248  [ 'addPgIndex', 'pagelinks', 'pagelinks_title', '(pl_title)' ],
249  [ 'addPgIndex', 'page_props', 'pp_propname_page', '(pp_propname, pp_page)' ],
250  [ 'addPgIndex', 'revision', 'rev_text_id_idx', '(rev_text_id)' ],
251  [ 'addPgIndex', 'recentchanges', 'rc_timestamp_bot', '(rc_timestamp) WHERE rc_bot = 0' ],
252  [ 'addPgIndex', 'templatelinks', 'templatelinks_from', '(tl_from)' ],
253  [ 'addPgIndex', 'watchlist', 'wl_user', '(wl_user)' ],
254  [ 'addPgIndex', 'watchlist', 'wl_user_notificationtimestamp',
255  '(wl_user, wl_notificationtimestamp)' ],
256  [ 'addPgIndex', 'logging', 'logging_user_type_time',
257  '(log_user, log_type, log_timestamp)' ],
258  [ 'addPgIndex', 'logging', 'logging_page_id_time', '(log_page,log_timestamp)' ],
259  [ 'addPgIndex', 'iwlinks', 'iwl_prefix_from_title', '(iwl_prefix, iwl_from, iwl_title)' ],
260  [ 'addPgIndex', 'iwlinks', 'iwl_prefix_title_from', '(iwl_prefix, iwl_title, iwl_from)' ],
261  [ 'addPgIndex', 'job', 'job_timestamp_idx', '(job_timestamp)' ],
262  [ 'addPgIndex', 'job', 'job_sha1', '(job_sha1)' ],
263  [ 'addPgIndex', 'job', 'job_cmd_token', '(job_cmd, job_token, job_random)' ],
264  [ 'addPgIndex', 'job', 'job_cmd_token_id', '(job_cmd, job_token, job_id)' ],
265  [ 'addPgIndex', 'filearchive', 'fa_sha1', '(fa_sha1)' ],
266  [ 'addPgIndex', 'logging', 'logging_user_text_type_time',
267  '(log_user_text, log_type, log_timestamp)' ],
268  [ 'addPgIndex', 'logging', 'logging_user_text_time', '(log_user_text, log_timestamp)' ],
269 
270  [ 'checkIndex', 'pagelink_unique', [
271  [ 'pl_from', 'int4_ops', 'btree', 0 ],
272  [ 'pl_namespace', 'int2_ops', 'btree', 0 ],
273  [ 'pl_title', 'text_ops', 'btree', 0 ],
274  ],
275  'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' ],
276  [ 'checkIndex', 'cl_sortkey', [
277  [ 'cl_to', 'text_ops', 'btree', 0 ],
278  [ 'cl_sortkey', 'text_ops', 'btree', 0 ],
279  [ 'cl_from', 'int4_ops', 'btree', 0 ],
280  ],
281  'CREATE INDEX cl_sortkey ON "categorylinks" ' .
282  'USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ],
283  [ 'checkIndex', 'iwl_prefix_title_from', [
284  [ 'iwl_prefix', 'text_ops', 'btree', 0 ],
285  [ 'iwl_title', 'text_ops', 'btree', 0 ],
286  [ 'iwl_from', 'int4_ops', 'btree', 0 ],
287  ],
288  'CREATE INDEX iwl_prefix_title_from ON "iwlinks" ' .
289  'USING "btree" ("iwl_prefix", "iwl_title", "iwl_from")' ],
290  [ 'checkIndex', 'logging_times', [
291  [ 'log_timestamp', 'timestamptz_ops', 'btree', 0 ],
292  ],
293  'CREATE INDEX "logging_times" ON "logging" USING "btree" ("log_timestamp")' ],
294  [ 'dropPgIndex', 'oldimage', 'oi_name' ],
295  [ 'checkIndex', 'oi_name_archive_name', [
296  [ 'oi_name', 'text_ops', 'btree', 0 ],
297  [ 'oi_archive_name', 'text_ops', 'btree', 0 ],
298  ],
299  'CREATE INDEX "oi_name_archive_name" ON "oldimage" ' .
300  'USING "btree" ("oi_name", "oi_archive_name")' ],
301  [ 'checkIndex', 'oi_name_timestamp', [
302  [ 'oi_name', 'text_ops', 'btree', 0 ],
303  [ 'oi_timestamp', 'timestamptz_ops', 'btree', 0 ],
304  ],
305  'CREATE INDEX "oi_name_timestamp" ON "oldimage" ' .
306  'USING "btree" ("oi_name", "oi_timestamp")' ],
307  [ 'checkIndex', 'page_main_title', [
308  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
309  ],
310  'CREATE INDEX "page_main_title" ON "page" ' .
311  'USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 0)' ],
312  [ 'checkIndex', 'page_mediawiki_title', [
313  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
314  ],
315  'CREATE INDEX "page_mediawiki_title" ON "page" ' .
316  'USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 8)' ],
317  [ 'checkIndex', 'page_project_title', [
318  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
319  ],
320  'CREATE INDEX "page_project_title" ON "page" ' .
321  'USING "btree" ("page_title" "text_pattern_ops") ' .
322  'WHERE ("page_namespace" = 4)' ],
323  [ 'checkIndex', 'page_talk_title', [
324  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
325  ],
326  'CREATE INDEX "page_talk_title" ON "page" ' .
327  'USING "btree" ("page_title" "text_pattern_ops") ' .
328  'WHERE ("page_namespace" = 1)' ],
329  [ 'checkIndex', 'page_user_title', [
330  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
331  ],
332  'CREATE INDEX "page_user_title" ON "page" ' .
333  'USING "btree" ("page_title" "text_pattern_ops") WHERE ' .
334  '("page_namespace" = 2)' ],
335  [ 'checkIndex', 'page_utalk_title', [
336  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
337  ],
338  'CREATE INDEX "page_utalk_title" ON "page" ' .
339  'USING "btree" ("page_title" "text_pattern_ops") ' .
340  'WHERE ("page_namespace" = 3)' ],
341  [ 'checkIndex', 'ts2_page_text', [
342  [ 'textvector', 'tsvector_ops', 'gist', 0 ],
343  ],
344  'CREATE INDEX "ts2_page_text" ON "pagecontent" USING "gist" ("textvector")' ],
345  [ 'checkIndex', 'ts2_page_title', [
346  [ 'titlevector', 'tsvector_ops', 'gist', 0 ],
347  ],
348  'CREATE INDEX "ts2_page_title" ON "page" USING "gist" ("titlevector")' ],
349 
350  [ 'checkOiNameConstraint' ],
351  [ 'checkPageDeletedTrigger' ],
352  [ 'checkRevUserFkey' ],
353  [ 'dropPgIndex', 'ipblocks', 'ipb_address' ],
354  [ 'checkIndex', 'ipb_address_unique', [
355  [ 'ipb_address', 'text_ops', 'btree', 0 ],
356  [ 'ipb_user', 'int4_ops', 'btree', 0 ],
357  [ 'ipb_auto', 'int2_ops', 'btree', 0 ],
358  [ 'ipb_anon_only', 'int2_ops', 'btree', 0 ],
359  ],
360  'CREATE UNIQUE INDEX ipb_address_unique ' .
361  'ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ],
362 
363  [ 'checkIwlPrefix' ],
364 
365  # All FK columns should be deferred
366  [ 'changeFkeyDeferrable', 'archive', 'ar_user', 'mwuser(user_id) ON DELETE SET NULL' ],
367  [ 'changeFkeyDeferrable', 'categorylinks', 'cl_from', 'page(page_id) ON DELETE CASCADE' ],
368  [ 'changeFkeyDeferrable', 'externallinks', 'el_from', 'page(page_id) ON DELETE CASCADE' ],
369  [ 'changeFkeyDeferrable', 'filearchive', 'fa_deleted_user',
370  'mwuser(user_id) ON DELETE SET NULL' ],
371  [ 'changeFkeyDeferrable', 'filearchive', 'fa_user', 'mwuser(user_id) ON DELETE SET NULL' ],
372  [ 'changeFkeyDeferrable', 'image', 'img_user', 'mwuser(user_id) ON DELETE SET NULL' ],
373  [ 'changeFkeyDeferrable', 'imagelinks', 'il_from', 'page(page_id) ON DELETE CASCADE' ],
374  [ 'changeFkeyDeferrable', 'ipblocks', 'ipb_by', 'mwuser(user_id) ON DELETE CASCADE' ],
375  [ 'changeFkeyDeferrable', 'ipblocks', 'ipb_user', 'mwuser(user_id) ON DELETE SET NULL' ],
376  [ 'changeFkeyDeferrable', 'ipblocks', 'ipb_parent_block_id',
377  'ipblocks(ipb_id) ON DELETE SET NULL' ],
378  [ 'changeFkeyDeferrable', 'langlinks', 'll_from', 'page(page_id) ON DELETE CASCADE' ],
379  [ 'changeFkeyDeferrable', 'logging', 'log_user', 'mwuser(user_id) ON DELETE SET NULL' ],
380  [ 'changeFkeyDeferrable', 'oldimage', 'oi_name',
381  'image(img_name) ON DELETE CASCADE ON UPDATE CASCADE' ],
382  [ 'changeFkeyDeferrable', 'oldimage', 'oi_user', 'mwuser(user_id) ON DELETE SET NULL' ],
383  [ 'changeFkeyDeferrable', 'pagelinks', 'pl_from', 'page(page_id) ON DELETE CASCADE' ],
384  [ 'changeFkeyDeferrable', 'page_props', 'pp_page', 'page (page_id) ON DELETE CASCADE' ],
385  [ 'changeFkeyDeferrable', 'page_restrictions', 'pr_page',
386  'page(page_id) ON DELETE CASCADE' ],
387  [ 'changeFkeyDeferrable', 'protected_titles', 'pt_user',
388  'mwuser(user_id) ON DELETE SET NULL' ],
389  [ 'changeFkeyDeferrable', 'recentchanges', 'rc_user',
390  'mwuser(user_id) ON DELETE SET NULL' ],
391  [ 'changeFkeyDeferrable', 'redirect', 'rd_from', 'page(page_id) ON DELETE CASCADE' ],
392  [ 'changeFkeyDeferrable', 'revision', 'rev_page', 'page (page_id) ON DELETE CASCADE' ],
393  [ 'changeFkeyDeferrable', 'revision', 'rev_user', 'mwuser(user_id) ON DELETE RESTRICT' ],
394  [ 'changeFkeyDeferrable', 'templatelinks', 'tl_from', 'page(page_id) ON DELETE CASCADE' ],
395  [ 'changeFkeyDeferrable', 'user_groups', 'ug_user', 'mwuser(user_id) ON DELETE CASCADE' ],
396  [ 'changeFkeyDeferrable', 'user_newtalk', 'user_id', 'mwuser(user_id) ON DELETE CASCADE' ],
397  [ 'changeFkeyDeferrable', 'user_properties', 'up_user',
398  'mwuser(user_id) ON DELETE CASCADE' ],
399  [ 'changeFkeyDeferrable', 'watchlist', 'wl_user', 'mwuser(user_id) ON DELETE CASCADE' ],
400 
401  # r81574
402  [ 'addInterwikiType' ],
403  # end
404  [ 'tsearchFixes' ],
405 
406  // 1.23
407  [ 'addPgField', 'recentchanges', 'rc_source', "TEXT NOT NULL DEFAULT ''" ],
408  [ 'addPgField', 'page', 'page_links_updated', "TIMESTAMPTZ NULL" ],
409  [ 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ],
410  [ 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea',
411  "replace(lc_value,'\','\\\\')::bytea" ],
412  // 1.23.9
413  [ 'rebuildTextSearch' ],
414 
415  // 1.24
416  [ 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ],
417  [ 'addPgIndex', 'page_props', 'pp_propname_sortkey_page',
418  '( pp_propname, pp_sortkey, pp_page ) WHERE ( pp_sortkey IS NOT NULL )' ],
419  [ 'addPgField', 'page', 'page_lang', 'TEXT default NULL' ],
420  [ 'addPgField', 'pagelinks', 'pl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
421  [ 'addPgField', 'templatelinks', 'tl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
422  [ 'addPgField', 'imagelinks', 'il_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
423 
424  // 1.25
425  [ 'dropTable', 'hitcounter' ],
426  [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
427  [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
428  [ 'dropFkey', 'recentchanges', 'rc_cur_id' ],
429 
430  // 1.27
431  [ 'dropTable', 'msg_resource_links' ],
432  [ 'dropTable', 'msg_resource' ],
433  [
434  'addPgField', 'watchlist', 'wl_id',
435  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('watchlist_wl_id_seq')"
436  ],
437 
438  // 1.28
439  [ 'addPgIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
440  '( rc_namespace, rc_type, rc_patrolled, rc_timestamp )' ],
441  [ 'addPgField', 'change_tag', 'ct_id',
442  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('change_tag_ct_id_seq')" ],
443 
444  // 1.29
445  [ 'addPgField', 'externallinks', 'el_index_60', "BYTEA NOT NULL DEFAULT ''" ],
446  [ 'addPgIndex', 'externallinks', 'el_index_60', '( el_index_60, el_id )' ],
447  [ 'addPgIndex', 'externallinks', 'el_from_index_60', '( el_from, el_index_60, el_id )' ],
448  [ 'addPgField', 'user_groups', 'ug_expiry', "TIMESTAMPTZ NULL" ],
449  [ 'addPgIndex', 'user_groups', 'user_groups_expiry', '( ug_expiry )' ],
450 
451  // 1.30
452  [ 'addPgEnumValue', 'media_type', '3D' ],
453  [ 'setDefault', 'revision', 'rev_comment', '' ],
454  [ 'changeNullableField', 'revision', 'rev_comment', 'NOT NULL', true ],
455  [ 'setDefault', 'archive', 'ar_comment', '' ],
456  [ 'changeNullableField', 'archive', 'ar_comment', 'NOT NULL', true ],
457  [ 'addPgField', 'archive', 'ar_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
458  [ 'setDefault', 'ipblocks', 'ipb_reason', '' ],
459  [ 'addPgField', 'ipblocks', 'ipb_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
460  [ 'setDefault', 'image', 'img_description', '' ],
461  [ 'setDefault', 'oldimage', 'oi_description', '' ],
462  [ 'changeNullableField', 'oldimage', 'oi_description', 'NOT NULL', true ],
463  [ 'addPgField', 'oldimage', 'oi_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
464  [ 'setDefault', 'filearchive', 'fa_deleted_reason', '' ],
465  [ 'changeNullableField', 'filearchive', 'fa_deleted_reason', 'NOT NULL', true ],
466  [ 'addPgField', 'filearchive', 'fa_deleted_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
467  [ 'setDefault', 'filearchive', 'fa_description', '' ],
468  [ 'addPgField', 'filearchive', 'fa_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
469  [ 'setDefault', 'recentchanges', 'rc_comment', '' ],
470  [ 'changeNullableField', 'recentchanges', 'rc_comment', 'NOT NULL', true ],
471  [ 'addPgField', 'recentchanges', 'rc_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
472  [ 'setDefault', 'logging', 'log_comment', '' ],
473  [ 'changeNullableField', 'logging', 'log_comment', 'NOT NULL', true ],
474  [ 'addPgField', 'logging', 'log_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
475  [ 'setDefault', 'protected_titles', 'pt_reason', '' ],
476  [ 'changeNullableField', 'protected_titles', 'pt_reason', 'NOT NULL', true ],
477  [ 'addPgField', 'protected_titles', 'pt_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
478  [ 'addTable', 'comment', 'patch-comment-table.sql' ],
479 
480  // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
481  [ 'addPgField', 'image', 'img_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
482 
483  [ 'migrateComments' ],
484  [ 'addIndex', 'site_stats', 'site_stats_pkey', 'patch-site_stats-pk.sql' ],
485  [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
486 
487  // 1.31
488  [ 'addTable', 'slots', 'patch-slots-table.sql' ],
489  [ 'dropPgIndex', 'slots', 'slot_role_inherited' ],
490  [ 'dropPgField', 'slots', 'slot_inherited' ],
491  [ 'addPgField', 'slots', 'slot_origin', 'INTEGER NOT NULL' ],
492  [
493  'addPgIndex',
494  'slots',
495  'slot_revision_origin_role',
496  '( slot_revision_id, slot_origin, slot_role_id )',
497  ],
498  [ 'addTable', 'content', 'patch-content-table.sql' ],
499  [ 'addTable', 'content_models', 'patch-content_models-table.sql' ],
500  [ 'addTable', 'slot_roles', 'patch-slot_roles-table.sql' ],
501  [ 'migrateArchiveText' ],
502  [ 'addTable', 'actor', 'patch-actor-table.sql' ],
503  [ 'setDefault', 'revision', 'rev_user', 0 ],
504  [ 'setDefault', 'revision', 'rev_user_text', '' ],
505  [ 'setDefault', 'archive', 'ar_user', 0 ],
506  [ 'changeNullableField', 'archive', 'ar_user', 'NOT NULL', true ],
507  [ 'setDefault', 'archive', 'ar_user_text', '' ],
508  [ 'addPgField', 'archive', 'ar_actor', 'INTEGER NOT NULL DEFAULT 0' ],
509  [ 'addPgIndex', 'archive', 'archive_actor', '( ar_actor )' ],
510  [ 'setDefault', 'ipblocks', 'ipb_by', 0 ],
511  [ 'addPgField', 'ipblocks', 'ipb_by_actor', 'INTEGER NOT NULL DEFAULT 0' ],
512  [ 'setDefault', 'image', 'img_user', 0 ],
513  [ 'changeNullableField', 'image', 'img_user', 'NOT NULL', true ],
514  [ 'setDefault', 'image', 'img_user_text', '' ],
515  [ 'addPgField', 'image', 'img_actor', 'INTEGER NOT NULL DEFAULT 0' ],
516  [ 'setDefault', 'oldimage', 'oi_user', 0 ],
517  [ 'changeNullableField', 'oldimage', 'oi_user', 'NOT NULL', true ],
518  [ 'setDefault', 'oldimage', 'oi_user_text', '' ],
519  [ 'addPgField', 'oldimage', 'oi_actor', 'INTEGER NOT NULL DEFAULT 0' ],
520  [ 'setDefault', 'filearchive', 'fa_user', 0 ],
521  [ 'changeNullableField', 'filearchive', 'fa_user', 'NOT NULL', true ],
522  [ 'setDefault', 'filearchive', 'fa_user_text', '' ],
523  [ 'addPgField', 'filearchive', 'fa_actor', 'INTEGER NOT NULL DEFAULT 0' ],
524  [ 'setDefault', 'recentchanges', 'rc_user', 0 ],
525  [ 'changeNullableField', 'recentchanges', 'rc_user', 'NOT NULL', true ],
526  [ 'setDefault', 'recentchanges', 'rc_user_text', '' ],
527  [ 'addPgField', 'recentchanges', 'rc_actor', 'INTEGER NOT NULL DEFAULT 0' ],
528  [ 'setDefault', 'logging', 'log_user', 0 ],
529  [ 'changeNullableField', 'logging', 'log_user', 'NOT NULL', true ],
530  [ 'addPgField', 'logging', 'log_actor', 'INTEGER NOT NULL DEFAULT 0' ],
531  [ 'addPgIndex', 'logging', 'logging_actor_time_backwards', '( log_timestamp, log_actor )' ],
532  [ 'addPgIndex', 'logging', 'logging_actor_type_time', '( log_actor, log_type, log_timestamp )' ],
533  [ 'addPgIndex', 'logging', 'logging_actor_time', '( log_actor, log_timestamp )' ],
534  [ 'migrateActors' ],
535  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
536  [ 'populateArchiveRevId' ],
537  [ 'dropPgIndex', 'recentchanges', 'rc_namespace_title' ],
538  [
539  'addPgIndex',
540  'recentchanges',
541  'rc_namespace_title_timestamp', '( rc_namespace, rc_title, rc_timestamp )'
542  ],
543  [ 'setSequenceOwner', 'mwuser', 'user_id', 'user_user_id_seq' ],
544  [ 'setSequenceOwner', 'actor', 'actor_id', 'actor_actor_id_seq' ],
545  [ 'setSequenceOwner', 'page', 'page_id', 'page_page_id_seq' ],
546  [ 'setSequenceOwner', 'revision', 'rev_id', 'revision_rev_id_seq' ],
547  [ 'setSequenceOwner', 'ip_changes', 'ipc_rev_id', 'ip_changes_ipc_rev_id_seq' ],
548  [ 'setSequenceOwner', 'pagecontent', 'old_id', 'text_old_id_seq' ],
549  [ 'setSequenceOwner', 'comment', 'comment_id', 'comment_comment_id_seq' ],
550  [ 'setSequenceOwner', 'page_restrictions', 'pr_id', 'page_restrictions_pr_id_seq' ],
551  [ 'setSequenceOwner', 'archive', 'ar_id', 'archive_ar_id_seq' ],
552  [ 'setSequenceOwner', 'content', 'content_id', 'content_content_id_seq' ],
553  [ 'setSequenceOwner', 'slot_roles', 'role_id', 'slot_roles_role_id_seq' ],
554  [ 'setSequenceOwner', 'content_models', 'model_id', 'content_models_model_id_seq' ],
555  [ 'setSequenceOwner', 'externallinks', 'el_id', 'externallinks_el_id_seq' ],
556  [ 'setSequenceOwner', 'ipblocks', 'ipb_id', 'ipblocks_ipb_id_seq' ],
557  [ 'setSequenceOwner', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ],
558  [ 'setSequenceOwner', 'uploadstash', 'us_id', 'uploadstash_us_id_seq' ],
559  [ 'setSequenceOwner', 'recentchanges', 'rc_id', 'recentchanges_rc_id_seq' ],
560  [ 'setSequenceOwner', 'watchlist', 'wl_id', 'watchlist_wl_id_seq' ],
561  [ 'setSequenceOwner', 'logging', 'log_id', 'logging_log_id_seq' ],
562  [ 'setSequenceOwner', 'job', 'job_id', 'job_job_id_seq' ],
563  [ 'setSequenceOwner', 'category', 'cat_id', 'category_cat_id_seq' ],
564  [ 'setSequenceOwner', 'change_tag', 'ct_id', 'change_tag_ct_id_seq' ],
565  [ 'setSequenceOwner', 'sites', 'site_id', 'sites_site_id_seq' ],
566 
567  // 1.32
568  [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
569  [ 'populateExternallinksIndex60' ],
570  [ 'dropDefault', 'externallinks', 'el_index_60' ],
571  [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
572  [ 'addPgField', 'change_tag', 'ct_tag_id', 'INTEGER NULL' ],
573  [
574  'addPgIndex',
575  'change_tag',
576  'change_tag_tag_id_id',
577  '( ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id )'
578  ],
579  [ 'addPgIndex', 'archive', 'ar_revid_uniq', '(ar_rev_id)', 'unique' ],
580  [ 'dropPgIndex', 'archive', 'ar_revid' ], // Probably doesn't exist, but do it anyway.
581  [ 'populateContentTables' ],
582  [ 'addPgIndex', 'logging', 'log_type_action', '( log_type, log_action, log_timestamp )' ],
583  [ 'dropPgIndex', 'page_props', 'page_props_propname' ],
584  [ 'addIndex', 'interwiki', 'interwiki_pkey', 'patch-interwiki-pk.sql' ],
585  [ 'addIndex', 'protected_titles', 'protected_titles_pkey', 'patch-protected_titles-pk.sql' ],
586  [ 'addIndex', 'site_identifiers', 'site_identifiers_pkey', 'patch-site_identifiers-pk.sql' ],
587  [ 'addPgIndex', 'recentchanges', 'rc_this_oldid', '(rc_this_oldid)' ],
588  [ 'dropTable', 'transcache' ],
589  [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
590  [ 'addIndex', 'change_tag', 'change_tag_rc_tag_id',
591  'patch-change_tag-change_tag_rc_tag_id.sql' ],
592  [ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],
593  [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
594  [ 'migrateImageCommentTemp' ],
595  [ 'dropPgField', 'category', 'cat_hidden' ],
596  [ 'dropPgField', 'site_stats', 'ss_admins' ],
597  [ 'dropPgField', 'recentchanges', 'rc_cur_time' ],
598 
599  // 1.33
600  [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
601  [ 'dropTable', 'valid_tag' ],
602  [ 'dropTable', 'tag_summary' ],
603  [ 'dropPgField', 'archive', 'ar_comment' ],
604  [ 'dropDefault', 'archive', 'ar_comment_id' ],
605  [ 'dropPgField', 'ipblocks', 'ipb_reason' ],
606  [ 'dropDefault', 'ipblocks', 'ipb_reason_id' ],
607  [ 'dropPgField', 'image', 'img_description' ],
608  [ 'dropDefault', 'image', 'img_description_id' ],
609  [ 'dropPgField', 'oldimage', 'oi_description' ],
610  [ 'dropDefault', 'oldimage', 'oi_description_id' ],
611  [ 'dropPgField', 'filearchive', 'fa_deleted_reason' ],
612  [ 'dropDefault', 'filearchive', 'fa_deleted_reason_id' ],
613  [ 'dropPgField', 'filearchive', 'fa_description' ],
614  [ 'dropDefault', 'filearchive', 'fa_description_id' ],
615  [ 'dropPgField', 'recentchanges', 'rc_comment' ],
616  [ 'dropDefault', 'recentchanges', 'rc_comment_id' ],
617  [ 'dropPgField', 'logging', 'log_comment' ],
618  [ 'dropDefault', 'logging', 'log_comment_id' ],
619  [ 'dropPgField', 'protected_titles', 'pt_reason' ],
620  [ 'dropDefault', 'protected_titles', 'pt_reason_id' ],
621  ];
622  }
623 
624  protected function getOldGlobalUpdates() {
625  global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes;
626 
627  $updates = [];
628 
629  # Add missing extension tables
630  foreach ( $wgExtNewTables as $tableRecord ) {
631  $updates[] = [
632  'addTable', $tableRecord[0], $tableRecord[1], true
633  ];
634  }
635 
636  # Add missing extension fields
637  foreach ( $wgExtPGNewFields as $fieldRecord ) {
638  $updates[] = [
639  'addPgField', $fieldRecord[0], $fieldRecord[1],
640  $fieldRecord[2]
641  ];
642  }
643 
644  # Change altered columns
645  foreach ( $wgExtPGAlteredFields as $fieldRecord ) {
646  $updates[] = [
647  'changeField', $fieldRecord[0], $fieldRecord[1],
648  $fieldRecord[2]
649  ];
650  }
651 
652  # Add missing extension indexes
653  foreach ( $wgExtNewIndexes as $fieldRecord ) {
654  $updates[] = [
655  'addPgExtIndex', $fieldRecord[0], $fieldRecord[1],
656  $fieldRecord[2]
657  ];
658  }
659 
660  return $updates;
661  }
662 
663  protected function describeTable( $table ) {
664  $q = <<<END
665 SELECT attname, attnum FROM pg_namespace, pg_class, pg_attribute
666  WHERE pg_class.relnamespace = pg_namespace.oid
667  AND attrelid=pg_class.oid AND attnum > 0
668  AND relname=%s AND nspname=%s
669 END;
670  $res = $this->db->query( sprintf( $q,
671  $this->db->addQuotes( $table ),
672  $this->db->addQuotes( $this->db->getCoreSchema() ) ) );
673  if ( !$res ) {
674  return null;
675  }
676 
677  $cols = [];
678  foreach ( $res as $r ) {
679  $cols[] = [
680  "name" => $r[0],
681  "ord" => $r[1],
682  ];
683  }
684 
685  return $cols;
686  }
687 
688  function describeIndex( $idx ) {
689  // first fetch the key (which is a list of columns ords) and
690  // the table the index applies to (an oid)
691  $q = <<<END
692 SELECT indkey, indrelid FROM pg_namespace, pg_class, pg_index
693  WHERE nspname=%s
694  AND pg_class.relnamespace = pg_namespace.oid
695  AND relname=%s
696  AND indexrelid=pg_class.oid
697 END;
698  $res = $this->db->query(
699  sprintf(
700  $q,
701  $this->db->addQuotes( $this->db->getCoreSchema() ),
702  $this->db->addQuotes( $idx )
703  )
704  );
705  if ( !$res ) {
706  return null;
707  }
708  $r = $this->db->fetchRow( $res );
709  if ( !$r ) {
710  return null;
711  }
712 
713  $indkey = $r[0];
714  $relid = intval( $r[1] );
715  $indkeys = explode( ' ', $indkey );
716 
717  $colnames = [];
718  foreach ( $indkeys as $rid ) {
719  $query = <<<END
720 SELECT attname FROM pg_class, pg_attribute
721  WHERE attrelid=$relid
722  AND attnum=%d
723  AND attrelid=pg_class.oid
724 END;
725  $r2 = $this->db->query( sprintf( $query, $rid ) );
726  if ( !$r2 ) {
727  return null;
728  }
729  $row2 = $this->db->fetchRow( $r2 );
730  if ( !$row2 ) {
731  return null;
732  }
733  $colnames[] = $row2[0];
734  }
735 
736  return $colnames;
737  }
738 
739  function fkeyDeltype( $fkey ) {
740  $q = <<<END
741 SELECT confdeltype FROM pg_constraint, pg_namespace
742  WHERE connamespace=pg_namespace.oid
743  AND nspname=%s
744  AND conname=%s;
745 END;
746  $r = $this->db->query(
747  sprintf(
748  $q,
749  $this->db->addQuotes( $this->db->getCoreSchema() ),
750  $this->db->addQuotes( $fkey )
751  )
752  );
753  $row = $this->db->fetchRow( $r );
754  if ( !$row ) {
755  return null;
756  }
757 
758  return $row[0];
759  }
760 
761  function ruleDef( $table, $rule ) {
762  $q = <<<END
763 SELECT definition FROM pg_rules
764  WHERE schemaname = %s
765  AND tablename = %s
766  AND rulename = %s
767 END;
768  $r = $this->db->query(
769  sprintf(
770  $q,
771  $this->db->addQuotes( $this->db->getCoreSchema() ),
772  $this->db->addQuotes( $table ),
773  $this->db->addQuotes( $rule )
774  )
775  );
776  $row = $this->db->fetchRow( $r );
777  if ( !$row ) {
778  return null;
779  }
780  $d = $row[0];
781 
782  return $d;
783  }
784 
785  protected function addSequence( $table, $pkey, $ns ) {
786  if ( !$this->db->sequenceExists( $ns ) ) {
787  $this->output( "Creating sequence $ns\n" );
788  if ( $pkey !== false ) {
789  $this->db->query( "CREATE SEQUENCE $ns OWNED BY $table.$pkey" );
790  $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' );
791  } else {
792  $this->db->query( "CREATE SEQUENCE $ns" );
793  }
794  }
795  }
796 
797  protected function dropSequence( $table, $ns ) {
798  if ( $this->db->sequenceExists( $ns ) ) {
799  $this->output( "Dropping sequence $ns\n" );
800  $this->db->query( "DROP SEQUENCE $ns CASCADE" );
801  }
802  }
803 
804  protected function renameSequence( $old, $new ) {
805  if ( $this->db->sequenceExists( $new ) ) {
806  $this->output( "...sequence $new already exists.\n" );
807 
808  return;
809  }
810  if ( $this->db->sequenceExists( $old ) ) {
811  $this->output( "Renaming sequence $old to $new\n" );
812  $this->db->query( "ALTER SEQUENCE $old RENAME TO $new" );
813  }
814  }
815 
816  protected function setSequenceOwner( $table, $pkey, $seq ) {
817  if ( $this->db->sequenceExists( $seq ) ) {
818  $this->output( "Setting sequence $seq owner to $table.$pkey\n" );
819  $this->db->query( "ALTER SEQUENCE $seq OWNED BY $table.$pkey" );
820  }
821  }
822 
823  protected function renameTable( $old, $new, $patch = false ) {
824  if ( $this->db->tableExists( $old ) ) {
825  $this->output( "Renaming table $old to $new\n" );
826  $old = $this->db->realTableName( $old, "quoted" );
827  $new = $this->db->realTableName( $new, "quoted" );
828  $this->db->query( "ALTER TABLE $old RENAME TO $new" );
829  if ( $patch !== false ) {
830  $this->applyPatch( $patch );
831  }
832  }
833  }
834 
835  protected function renameIndex(
836  $table, $old, $new, $skipBothIndexExistWarning = false, $a = false, $b = false
837  ) {
838  // First requirement: the table must exist
839  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
840  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
841 
842  return true;
843  }
844 
845  // Second requirement: the new index must be missing
846  if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) {
847  $this->output( "...index $new already set on $table table.\n" );
848  if ( !$skipBothIndexExistWarning
849  && $this->db->indexExists( $table, $old, __METHOD__ )
850  ) {
851  $this->output( "...WARNING: $old still exists, despite it has been " .
852  "renamed into $new (which also exists).\n" .
853  " $old should be manually removed if not needed anymore.\n" );
854  }
855 
856  return true;
857  }
858 
859  // Third requirement: the old index must exist
860  if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
861  $this->output( "...skipping: index $old doesn't exist.\n" );
862 
863  return true;
864  }
865 
866  $this->db->query( "ALTER INDEX $old RENAME TO $new" );
867  return true;
868  }
869 
870  protected function dropPgField( $table, $field ) {
871  $fi = $this->db->fieldInfo( $table, $field );
872  if ( is_null( $fi ) ) {
873  $this->output( "...$table table does not contain $field field.\n" );
874 
875  return;
876  } else {
877  $this->output( "Dropping column '$table.$field'\n" );
878  $this->db->query( "ALTER TABLE $table DROP COLUMN $field" );
879  }
880  }
881 
882  protected function addPgField( $table, $field, $type ) {
883  $fi = $this->db->fieldInfo( $table, $field );
884  if ( !is_null( $fi ) ) {
885  $this->output( "...column '$table.$field' already exists\n" );
886 
887  return;
888  } else {
889  $this->output( "Adding column '$table.$field'\n" );
890  $this->db->query( "ALTER TABLE $table ADD $field $type" );
891  }
892  }
893 
894  protected function changeField( $table, $field, $newtype, $default ) {
895  $fi = $this->db->fieldInfo( $table, $field );
896  if ( is_null( $fi ) ) {
897  $this->output( "...ERROR: expected column $table.$field to exist\n" );
898  exit( 1 );
899  }
900 
901  if ( $fi->type() === $newtype ) {
902  $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
903  } else {
904  $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
905  $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
906  if ( strlen( $default ) ) {
907  $res = [];
908  if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) {
909  $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
910  $this->db->query( $sqldef );
911  $default = preg_replace( '/\s*DEFAULT .+/', '', $default );
912  }
913  $sql .= " USING $default";
914  }
915  $this->db->query( $sql );
916  }
917  }
918 
919  protected function changeFieldPurgeTable( $table, $field, $newtype, $default ) {
920  # # For a cache table, empty it if the field needs to be changed, because the old contents
921  # # may be corrupted. If the column is already the desired type, refrain from purging.
922  $fi = $this->db->fieldInfo( $table, $field );
923  if ( is_null( $fi ) ) {
924  $this->output( "...ERROR: expected column $table.$field to exist\n" );
925  exit( 1 );
926  }
927 
928  if ( $fi->type() === $newtype ) {
929  $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
930  } else {
931  $this->output( "Purging data from cache table '$table'\n" );
932  $this->db->query( "DELETE from $table" );
933  $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
934  $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
935  if ( strlen( $default ) ) {
936  $res = [];
937  if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) {
938  $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
939  $this->db->query( $sqldef );
940  $default = preg_replace( '/\s*DEFAULT .+/', '', $default );
941  }
942  $sql .= " USING $default";
943  }
944  $this->db->query( $sql );
945  }
946  }
947 
948  protected function setDefault( $table, $field, $default ) {
949  $info = $this->db->fieldInfo( $table, $field );
950  if ( $info && $info->defaultValue() !== $default ) {
951  $this->output( "Changing '$table.$field' default value\n" );
952  $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT "
953  . $this->db->addQuotes( $default ) );
954  }
955  }
956 
963  protected function dropDefault( $table, $field ) {
964  $info = $this->db->fieldInfo( $table, $field );
965  if ( $info->defaultValue() !== false ) {
966  $this->output( "Removing '$table.$field' default value\n" );
967  $this->db->query( "ALTER TABLE $table ALTER $field DROP DEFAULT" );
968  }
969  }
970 
971  protected function changeNullableField( $table, $field, $null, $update = false ) {
972  $fi = $this->db->fieldInfo( $table, $field );
973  if ( is_null( $fi ) ) {
974  return;
975  }
976  if ( $fi->isNullable() ) {
977  # # It's NULL - does it need to be NOT NULL?
978  if ( $null === 'NOT NULL' ) {
979  $this->output( "Changing '$table.$field' to not allow NULLs\n" );
980  if ( $update ) {
981  $this->db->query( "UPDATE $table SET $field = DEFAULT WHERE $field IS NULL" );
982  }
983  $this->db->query( "ALTER TABLE $table ALTER $field SET NOT NULL" );
984  } else {
985  $this->output( "...column '$table.$field' is already set as NULL\n" );
986  }
987  } else {
988  # # It's NOT NULL - does it need to be NULL?
989  if ( $null === 'NULL' ) {
990  $this->output( "Changing '$table.$field' to allow NULLs\n" );
991  $this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" );
992  } else {
993  $this->output( "...column '$table.$field' is already set as NOT NULL\n" );
994  }
995  }
996  }
997 
998  public function addPgIndex( $table, $index, $type, $unique = false ) {
999  if ( $this->db->indexExists( $table, $index ) ) {
1000  $this->output( "...index '$index' on table '$table' already exists\n" );
1001  } else {
1002  $this->output( "Creating index '$index' on table '$table' $type\n" );
1003  $unique = $unique ? 'UNIQUE' : '';
1004  $this->db->query( "CREATE $unique INDEX $index ON $table $type" );
1005  }
1006  }
1007 
1008  public function addPgExtIndex( $table, $index, $type ) {
1009  if ( $this->db->indexExists( $table, $index ) ) {
1010  $this->output( "...index '$index' on table '$table' already exists\n" );
1011  } elseif ( preg_match( '/^\(/', $type ) ) {
1012  $this->output( "Creating index '$index' on table '$table'\n" );
1013  $this->db->query( "CREATE INDEX $index ON $table $type" );
1014  } else {
1015  $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
1016  }
1017  }
1018 
1025  public function addPgEnumValue( $type, $value ) {
1026  $row = $this->db->selectRow(
1027  [
1028  't' => 'pg_catalog.pg_type',
1029  'n' => 'pg_catalog.pg_namespace',
1030  'e' => 'pg_catalog.pg_enum',
1031  ],
1032  [ 't.typname', 't.typtype', 'e.enumlabel' ],
1033  [
1034  't.typname' => $type,
1035  'n.nspname' => $this->db->getCoreSchema(),
1036  ],
1037  __METHOD__,
1038  [],
1039  [
1040  'n' => [ 'JOIN', 't.typnamespace = n.oid' ],
1041  'e' => [ 'LEFT JOIN', [ 'e.enumtypid = t.oid', 'e.enumlabel' => $value ] ],
1042  ]
1043  );
1044 
1045  if ( !$row ) {
1046  $this->output( "...Type $type does not exist, skipping modify enum.\n" );
1047  } elseif ( $row->typtype !== 'e' ) {
1048  $this->output( "...Type $type does not seem to be an enum, skipping modify enum.\n" );
1049  } elseif ( $row->enumlabel === $value ) {
1050  $this->output( "...Enum type $type already contains value '$value'.\n" );
1051  } else {
1052  $this->output( "...Adding value '$value' to enum type $type.\n" );
1053  $etype = $this->db->addIdentifierQuotes( $type );
1054  $evalue = $this->db->addQuotes( $value );
1055  $this->db->query( "ALTER TYPE $etype ADD VALUE $evalue" );
1056  }
1057  }
1058 
1059  protected function dropFkey( $table, $field ) {
1060  $fi = $this->db->fieldInfo( $table, $field );
1061  if ( is_null( $fi ) ) {
1062  $this->output( "WARNING! Column '$table.$field' does not exist but it should! " .
1063  "Please report this.\n" );
1064  return;
1065  }
1066  $conname = $fi->conname();
1067  if ( $fi->conname() ) {
1068  $this->output( "Dropping foreign key constraint on '$table.$field'\n" );
1069  $conclause = "CONSTRAINT \"$conname\"";
1070  $command = "ALTER TABLE $table DROP CONSTRAINT $conname";
1071  $this->db->query( $command );
1072  } else {
1073  $this->output( "...foreign key constraint on '$table.$field' already does not exist\n" );
1074  };
1075  }
1076 
1077  protected function changeFkeyDeferrable( $table, $field, $clause ) {
1078  $fi = $this->db->fieldInfo( $table, $field );
1079  if ( is_null( $fi ) ) {
1080  $this->output( "WARNING! Column '$table.$field' does not exist but it should! " .
1081  "Please report this.\n" );
1082 
1083  return;
1084  }
1085  if ( $fi->is_deferred() && $fi->is_deferrable() ) {
1086  return;
1087  }
1088  $this->output( "Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" );
1089  $conname = $fi->conname();
1090  if ( $fi->conname() ) {
1091  $conclause = "CONSTRAINT \"$conname\"";
1092  $command = "ALTER TABLE $table DROP CONSTRAINT $conname";
1093  $this->db->query( $command );
1094  } else {
1095  $this->output( "Column '$table.$field' does not have a foreign key " .
1096  "constraint, will be added\n" );
1097  $conclause = "";
1098  }
1099  $command =
1100  "ALTER TABLE $table ADD $conclause " .
1101  "FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED";
1102  $this->db->query( $command );
1103  }
1104 
1105  protected function convertArchive2() {
1106  if ( $this->db->tableExists( "archive2" ) ) {
1107  if ( $this->db->ruleExists( 'archive', 'archive_insert' ) ) {
1108  $this->output( "Dropping rule 'archive_insert'\n" );
1109  $this->db->query( 'DROP RULE archive_insert ON archive' );
1110  }
1111  if ( $this->db->ruleExists( 'archive', 'archive_delete' ) ) {
1112  $this->output( "Dropping rule 'archive_delete'\n" );
1113  $this->db->query( 'DROP RULE archive_delete ON archive' );
1114  }
1115  $this->applyPatch(
1116  'patch-remove-archive2.sql',
1117  false,
1118  "Converting 'archive2' back to normal archive table"
1119  );
1120  } else {
1121  $this->output( "...obsolete table 'archive2' does not exist\n" );
1122  }
1123  }
1124 
1125  protected function checkOiDeleted() {
1126  if ( $this->db->fieldInfo( 'oldimage', 'oi_deleted' )->type() !== 'smallint' ) {
1127  $this->output( "Changing 'oldimage.oi_deleted' to type 'smallint'\n" );
1128  $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
1129  $this->db->query(
1130  "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
1131  $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
1132  } else {
1133  $this->output( "...column 'oldimage.oi_deleted' is already of type 'smallint'\n" );
1134  }
1135  }
1136 
1137  protected function checkOiNameConstraint() {
1138  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascaded" ) ) {
1139  $this->output( "...table 'oldimage' has correct cascading delete/update " .
1140  "foreign key to image\n" );
1141  } else {
1142  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey" ) ) {
1143  $this->db->query(
1144  "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
1145  }
1146  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascade" ) ) {
1147  $this->db->query(
1148  "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" );
1149  }
1150  $this->output( "Making foreign key on table 'oldimage' (to image) a cascade delete/update\n" );
1151  $this->db->query(
1152  "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded " .
1153  "FOREIGN KEY (oi_name) REFERENCES image(img_name) " .
1154  "ON DELETE CASCADE ON UPDATE CASCADE" );
1155  }
1156  }
1157 
1158  protected function checkPageDeletedTrigger() {
1159  if ( !$this->db->triggerExists( 'page', 'page_deleted' ) ) {
1160  $this->applyPatch(
1161  'patch-page_deleted.sql',
1162  false,
1163  "Adding function and trigger 'page_deleted' to table 'page'"
1164  );
1165  } else {
1166  $this->output( "...table 'page' has 'page_deleted' trigger\n" );
1167  }
1168  }
1169 
1170  protected function dropPgIndex( $table, $index ) {
1171  if ( $this->db->indexExists( $table, $index ) ) {
1172  $this->output( "Dropping obsolete index '$index'\n" );
1173  $this->db->query( "DROP INDEX \"" . $index . "\"" );
1174  }
1175  }
1176 
1177  protected function checkIndex( $index, $should_be, $good_def ) {
1178  $pu = $this->db->indexAttributes( $index );
1179  if ( !empty( $pu ) && $pu != $should_be ) {
1180  $this->output( "Dropping obsolete version of index '$index'\n" );
1181  $this->db->query( "DROP INDEX \"" . $index . "\"" );
1182  $pu = [];
1183  } else {
1184  $this->output( "...no need to drop index '$index'\n" );
1185  }
1186 
1187  if ( empty( $pu ) ) {
1188  $this->output( "Creating index '$index'\n" );
1189  $this->db->query( $good_def );
1190  } else {
1191  $this->output( "...index '$index' exists\n" );
1192  }
1193  }
1194 
1195  protected function checkRevUserFkey() {
1196  if ( $this->fkeyDeltype( 'revision_rev_user_fkey' ) == 'r' ) {
1197  $this->output( "...constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" );
1198  } else {
1199  $this->applyPatch(
1200  'patch-revision_rev_user_fkey.sql',
1201  false,
1202  "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT"
1203  );
1204  }
1205  }
1206 
1207  protected function checkIwlPrefix() {
1208  if ( $this->db->indexExists( 'iwlinks', 'iwl_prefix' ) ) {
1209  $this->applyPatch(
1210  'patch-rename-iwl_prefix.sql',
1211  false,
1212  "Replacing index 'iwl_prefix' with 'iwl_prefix_title_from'"
1213  );
1214  }
1215  }
1216 
1217  protected function addInterwikiType() {
1218  $this->applyPatch( 'patch-add_interwiki.sql', false, "Refreshing add_interwiki()" );
1219  }
1220 
1221  protected function tsearchFixes() {
1222  # Tweak the page_title tsearch2 trigger to filter out slashes
1223  # This is create or replace, so harmless to call if not needed
1224  $this->applyPatch( 'patch-ts2pagetitle.sql', false, "Refreshing ts2_page_title()" );
1225 
1226  # If the server is 8.3 or higher, rewrite the tsearch2 triggers
1227  # in case they have the old 'default' versions
1228  # Gather version numbers in case we need them
1229  if ( $this->db->getServerVersion() >= 8.3 ) {
1230  $this->applyPatch( 'patch-tsearch2funcs.sql', false, "Rewriting tsearch2 triggers" );
1231  }
1232  }
1233 
1234  protected function rebuildTextSearch() {
1235  if ( $this->updateRowExists( 'patch-textsearch_bug66650.sql' ) ) {
1236  $this->output( "...T68650 already fixed or not applicable.\n" );
1237  return;
1238  };
1239  $this->applyPatch( 'patch-textsearch_bug66650.sql', false,
1240  'Rebuilding text search for T68650' );
1241  }
1242 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:221
PostgresUpdater\rebuildTextSearch
rebuildTextSearch()
Definition: PostgresUpdater.php:1234
PostgresUpdater\renameIndex
renameIndex( $table, $old, $new, $skipBothIndexExistWarning=false, $a=false, $b=false)
Rename an index from an existing table.
Definition: PostgresUpdater.php:835
PostgresUpdater\checkOiNameConstraint
checkOiNameConstraint()
Definition: PostgresUpdater.php:1137
PostgresUpdater\changeNullableField
changeNullableField( $table, $field, $null, $update=false)
Definition: PostgresUpdater.php:971
PostgresUpdater\getCoreUpdateList
getCoreUpdateList()
Definition: PostgresUpdater.php:44
PostgresUpdater\setDefault
setDefault( $table, $field, $default)
Definition: PostgresUpdater.php:948
PostgresUpdater\addPgEnumValue
addPgEnumValue( $type, $value)
Add a value to an existing PostgreSQL enum type.
Definition: PostgresUpdater.php:1025
DatabaseUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: DatabaseUpdater.php:672
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:36
PostgresUpdater\convertArchive2
convertArchive2()
Definition: PostgresUpdater.php:1105
PostgresUpdater\dropFkey
dropFkey( $table, $field)
Definition: PostgresUpdater.php:1059
PostgresUpdater\checkPageDeletedTrigger
checkPageDeletedTrigger()
Definition: PostgresUpdater.php:1158
PostgresUpdater\describeIndex
describeIndex( $idx)
Definition: PostgresUpdater.php:688
PostgresUpdater\$db
DatabasePostgres $db
Definition: PostgresUpdater.php:37
PostgresUpdater\renameTable
renameTable( $old, $new, $patch=false)
Definition: PostgresUpdater.php:823
PostgresUpdater\fkeyDeltype
fkeyDeltype( $fkey)
Definition: PostgresUpdater.php:739
Wikimedia\Rdbms\DatabasePostgres
Definition: DatabasePostgres.php:33
$res
$res
Definition: database.txt:21
PostgresUpdater\checkIwlPrefix
checkIwlPrefix()
Definition: PostgresUpdater.php:1207
PostgresUpdater\changeField
changeField( $table, $field, $newtype, $default)
Definition: PostgresUpdater.php:894
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
DatabaseUpdater\$updates
array $updates
Array of updates to perform on the database.
Definition: DatabaseUpdater.php:44
PostgresUpdater\changeFieldPurgeTable
changeFieldPurgeTable( $table, $field, $newtype, $default)
Definition: PostgresUpdater.php:919
PostgresUpdater\addPgExtIndex
addPgExtIndex( $table, $index, $type)
Definition: PostgresUpdater.php:1008
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1588
FROM
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR ARISING FROM
Definition: MIT-LICENSE.txt:10
PostgresUpdater\describeTable
describeTable( $table)
Definition: PostgresUpdater.php:663
PostgresUpdater\ruleDef
ruleDef( $table, $rule)
Definition: PostgresUpdater.php:761
PostgresUpdater\addPgIndex
addPgIndex( $table, $index, $type, $unique=false)
Definition: PostgresUpdater.php:998
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
PostgresUpdater\checkRevUserFkey
checkRevUserFkey()
Definition: PostgresUpdater.php:1195
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:509
$command
$command
Definition: cdb.php:65
$value
$value
Definition: styleTest.css.php:49
PostgresUpdater
Class for handling updates to Postgres databases.
Definition: PostgresUpdater.php:32
PostgresUpdater\checkIndex
checkIndex( $index, $should_be, $good_def)
Definition: PostgresUpdater.php:1177
PostgresUpdater\changeFkeyDeferrable
changeFkeyDeferrable( $table, $field, $clause)
Definition: PostgresUpdater.php:1077
PostgresUpdater\renameSequence
renameSequence( $old, $new)
Definition: PostgresUpdater.php:804
PostgresUpdater\dropDefault
dropDefault( $table, $field)
Drop a default value from a field.
Definition: PostgresUpdater.php:963
PostgresUpdater\setSequenceOwner
setSequenceOwner( $table, $pkey, $seq)
Definition: PostgresUpdater.php:816
PostgresUpdater\addInterwikiType
addInterwikiType()
Definition: PostgresUpdater.php:1217
PostgresUpdater\dropSequence
dropSequence( $table, $ns)
Definition: PostgresUpdater.php:797
PostgresUpdater\addSequence
addSequence( $table, $pkey, $ns)
Definition: PostgresUpdater.php:785
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
PostgresUpdater\tsearchFixes
tsearchFixes()
Definition: PostgresUpdater.php:1221
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1985
PostgresUpdater\addPgField
addPgField( $table, $field, $type)
Definition: PostgresUpdater.php:882
PostgresUpdater\dropPgField
dropPgField( $table, $field)
Definition: PostgresUpdater.php:870
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
definition
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this definition
Definition: APACHE-LICENSE-2.0.txt:49
PostgresUpdater\checkOiDeleted
checkOiDeleted()
Definition: PostgresUpdater.php:1125
PostgresUpdater\getOldGlobalUpdates
getOldGlobalUpdates()
Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
Definition: PostgresUpdater.php:624
PostgresUpdater\dropPgIndex
dropPgIndex( $table, $index)
Definition: PostgresUpdater.php:1170
$type
$type
Definition: testCompression.php:48