From 2cda98321d7f03d4d17a545aef9e2e6599ada42f Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 17 Apr 2006 04:30:39 +0000 Subject: [PATCH] (bug 4327) Report age of cached data sets in query pages [Schema change] --- RELEASE-NOTES | 1 + includes/QueryPage.php | 17 +++++++++++++++-- maintenance/archives/patch-querycacheinfo.sql | 12 ++++++++++++ maintenance/mysql5/tables.sql | 14 ++++++++++++++ maintenance/tables.sql | 15 +++++++++++++++ maintenance/updaters.inc | 1 + 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 maintenance/archives/patch-querycacheinfo.sql diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 16242b3314..ac345e92a6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -81,6 +81,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5570) Problems using /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 == diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 1d354d95fe..600c12908e 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -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 index 0000000000..0f807d81e9 --- /dev/null +++ b/maintenance/archives/patch-querycacheinfo.sql @@ -0,0 +1,12 @@ +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 diff --git a/maintenance/mysql5/tables.sql b/maintenance/mysql5/tables.sql index 3a9a1b2c2b..95c3ddc1d1 100644 --- a/maintenance/mysql5/tables.sql +++ b/maintenance/mysql5/tables.sql @@ -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 diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 77ca26d17d..5b23f3576e 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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 diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index ec16062e88..fc0bac67a7 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -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( -- 2.20.1