Index: trunk/phase3/includes/Article.php |
— | — | @@ -3164,7 +3164,7 @@ |
3165 | 3165 | } |
3166 | 3166 | |
3167 | 3167 | public static function onArticleDelete( $title ) { |
3168 | | - global $wgUseFileCache, $wgMessageCache; |
| 3168 | + global $wgMessageCache; |
3169 | 3169 | # Update existence markers on article/talk tabs... |
3170 | 3170 | if( $title->isTalkPage() ) { |
3171 | 3171 | $other = $title->getSubjectPage(); |
— | — | @@ -3178,10 +3178,7 @@ |
3179 | 3179 | $title->purgeSquid(); |
3180 | 3180 | |
3181 | 3181 | # File cache |
3182 | | - if( $wgUseFileCache ) { |
3183 | | - $cm = new HTMLFileCache( $title ); |
3184 | | - @unlink( $cm->fileCacheName() ); |
3185 | | - } |
| 3182 | + HTMLFileCache::clearFileCache( $title ); |
3186 | 3183 | |
3187 | 3184 | # Messages |
3188 | 3185 | if( $title->getNamespace() == NS_MEDIAWIKI ) { |
— | — | @@ -3203,7 +3200,7 @@ |
3204 | 3201 | * Purge caches on page update etc |
3205 | 3202 | */ |
3206 | 3203 | public static function onArticleEdit( $title, $transclusions = 'transclusions' ) { |
3207 | | - global $wgDeferredUpdateList, $wgUseFileCache; |
| 3204 | + global $wgDeferredUpdateList; |
3208 | 3205 | |
3209 | 3206 | // Invalidate caches of articles which include this page |
3210 | 3207 | if( $transclusions !== 'skiptransclusions' ) |
— | — | @@ -3216,10 +3213,7 @@ |
3217 | 3214 | $title->purgeSquid(); |
3218 | 3215 | |
3219 | 3216 | # Clear file cache for this page only |
3220 | | - if( $wgUseFileCache ) { |
3221 | | - $cm = new HTMLFileCache( $title ); |
3222 | | - @unlink( $cm->fileCacheName() ); |
3223 | | - } |
| 3217 | + HTMLFileCache::clearFileCache( $title ); |
3224 | 3218 | } |
3225 | 3219 | |
3226 | 3220 | /**#@-*/ |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1954,7 +1954,6 @@ |
1955 | 1955 | * @return \type{\bool} true if the update succeded |
1956 | 1956 | */ |
1957 | 1957 | public function invalidateCache() { |
1958 | | - global $wgUseFileCache; |
1959 | 1958 | if( wfReadOnly() ) { |
1960 | 1959 | return; |
1961 | 1960 | } |
— | — | @@ -1964,10 +1963,7 @@ |
1965 | 1964 | $this->pageCond(), |
1966 | 1965 | __METHOD__ |
1967 | 1966 | ); |
1968 | | - if( $wgUseFileCache) { |
1969 | | - $cache = new HTMLFileCache( $this ); |
1970 | | - @unlink( $cache->fileCacheName() ); |
1971 | | - } |
| 1967 | + HTMLFileCache::clearFileCache( $this ); |
1972 | 1968 | return $success; |
1973 | 1969 | } |
1974 | 1970 | |
Index: trunk/phase3/includes/RawPage.php |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage ); |
153 | 153 | |
154 | 154 | if( HTMLFileCache::useFileCache() ) { |
155 | | - $cache = new HTMLFileCache( $this->mTitle ); |
| 155 | + $cache = new HTMLFileCache( $this->mTitle, 'raw' ); |
156 | 156 | if( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
157 | 157 | /* Check incoming headers to see if client has this cached */ |
158 | 158 | if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) { |
Index: trunk/phase3/includes/HTMLFileCache.php |
— | — | @@ -20,22 +20,23 @@ |
21 | 21 | * @ingroup Cache |
22 | 22 | */ |
23 | 23 | class HTMLFileCache { |
24 | | - var $mTitle, $mFileCache; |
| 24 | + var $mTitle, $mFileCache, $mType; |
25 | 25 | |
26 | | - public function __construct( &$title ) { |
| 26 | + public function __construct( &$title, $type = 'view' ) { |
27 | 27 | $this->mTitle = $title; |
28 | | - $this->mFileCache = $this->fileCacheName(); |
| 28 | + $this->mType = ($type == 'raw' || $type == 'view' ) ? $type : false; |
| 29 | + $this->fileCacheName(); // init name |
29 | 30 | } |
30 | 31 | |
31 | 32 | public function fileCacheName() { |
32 | 33 | if( !$this->mFileCache ) { |
33 | 34 | global $wgFileCacheDirectory, $wgRequest; |
| 35 | + # Store raw pages (like CSS hits) elsewhere |
| 36 | + $subdir = ($this->mType === 'raw') ? 'raw/' : ''; |
34 | 37 | $key = $this->mTitle->getPrefixedDbkey(); |
35 | 38 | $hash = md5( $key ); |
36 | 39 | # Avoid extension confusion |
37 | 40 | $key = str_replace( '.', '%2E', urlencode( $key ) ); |
38 | | - # Store raw pages (like CSS hits) elsewhere |
39 | | - $subdir = $wgRequest->getVal('action') == 'raw' ? 'raw/' : ''; |
40 | 41 | |
41 | 42 | $hash1 = substr( $hash, 0, 1 ); |
42 | 43 | $hash2 = substr( $hash, 0, 2 ); |
— | — | @@ -50,6 +51,7 @@ |
51 | 52 | } |
52 | 53 | |
53 | 54 | public function isFileCached() { |
| 55 | + if( $this->mType === false ) return false; |
54 | 56 | return file_exists( $this->fileCacheName() ); |
55 | 57 | } |
56 | 58 | |
— | — | @@ -70,11 +72,13 @@ |
71 | 73 | if( $query == 'title' || $query == 'curid' ) continue; |
72 | 74 | // Normal page view in query form can have action=view. |
73 | 75 | // Raw hits for pages also stored, like .css pages for example. |
74 | | - if( $query == 'action' && ($val == 'view' || $val == 'raw') ) continue; |
75 | | - if( $query == 'usemsgcache' && $val == 'yes' ) continue; |
| 76 | + else if( $query == 'action' && ($val == 'view' || $val == 'raw') ) continue; |
| 77 | + else if( $query == 'usemsgcache' && $val == 'yes' ) continue; |
76 | 78 | // Below are header setting params |
77 | | - if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' ) |
| 79 | + else if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' ) |
78 | 80 | continue; |
| 81 | + else |
| 82 | + return false; |
79 | 83 | } |
80 | 84 | // Check for non-standard user language; this covers uselang, |
81 | 85 | // and extensions for auto-detecting user language. |
— | — | @@ -193,4 +197,13 @@ |
194 | 198 | return $text; |
195 | 199 | } |
196 | 200 | |
| 201 | + public static function clearFileCache( $title ) { |
| 202 | + global $wgUseFileCache; |
| 203 | + if( !$wgUseFileCache ) return false; |
| 204 | + $fc = new self( $title, '' ); |
| 205 | + @unlink( $fc->fileCacheName() ); |
| 206 | + $fc = new self( $title, 'raw' ); |
| 207 | + @unlink( $fc->fileCacheName() ); |
| 208 | + return true; |
| 209 | + } |
197 | 210 | } |
Index: trunk/phase3/includes/HTMLCacheUpdate.php |
— | — | @@ -172,8 +172,7 @@ |
173 | 173 | # Update file cache |
174 | 174 | if ( $wgUseFileCache ) { |
175 | 175 | foreach ( $titles as $title ) { |
176 | | - $cm = new HTMLFileCache($title); |
177 | | - @unlink($cm->fileCacheName()); |
| 176 | + HTMLFileCache::clearFileCache( $title ); |
178 | 177 | } |
179 | 178 | } |
180 | 179 | } |