From: Roan Kattouw Date: Wed, 22 Dec 2010 20:31:32 +0000 (+0000) Subject: Refactor the retrieval of the cache timestamp into getCachedTimestamp() so the future... X-Git-Tag: 1.31.0-rc.0~33175 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=e479611a0aa8cead30acefb0ebbd39dc19b93aa9;p=lhc%2Fweb%2Fwiklou.git Refactor the retrieval of the cache timestamp into getCachedTimestamp() so the future API module can use it --- diff --git a/includes/QueryPage.php b/includes/QueryPage.php index f0efce0c06..19a0d53ea8 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -414,6 +414,12 @@ abstract class QueryPage extends SpecialPage { ); return $dbr->resultObject( $res ); } + + public function getCachedTimestamp() { + $dbr = wfGetDB( DB_SLAVE ); + $fname = get_class( $this ) . '::getCachedTimestamp'; + return $dbr->selectField( 'querycache_info', 'qci_timestamp', array( 'qci_type' => $this->getName() ), $fname ); + } /** * This is the actual workhorse. It does everything needed to make a @@ -429,8 +435,6 @@ abstract class QueryPage extends SpecialPage { if ( $this->limit == 0 && $this->offset == 0 ) list( $this->limit, $this->offset ) = wfCheckLimits(); - $sname = $this->getName(); - $fname = get_class( $this ) . '::doQuery'; $dbr = wfGetDB( DB_SLAVE ); $this->setHeaders(); @@ -452,15 +456,14 @@ abstract class QueryPage extends SpecialPage { if ( !$this->listoutput ) { # Fetch the timestamp of this update - $tRes = $dbr->select( 'querycache_info', array( 'qci_timestamp' ), array( 'qci_type' => $sname ), $fname ); - $tRow = $dbr->fetchObject( $tRes ); - - if ( $tRow ) { - $updated = $wgLang->timeanddate( $tRow->qci_timestamp, true, true ); - $updateddate = $wgLang->date( $tRow->qci_timestamp, true, true ); - $updatedtime = $wgLang->time( $tRow->qci_timestamp, true, true ); - $wgOut->addMeta( 'Data-Cache-Time', $tRow->qci_timestamp ); - $wgOut->addInlineScript( "var dataCacheTime = '{$tRow->qci_timestamp}';" ); + $ts = $this->getCachedTimestamp(); + + if ( $ts ) { + $updated = $wgLang->timeanddate( $ts, true, true ); + $updateddate = $wgLang->date( $ts, true, true ); + $updatedtime = $wgLang->time( $ts, true, true ); + $wgOut->addMeta( 'Data-Cache-Time', $ts ); + $wgOut->addInlineScript( "var dataCacheTime = '$ts';" ); $wgOut->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime ); } else { $wgOut->addWikiMsg( 'perfcached' );