(bug 4327) Report age of cached data sets in query pages
authorRob Church <robchurch@users.mediawiki.org>
Mon, 17 Apr 2006 04:30:39 +0000 (04:30 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 17 Apr 2006 04:30:39 +0000 (04:30 +0000)
[Schema change]

RELEASE-NOTES
includes/QueryPage.php
maintenance/archives/patch-querycacheinfo.sql [new file with mode: 0644]
maintenance/mysql5/tables.sql
maintenance/tables.sql
maintenance/updaters.inc

index 16242b3..ac345e9 100644 (file)
@@ -81,6 +81,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 5570) Problems using <special page>/parameter link form for long titles
 * (bug 3884) Add $user parameter to AddNewUser hook, call it for by-email 
   registrations as well as self-registrations.
+* (bug 4327) Report age of cached data sets in query pages
 
 
 == Compatibility ==
index 1d354d9..600c129 100644 (file)
@@ -243,6 +243,11 @@ class QueryPage {
                                $dbw->ignoreErrors( $ignoreW );
                                $dbr->ignoreErrors( $ignoreR );
                        }
+
+                       # Update the querycache_info record for the page
+                       $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
+                       $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
+
                }
                return $num;
        }
@@ -256,7 +261,7 @@ class QueryPage {
         * @param $shownavigation show navigation like "next 200"?
         */
        function doQuery( $offset, $limit, $shownavigation=true ) {
-               global $wgUser, $wgOut, $wgContLang;
+               global $wgUser, $wgOut, $wgLang, $wgContLang;
 
                $sname = $this->getName();
                $fname = get_class($this) . '::doQuery';
@@ -271,8 +276,16 @@ class QueryPage {
                        $sql =
                                "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
                                 FROM $querycache WHERE qc_type='$type'";
+
+                       # Fetch the timestamp of this update
+                       $tRes = $dbr->select( 'querycache_info', array( 'qci_timestamp' ), array( 'qci_type' => $type ), $fname );
+                       $tRow = $dbr->fetchObject( $tRes );
+                       $updated = $tRow->qci_timestamp;
+                       $updatedTs = $wgLang->timeAndDate( $updated, true, true );
+
                        if ( ! $this->listoutput )
-                               $wgOut->addWikiText( wfMsg( 'perfcached' ) );
+                               $wgOut->addWikiText( wfMsg( 'perfcached', $updatedTs ) );
+
                }
 
                $sql .= $this->getOrder();
diff --git a/maintenance/archives/patch-querycacheinfo.sql b/maintenance/archives/patch-querycacheinfo.sql
new file mode 100644 (file)
index 0000000..0f807d8
--- /dev/null
@@ -0,0 +1,12 @@
+CREATE TABLE /*$wgDBprefix*/querycache_info (\r
+\r
+       -- Special page name\r
+       -- Corresponds to a qc_type value\r
+       qci_type varchar(255) NOT NULL default '',\r
+\r
+       -- Timestamp of last update\r
+       qci_timestamp char(14) NOT NULL default '19700101000000',\r
+\r
+       UNIQUE KEY ( qci_type )\r
+\r
+) TYPE=InnoDB;
\ No newline at end of file
index 3a9a1b2..95c3ddc 100644 (file)
@@ -954,3 +954,17 @@ CREATE TABLE /*$wgDBprefix*/job (
   PRIMARY KEY job_id (job_id),
   KEY (job_cmd, job_namespace, job_title)
 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
+
+-- Details of updates to cached special pages
+CREATE TABLE /*$wgDBprefix*/querycache_info (
+
+       -- Special page name
+       -- Corresponds to a qc_type value
+       qci_type varchar(255) NOT NULL default '',
+
+       -- Timestamp of last update
+       qci_timestamp char(14) NOT NULL default '19700101000000',
+
+       UNIQUE KEY ( qci_type )
+
+) TYPE=InnoDB;
\ No newline at end of file
index 77ca26d..5b23f35 100644 (file)
@@ -943,3 +943,18 @@ CREATE TABLE /*$wgDBprefix*/job (
   PRIMARY KEY job_id (job_id),
   KEY (job_cmd, job_namespace, job_title)
 ) TYPE=InnoDB;
+
+
+-- Details of updates to cached special pages
+CREATE TABLE /*$wgDBprefix*/querycache_info (
+
+       -- Special page name
+       -- Corresponds to a qc_type value
+       qci_type varchar(255) NOT NULL default '',
+
+       -- Timestamp of last update
+       qci_timestamp char(14) NOT NULL default '19700101000000',
+
+       UNIQUE KEY ( qci_type )
+
+) TYPE=InnoDB;
\ No newline at end of file
index ec16062..fc0bac6 100644 (file)
@@ -29,6 +29,7 @@ $wgNewTables = array(
        array( 'externallinks', 'patch-externallinks.sql' ),
        array( 'job',           'patch-job.sql' ),
        array( 'langlinks',     'patch-langlinks.sql' ),
+       array( 'querycache_info', 'patch-querycacheinfo.sql' ),
 );
 
 $wgNewFields = array(