* @ingroup SpecialPage
*/
+use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
$num = $res->numRows();
# Fetch results
$vals = [];
- foreach ( $res as $row ) {
+ foreach ( $res as $i => $row ) {
if ( isset( $row->value ) ) {
if ( $this->usesTimestamps() ) {
$value = wfTimestamp( TS_UNIX,
$value = intval( $row->value ); // T16414
}
} else {
- $value = 0;
+ $value = $i;
}
$vals[] = [
return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
}
+ /**
+ * Remove a cached result.
+ * Useful for interactive backlogs where the user can fix problems in-place.
+ * @param LinkTarget $title The page to remove.
+ * @since 1.34
+ */
+ public function delete( LinkTarget $title ) {
+ if ( $this->isCached() ) {
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->delete( 'querycache', [
+ 'qc_type' => $this->getName(),
+ 'qc_namespace' => $title->getNamespace(),
+ 'qc_title' => $title->getDBkey(),
+ ], __METHOD__ );
+ }
+ }
+
/**
* Run the query and return the result
* @param int|bool $limit Numerical limit or false for no limit
# an OutputPage, and let them get on with it
$this->outputResults( $out,
$this->getSkin(),
- $dbr, # Should use a ResultWrapper for this
+ $dbr, # Should use IResultWrapper for this
$res,
min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
$this->offset );
}
/**
- * Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include
+ * Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include
* title and optional the namespace field) and executes the batch. This operation will pre-cache
* LinkCache information like page existence and information for stub color and redirect hints.
*
- * @param IResultWrapper $res The ResultWrapper object to process. Needs to include the title
+ * @param IResultWrapper $res The result wrapper to process. Needs to include the title
* field and namespace field, if the $ns parameter isn't set.
- * @param null $ns Use this namespace for the given titles in the ResultWrapper object,
+ * @param null $ns Use this namespace for the given titles in the result wrapper,
* instead of the namespace value of $res.
*/
protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {