blob: 26ecfa8a7bfbe050e50b8257ddb29c20b14137f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<?php
namespace SMW\MediaWiki\Hooks;
use SMW\ApplicationFactory;
use SMW\DIProperty;
use SMW\DIWikiPage;
use SMW\EventHandler;
use WikiPage;
/**
* A function hook being executed before running "&action=purge"
*
* A temporary cache entry is created to mark and identify the
* Article that has been purged.
*
* @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge
*
* @license GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
class ArticlePurge {
/**
* @since 1.9
*
* @return true
*/
public function process( WikiPage &$wikiPage ) {
$applicationFactory = ApplicationFactory::getInstance();
$pageId = $wikiPage->getTitle()->getArticleID();
$settings = $applicationFactory->getSettings();
$cache = $applicationFactory->getCache();
$cacheFactory = $applicationFactory->newCacheFactory();
if ( $pageId > 0 ) {
$cache->save(
$cacheFactory->getPurgeCacheKey( $pageId ),
$settings->get( 'smwgAutoRefreshOnPurge' )
);
}
$dispatchContext = EventHandler::getInstance()->newDispatchContext();
$dispatchContext->set( 'title', $wikiPage->getTitle() );
$dispatchContext->set( 'context', 'ArticlePurge' );
if ( $settings->isFlagSet( 'smwgFactboxFeatures', SMW_FACTBOX_PURGE_REFRESH ) ) {
EventHandler::getInstance()->getEventDispatcher()->dispatch(
'factbox.cache.delete',
$dispatchContext
);
}
if ( $settings->get( 'smwgQueryResultCacheRefreshOnPurge' ) ) {
$dispatchContext->set( 'ask', $applicationFactory->getStore()->getPropertyValues(
DIWikiPage::newFromTitle( $wikiPage->getTitle() ),
new DIProperty( '_ASK') )
);
EventHandler::getInstance()->getEventDispatcher()->dispatch(
'cached.prefetcher.reset',
$dispatchContext
);
}
return true;
}
}
|