/**
* Contain a class for special pages
* @file
- * @ingroup SpecialPages
+ * @ingroup SpecialPage
*/
/**
* Setting this to return true will ensure formatResult() is called
* one more time to make sure that the very last result is formatted
* as well.
+ * @return bool
*/
function tryLastResult() {
return false;
*
* @param $limit Integer: limit for SQL statement
* @param $ignoreErrors Boolean: whether to ignore database errors
+ * @return bool|int
*/
function recache( $limit, $ignoreErrors = true ) {
if ( !$this->isCacheable() ) {
$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 ) ) {
/**
* Somewhat deprecated, you probably want to be using execute()
+ * @return ResultWrapper
*/
function doQuery( $offset = false, $limit = false ) {
if ( $this->isCached() && $this->isCacheable() ) {
/**
* 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 ) ) {
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 {
# 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' );
}
-
}
-
}
- $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' ) ) );
/**
* Similar to above, but packaging in a syndicated feed instead of a web page
+ * @return bool
*/
function doFeed( $class = '', $limit = 50 ) {
global $wgFeed, $wgFeedClasses;
/**
* Override for custom handling. If the titles/links are ok, just do
* feedItemDesc()
+ * @return FeedItem|null
*/
function feedResult( $row ) {
if ( !isset( $row->title ) ) {
* 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 );
$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 );
}
/**
* 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;