X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FQueryPage.php;h=4440aac3a08d15934cde317c304bbe070f54b669;hb=aab43dd49523476f3ec28c695e43006446a7be7a;hp=bfdfa196ba3308515bda5cd477e9d583c63bdb16;hpb=f9ceae070d629cb5b3399b56552ac34727772505;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/QueryPage.php b/includes/QueryPage.php index bfdfa196ba..4440aac3a0 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -1,8 +1,24 @@ isCacheable() ) { @@ -293,7 +311,7 @@ abstract class QueryPage extends SpecialPage { $res = $this->reallyDoQuery( $limit, false ); $num = false; if ( $res ) { - $num = $dbr->numRows( $res ); + $num = $res->numRows(); # Fetch results $vals = array(); while ( $res && $row = $dbr->fetchObject( $res ) ) { @@ -358,7 +376,7 @@ abstract class QueryPage extends SpecialPage { $options = isset( $query['options'] ) ? (array)$query['options'] : array(); $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : array(); if ( count( $order ) ) { - $options['ORDER BY'] = implode( ', ', $order ); + $options['ORDER BY'] = $order; } if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); @@ -382,6 +400,7 @@ abstract class QueryPage extends SpecialPage { /** * Somewhat deprecated, you probably want to be using execute() + * @return ResultWrapper */ function doQuery( $offset = false, $limit = false ) { if ( $this->isCached() && $this->isCacheable() ) { @@ -435,9 +454,10 @@ abstract class QueryPage extends SpecialPage { /** * This is the actual workhorse. It does everything needed to make a * real, honest-to-gosh query page. + * @return int */ function execute( $par ) { - global $wgQueryCacheLimit; + global $wgQueryCacheLimit, $wgDisableQueryPageUpdate; $user = $this->getUser(); if ( !$this->userCanExecute( $user ) ) { @@ -445,25 +465,23 @@ abstract class QueryPage extends SpecialPage { return; } - if ( $this->limit == 0 && $this->offset == 0 ) { - list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset(); - } - $dbr = wfGetDB( DB_SLAVE ); - $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); - $out->setSyndicated( $this->isSyndicated() ); if ( $this->isCached() && !$this->isCacheable() ) { - $out->setSyndicated( false ); $out->addWikiMsg( 'querypage-disabled' ); return 0; } + $out->setSyndicated( $this->isSyndicated() ); + + if ( $this->limit == 0 && $this->offset == 0 ) { + list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset(); + } + // TODO: Use doQuery() - // $res = null; if ( !$this->isCached() ) { $res = $this->reallyDoQuery( $this->limit, $this->offset ); } else { @@ -481,7 +499,7 @@ abstract class QueryPage extends SpecialPage { $updateddate = $lang->userDate( $ts, $user ); $updatedtime = $lang->userTime( $ts, $user ); $out->addMeta( 'Data-Cache-Time', $ts ); - $out->addInlineScript( "var dataCacheTime = '$ts';" ); + $out->addJsConfigVars( 'dataCacheTime', $ts ); $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults ); } else { $out->addWikiMsg( 'perfcached', $maxResults ); @@ -489,17 +507,15 @@ abstract class QueryPage extends SpecialPage { # If updates on this page have been disabled, let the user know # that the data set won't be refreshed for now - global $wgDisableQueryPageUpdate; if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) { - $out->addWikiMsg( 'querypage-no-updates' ); + $out->wrapWikiMsg( "
\n$1\n
", 'querypage-no-updates' ); } - } - } - $this->numRows = $dbr->numRows( $res ); + $this->numRows = $res->numRows(); + $dbr = wfGetDB( DB_SLAVE ); $this->preprocessResults( $dbr, $res ); $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) ); @@ -625,6 +641,7 @@ abstract class QueryPage extends SpecialPage { /** * Similar to above, but packaging in a syndicated feed instead of a web page + * @return bool */ function doFeed( $class = '', $limit = 50 ) { global $wgFeed, $wgFeedClasses; @@ -664,12 +681,13 @@ abstract class QueryPage extends SpecialPage { /** * Override for custom handling. If the titles/links are ok, just do * feedItemDesc() + * @return FeedItem|null */ function feedResult( $row ) { if ( !isset( $row->title ) ) { return null; } - $title = Title::MakeTitle( intval( $row->namespace ), $row->title ); + $title = Title::makeTitle( intval( $row->namespace ), $row->title ); if ( $title ) { $date = isset( $row->timestamp ) ? $row->timestamp : ''; $comments = ''; @@ -731,6 +749,10 @@ abstract class WantedQueryPage extends QueryPage { * Cache page existence for performance */ function preprocessResults( $db, $res ) { + if ( !$res->numRows() ) { + return; + } + $batch = new LinkBatch; foreach ( $res as $row ) { $batch->add( $row->namespace, $row->title ); @@ -738,9 +760,7 @@ abstract class WantedQueryPage extends QueryPage { $batch->execute(); // Back to start for display - if ( $db->numRows( $res ) > 0 ) - // If there are no rows we get an error seeking. - $db->dataSeek( $res, 0 ); + $res->seek( 0 ); } /** @@ -749,6 +769,7 @@ abstract class WantedQueryPage extends QueryPage { * kluge for Special:WantedFiles, which may contain false * positives for files that exist e.g. in a shared repo (bug * 6220). + * @return bool */ function forceExistenceCheck() { return false;