From: Gergő Tisza Date: Fri, 26 Jul 2019 14:47:09 +0000 (+0200) Subject: Add QueryPage::delete method X-Git-Tag: 1.34.0-rc.0~830^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=767fdb56cf0d660c63a2ddaf072eb00943165dfb;p=lhc%2Fweb%2Fwiklou.git Add QueryPage::delete method Add a method for delete the cached result for a page. This is useful for backlog-type query pages which provide some interface for fixing the problem in-place. Change-Id: I36b750d71b6551bb5c662e82c24f029db01acd3b --- diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index eb179bf310..1977af0821 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -21,6 +21,7 @@ * @ingroup SpecialPage */ +use MediaWiki\Linker\LinkTarget; use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\IDatabase; @@ -375,6 +376,23 @@ abstract class QueryPage extends SpecialPage { 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