*
* @since 1.22
* @param Title $title Title to clear cache for
+ * @param int|null $revid Revision id to clear
*/
- public static function invalidateCache( Title $title ) {
+ public static function invalidateCache( Title $title, $revid = null ) {
$cache = ObjectCache::getMainWANInstance();
- $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST );
- if ( $revision !== null ) {
- $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revision->getId() );
+ if ( !$revid ) {
+ $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST );
+ $revid = $revision ? $revision->getId() : null;
+ }
+ if ( $revid !== null ) {
+ $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revid );
$cache->delete( $key );
}
}
if ( $options['created'] ) {
self::onArticleCreate( $this->mTitle );
} elseif ( $options['changed'] ) { // bug 50785
- self::onArticleEdit( $this->mTitle );
+ self::onArticleEdit( $this->mTitle, $revision );
}
}
* Purge caches on page update etc
*
* @param Title $title
+ * @param Revision|null $revision Revision that was just saved, may be null
*/
- public static function onArticleEdit( Title $title ) {
+ public static function onArticleEdit( Title $title, Revision $revision = null ) {
// Invalidate caches of articles which include this page
DeferredUpdates::addHTMLCacheUpdate( $title, 'templatelinks' );
// Purge squid for this page only
$title->purgeSquid();
+ $revid = $revision ? $revision->getId() : null;
// Clear file cache for this page only
HTMLFileCache::clearFileCache( $title );
- DeferredUpdates::addCallableUpdate( function() use ( $title ) {
- InfoAction::invalidateCache( $title );
+ DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) {
+ InfoAction::invalidateCache( $title, $revid );
} );
}