r32084 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32083‎ | r32084 | r32085 >
Date:00:06, 18 March 2008
Author:simetrical
Status:old
Tags:
Comment:
Add updatelog table to reliably permit updates that don't change the schema. A fairly trivial patch. It isn't used at all currently (it will be in a minute!), and presumably won't ever be used outside of update.php, so it can be ignored for Wikimedia despite being a schema change.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-updatelog.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-updatelog.sql
@@ -0,0 +1,4 @@
 2+CREATE TABLE /*$wgDBprefix*/updatelog (
 3+ ul_key varchar(255) NOT NULL,
 4+ PRIMARY KEY (ul_key)
 5+) /*$wgDBTableOptions*/;
Property changes on: trunk/phase3/maintenance/archives/patch-updatelog.sql
___________________________________________________________________
Added: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/updaters.inc
@@ -132,6 +132,7 @@
133133 // 1.13
134134 array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ),
135135 array( 'add_table', 'page_props', 'patch-page_props.sql' ),
 136+ array( 'add_table', 'updatelog', 'patch-updatelog.sql' ),
136137 );
137138
138139
@@ -142,6 +143,20 @@
143144 $wgExtPGNewFields = array(); // table, column attributes; for PostgreSQL
144145 $wgExtNewIndexes = array(); // table, index, dir
145146
 147+# Helper function: check if the given key is present in the updatelog table.
 148+# Obviously, only use this for updates that occur after the updatelog table was
 149+# created!
 150+function update_row_exists( $key ) {
 151+ $dbr = wfGetDB( DB_SLAVE );
 152+ $row = $dbr->selectRow(
 153+ 'updatelog',
 154+ '1',
 155+ array( 'ul_key' => $key ),
 156+ __FUNCTION__
 157+ );
 158+ return (bool)$row;
 159+}
 160+
146161 function rename_table( $from, $to, $patch ) {
147162 global $wgDatabase;
148163 if ( $wgDatabase->tableExists( $from ) ) {
@@ -1118,7 +1133,6 @@
11191134 }
11201135 print "ok\n";
11211136 }
1122 -
11231137 }
11241138
11251139 function
Index: trunk/phase3/maintenance/tables.sql
@@ -1193,4 +1193,10 @@
11941194 PRIMARY KEY (pp_page,pp_propname)
11951195 ) /*$wgDBTableOptions*/;
11961196
 1197+-- A table to log updates, one text key row per update.
 1198+CREATE TABLE /*$wgDBprefix*/updatelog (
 1199+ ul_key varchar(255) NOT NULL,
 1200+ PRIMARY KEY (ul_key)
 1201+) /*$wgDBTableOptions*/;
 1202+
11971203 -- vim: sw=2 sts=2 et
Index: trunk/phase3/RELEASE-NOTES
@@ -45,6 +45,7 @@
4646 * (bug 12882) Added a span with class "patrollink" arround "Mark as patrolled"
4747 link on diffs
4848 * Magic word formatnum can now take raw suffix to undo formatting
 49+* Add updatelog table to reliably permit updates that don't change the schema
4950
5051 === Bug fixes in 1.13 ===
5152

Status & tagging log