diff --git a/src/MediaWiki/Jobs/ParserCachePurgeJob.php b/src/MediaWiki/Jobs/ParserCachePurgeJob.php index 3b7b151a76..b2d0e96f7d 100644 --- a/src/MediaWiki/Jobs/ParserCachePurgeJob.php +++ b/src/MediaWiki/Jobs/ParserCachePurgeJob.php @@ -9,6 +9,7 @@ use SMW\RequestOptions; use SMWQuery as Query; use Title; +use SMW\Utils\Timer; /** * @license GNU GPL v2+ @@ -62,8 +63,11 @@ public function __construct( Title $title, $params = array() ) { */ public function run() { + Timer::start( __METHOD__ ); + $this->pageUpdater = $this->applicationFactory->newPageUpdater(); $this->store = $this->applicationFactory->getStore(); + $logger = $this->applicationFactory->getMediaWikiLogger(); if ( $this->hasParameter( 'limit' ) ) { $this->limit = $this->getParameter( 'limit' ); @@ -76,7 +80,7 @@ public function run() { if ( $this->hasParameter( 'idlist' ) ) { $this->findEmbeddedQueryTargetLinksBatches( $this->getParameter( 'idlist' ), - $this->applicationFactory->getMediaWikiLogger() + $logger ); } @@ -86,6 +90,8 @@ public function run() { Hooks::run( 'SMW::Job::AfterParserCachePurgeComplete', array( $this ) ); + $logger->info( __METHOD__ . ' (procTime in sec: ' . Timer::getElapsedTime( __METHOD__, 7 ) . ')' ); + return true; } @@ -120,22 +126,16 @@ private function findEmbeddedQueryTargetLinksBatches( $idList, $logger ) { // +1 to look ahead $requestOptions->setLimit( $this->limit + 1 ); $requestOptions->setOffset( $this->offset ); + $requestOptions->targetLinksCount = 0; $hashList = $queryDependencyLinksStore->findEmbeddedQueryTargetLinksHashListFrom( $idList, $requestOptions ); - if ( $hashList === array() ) { - return true; - } - - $countedHashListEntries = count( $hashList ); - // If more results are available then use an iterative increase to fetch // the remaining updates by creating successive jobs - if ( $countedHashListEntries > $this->limit ) { - + if ( $requestOptions->targetLinksCount > $this->limit ) { $job = new self( $this->getTitle(), array( 'idlist' => $idList, 'limit' => $this->limit, @@ -145,12 +145,21 @@ private function findEmbeddedQueryTargetLinksBatches( $idList, $logger ) { $job->run(); } - $logger->info( __METHOD__ . " counted: {$countedHashListEntries} | offset: {$this->offset} for " . $this->getTitle()->getPrefixedDBKey() ); + if ( $hashList === array() ) { + return true; + } list( $hashList, $queryList ) = $this->doBuildUniqueTargetLinksHashList( $hashList ); + $logger->info( + __METHOD__ . + " counted: " . count( $hashList ) . + " targetLinksCount: " . $requestOptions->targetLinksCount . + " (offset: {$this->offset} for " . $this->getTitle()->getPrefixedDBKey() . ")" + ); + $this->applicationFactory->singleton( 'CachedQueryResultPrefetcher' )->resetCacheBy( $queryList, 'ParserCachePurgeJob' diff --git a/src/SQLStore/QueryDependency/QueryDependencyLinksStore.php b/src/SQLStore/QueryDependency/QueryDependencyLinksStore.php index 5bfd0093d0..a4f83f50e9 100644 --- a/src/SQLStore/QueryDependency/QueryDependencyLinksStore.php +++ b/src/SQLStore/QueryDependency/QueryDependencyLinksStore.php @@ -306,16 +306,19 @@ public function findEmbeddedQueryTargetLinksHashListFrom( array $idlist, Request return array(); } - $requestOptions = new RequestOptions(); + // Return the expected count of targets + $requestOptions->targetLinksCount = count( $targetLinksIdList ); - $requestOptions->addExtraCondition( + $poolRequestOptions = new RequestOptions(); + + $poolRequestOptions->addExtraCondition( 'smw_iw !=' . $this->connection->addQuotes( SMW_SQL3_SMWREDIIW ) . ' AND '. 'smw_iw !=' . $this->connection->addQuotes( SMW_SQL3_SMWDELETEIW ) ); return $this->store->getObjectIds()->getDataItemPoolHashListFor( $targetLinksIdList, - $requestOptions + $poolRequestOptions ); }