r13683 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13682‎ | r13683 | r13684 >
Date:04:30, 17 April 2006
Author:robchurch
Status:old
Tags:
Comment:
(bug 4327) Report age of cached data sets in query pages
[Schema change]
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/QueryPage.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-querycacheinfo.sql (added) (history)
  • /trunk/phase3/maintenance/mysql5/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-querycacheinfo.sql
@@ -0,0 +1,12 @@
 2+CREATE TABLE /*$wgDBprefix*/querycache_info (
 3+
 4+ -- Special page name
 5+ -- Corresponds to a qc_type value
 6+ qci_type varchar(255) NOT NULL default '',
 7+
 8+ -- Timestamp of last update
 9+ qci_timestamp char(14) NOT NULL default '19700101000000',
 10+
 11+ UNIQUE KEY ( qci_type )
 12+
 13+) TYPE=InnoDB;
\ No newline at end of file
Index: trunk/phase3/maintenance/mysql5/tables.sql
@@ -954,3 +954,17 @@
955955 PRIMARY KEY job_id (job_id),
956956 KEY (job_cmd, job_namespace, job_title)
957957 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
 958+
 959+-- Details of updates to cached special pages
 960+CREATE TABLE /*$wgDBprefix*/querycache_info (
 961+
 962+ -- Special page name
 963+ -- Corresponds to a qc_type value
 964+ qci_type varchar(255) NOT NULL default '',
 965+
 966+ -- Timestamp of last update
 967+ qci_timestamp char(14) NOT NULL default '19700101000000',
 968+
 969+ UNIQUE KEY ( qci_type )
 970+
 971+) TYPE=InnoDB;
\ No newline at end of file
Index: trunk/phase3/maintenance/updaters.inc
@@ -29,6 +29,7 @@
3030 array( 'externallinks', 'patch-externallinks.sql' ),
3131 array( 'job', 'patch-job.sql' ),
3232 array( 'langlinks', 'patch-langlinks.sql' ),
 33+ array( 'querycache_info', 'patch-querycacheinfo.sql' ),
3334 );
3435
3536 $wgNewFields = array(
Index: trunk/phase3/maintenance/tables.sql
@@ -943,3 +943,18 @@
944944 PRIMARY KEY job_id (job_id),
945945 KEY (job_cmd, job_namespace, job_title)
946946 ) TYPE=InnoDB;
 947+
 948+
 949+-- Details of updates to cached special pages
 950+CREATE TABLE /*$wgDBprefix*/querycache_info (
 951+
 952+ -- Special page name
 953+ -- Corresponds to a qc_type value
 954+ qci_type varchar(255) NOT NULL default '',
 955+
 956+ -- Timestamp of last update
 957+ qci_timestamp char(14) NOT NULL default '19700101000000',
 958+
 959+ UNIQUE KEY ( qci_type )
 960+
 961+) TYPE=InnoDB;
\ No newline at end of file
Index: trunk/phase3/includes/QueryPage.php
@@ -243,6 +243,11 @@
244244 $dbw->ignoreErrors( $ignoreW );
245245 $dbr->ignoreErrors( $ignoreR );
246246 }
 247+
 248+ # Update the querycache_info record for the page
 249+ $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
 250+ $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
 251+
247252 }
248253 return $num;
249254 }
@@ -256,7 +261,7 @@
257262 * @param $shownavigation show navigation like "next 200"?
258263 */
259264 function doQuery( $offset, $limit, $shownavigation=true ) {
260 - global $wgUser, $wgOut, $wgContLang;
 265+ global $wgUser, $wgOut, $wgLang, $wgContLang;
261266
262267 $sname = $this->getName();
263268 $fname = get_class($this) . '::doQuery';
@@ -271,8 +276,16 @@
272277 $sql =
273278 "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
274279 FROM $querycache WHERE qc_type='$type'";
 280+
 281+ # Fetch the timestamp of this update
 282+ $tRes = $dbr->select( 'querycache_info', array( 'qci_timestamp' ), array( 'qci_type' => $type ), $fname );
 283+ $tRow = $dbr->fetchObject( $tRes );
 284+ $updated = $tRow->qci_timestamp;
 285+ $updatedTs = $wgLang->timeAndDate( $updated, true, true );
 286+
275287 if ( ! $this->listoutput )
276 - $wgOut->addWikiText( wfMsg( 'perfcached' ) );
 288+ $wgOut->addWikiText( wfMsg( 'perfcached', $updatedTs ) );
 289+
277290 }
278291
279292 $sql .= $this->getOrder();
Index: trunk/phase3/RELEASE-NOTES
@@ -81,6 +81,7 @@
8282 * (bug 5570) Problems using <special page>/parameter link form for long titles
8383 * (bug 3884) Add $user parameter to AddNewUser hook, call it for by-email
8484 registrations as well as self-registrations.
 85+* (bug 4327) Report age of cached data sets in query pages
8586
8687
8788 == Compatibility ==

Status & tagging log