MediaWiki  1.28.0
MssqlUpdater.php
Go to the documentation of this file.
1 <?php
32 
36  protected $db;
37 
38  protected function getCoreUpdateList() {
39  return [
40  // 1.23
41  [ 'addField', 'mwuser', 'user_password_expires', 'patch-user_password_expires.sql' ],
42 
43  // 1.24
44  [ 'addField', 'page', 'page_lang', 'patch-page_page_lang.sql' ],
45 
46  // 1.25
47  [ 'dropTable', 'hitcounter' ],
48  [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
49  [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
50  // scripts were updated in 1.27 due to SQL errors; retaining old updatekeys so that people
51  // updating from 1.23->1.25->1.27 do not execute these scripts twice even though the
52  // updatekeys no longer make sense as they are.
53  [ 'updateSchema', 'categorylinks', 'cl_type-category_types-ck',
54  'patch-categorylinks-constraints.sql' ],
55  [ 'updateSchema', 'filearchive', 'fa_major_mime-major_mime-ck',
56  'patch-filearchive-constraints.sql' ],
57  [ 'updateSchema', 'oldimage', 'oi_major_mime-major_mime-ck',
58  'patch-oldimage-constraints.sql' ],
59  [ 'updateSchema', 'image', 'img_major_mime-major_mime-ck', 'patch-image-constraints.sql' ],
60  [ 'updateSchema', 'uploadstash', 'us_media_type-media_type-ck',
61  'patch-uploadstash-constraints.sql' ],
62 
63  [ 'modifyField', 'image', 'img_major_mime',
64  'patch-img_major_mime-chemical.sql' ],
65  [ 'modifyField', 'oldimage', 'oi_major_mime',
66  'patch-oi_major_mime-chemical.sql' ],
67  [ 'modifyField', 'filearchive', 'fa_major_mime',
68  'patch-fa_major_mime-chemical.sql' ],
69 
70  // 1.27
71  [ 'dropTable', 'msg_resource_links' ],
72  [ 'dropTable', 'msg_resource' ],
73  [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
74  [ 'dropField', 'mwuser', 'user_options', 'patch-drop-user_options.sql' ],
75  [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
76  [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
77  [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
78  [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
79  [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
80  [ 'addIndex', 'categorylinks', 'cl_collation_ext',
81  'patch-add-cl_collation_ext_index.sql' ],
82  [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
83  [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
84  [ 'updateSchema', 'oldimage', 'oldimage varchar', 'patch-oldimage-schema.sql' ],
85  [ 'updateSchema', 'filearchive', 'filearchive varchar', 'patch-filearchive-schema.sql' ],
86  [ 'updateSchema', 'image', 'image varchar', 'patch-image-schema.sql' ],
87  [ 'updateSchema', 'recentchanges', 'recentchanges-drop-fks',
88  'patch-recentchanges-drop-fks.sql' ],
89  [ 'updateSchema', 'logging', 'logging-drop-fks', 'patch-logging-drop-fks.sql' ],
90  [ 'updateSchema', 'archive', 'archive-drop-fks', 'patch-archive-drop-fks.sql' ],
91 
92  // 1.28
93  [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
94  'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
95  [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
96  [ 'addField', 'tag_summary', 'ts_id', 'patch-tag_summary-ts_id.sql' ],
97  ];
98  }
99 
100  protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
101  $prevScroll = $this->db->scrollableCursor( false );
102  $prevPrep = $this->db->prepareStatements( false );
103  parent::applyPatch( $path, $isFullPath, $msg );
104  $this->db->scrollableCursor( $prevScroll );
105  $this->db->prepareStatements( $prevPrep );
106  }
107 
117  protected function updateSchema( $table, $updatekey, $patch, $fullpath = false ) {
118  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
119  $this->output( "...$table table does not exist, skipping schema update patch.\n" );
120  } elseif ( $this->updateRowExists( $updatekey ) ) {
121  $this->output( "...$table already had schema updated by $patch.\n" );
122  } else {
123  $this->insertUpdateRow( $updatekey );
124 
125  return $this->applyPatch( $patch, $fullpath, "Updating schema of table $table" );
126  }
127 
128  return true;
129  }
130 }
Class for handling database updates.
output($str)
Output some text.
applyPatch($path, $isFullPath=false, $msg=null)
insertUpdateRow($key, $val=null)
Helper function: Add a key to the updatelog table Obviously, only use this for updates that occur aft...
updateSchema($table, $updatekey, $patch, $fullpath=false)
General schema update for a table that touches more than one field or requires destructive actions (s...
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
updateRowExists($key)
Helper function: check if the given key is present in the updatelog table.
Class for setting up the MediaWiki database using Microsoft SQL Server.
DatabaseMssql $db