r59869 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59868‎ | r59869 | r59870 >
Date:02:26, 9 December 2009
Author:overlordq
Status:ok (Comments)
Tags:
Comment:
Followup to r59818, change transcache timestamp field to be consistent with other timestamp fields, requires schema change
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-tc-timestamp.sql (added) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-tc-timestamp.sql
@@ -0,0 +1,4 @@
 2+ALTER TABLE /*_*/transcache MODIFY tc_time varchar(14);
 3+UPDATE /*_*/transcache SET tc_time = DATE_FORMAT(FROM_UNIXTIME(tc_time), "%Y%c%d%H%i%s");
 4+
 5+INSERT INTO /*_*/updatelog VALUES ('convert transcache field');
Property changes on: trunk/phase3/maintenance/archives/patch-tc-timestamp.sql
___________________________________________________________________
Name: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/updaters.inc
@@ -192,7 +192,8 @@
193193 array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
194194 array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
195195 array( 'add_field', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
196 -
 196+ array( 'do_update_transcache_field' ),
 197+
197198 // version-independent searchindex setup, added in 1.16
198199 array( 'sqlite_setup_searchindex' ),
199200 ),
@@ -1342,6 +1343,18 @@
13431344 wfOut( "ok\n" );
13441345 }
13451346
 1347+function do_update_transcache_field() {
 1348+ global $wgDatabase;
 1349+ if( update_row_exists( 'convert transcache field' ) ) {
 1350+ wfOut( "...transcache tc_time already converted.\n" );
 1351+ return;
 1352+ } else {
 1353+ wfOut( "Converting tc_time from int(11) to varchar(13)... " );
 1354+ $wgDatabase->sourceFile( archive( 'patch-tc-timestamp.sql' ) );
 1355+ wfOut( "ok\n" );
 1356+ }
 1357+}
 1358+
13461359 /***********************************************************************
13471360 * Start PG stuff
13481361 * TODO: merge with above
Index: trunk/phase3/includes/parser/Parser.php
@@ -3172,14 +3172,11 @@
31733173 function fetchScaryTemplateMaybeFromCache($url) {
31743174 global $wgTranscludeCacheExpiry;
31753175 $dbr = wfGetDB(DB_SLAVE);
 3176+ $tsCond = $dbr->timestamp( time() - $wgTranscludeCacheExpiry );
31763177 $obj = $dbr->selectRow('transcache', array('tc_time', 'tc_contents'),
3177 - array('tc_url' => $url));
 3178+ array('tc_url' => $url, "tc_time >= " . $dbr->addQuotes( $tsCond ) ) );
31783179 if ($obj) {
3179 - $time = $obj->tc_time;
3180 - $text = $obj->tc_contents;
3181 - if ($time && time() < $time + $wgTranscludeCacheExpiry ) {
3182 - return $text;
3183 - }
 3180+ return $obj->tc_contents;
31843181 }
31853182
31863183 $text = Http::get($url);

Follow-up revisions

RevisionCommit summaryAuthorDate
r59925Followup to r59869, add to MySQL section, and copy patch to SQLite directoryoverlordq05:39, 10 December 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59818Fix Parser transcache to correctly format timestampsoverlordq02:01, 8 December 2009

Comments

#Comment by Raymond (talk | contribs)   22:04, 9 December 2009

'do_update_transcache_field' was added to the 'sqlite' section only. Isn't it necessary for MySQL?

#Comment by OverlordQ (talk | contribs)   05:27, 10 December 2009
  • facepalm* yea, I added it to the wrong section.
#Comment by Tim Starling (talk | contribs)   23:26, 25 March 2010

The transcache tables on Wikimedia are empty so this patch will run without modification.

Status & tagging log