Index: branches/jsgrammar/includes/resourceloader/ResourceLoaderLanguageDataModule.php |
— | — | @@ -53,28 +53,21 @@ |
54 | 54 | * @return array|int|Mixed |
55 | 55 | */ |
56 | 56 | public function getModifiedTime( ResourceLoaderContext $context ) { |
57 | | - global $wgCacheEpoch; |
| 57 | + $cache = wfGetCache( CACHE_ANYTHING ); |
| 58 | + $key = wfMemckey( 'rllangdatacache' ); |
58 | 59 | |
59 | | - /** |
60 | | - * @todo FIXME: This needs to change whenever the array created by |
61 | | - * $wgContLang->getGrammarForms() changes. Which gets its data from |
62 | | - * $wgGrammarForms, which (for standard installations) comes from LocalSettings |
63 | | - * and $wgCacheEpoch would cover that. However there's two three problems: |
64 | | - * |
65 | | - * 1) $wgCacheEpoch is not meant for this use. |
66 | | - * 2) If $wgInvalidateCacheOnLocalSettingsChange is set to false, |
67 | | - * $wgCacheEpoch will not be raised if LocalSettings is modified (see #1). |
68 | | - * 3) $wgGrammarForms can be set from anywhere. For example on WMF it is set |
69 | | - * by the WikimediaMessages extension. Other farms might set it form |
70 | | - * their 'CommonSettings.php'-like file or something (see #1). |
71 | | - * |
72 | | - * Possible solutions: |
73 | | - * - Store grammarforms in the language object cache instead of directly |
74 | | - * from the global everytime. Then use $wgContLang->getLastModified(). |
75 | | - * - Somehow monitor the value of $wgGrammarForms. |
76 | | - */ |
| 60 | + $forms = $this->getSiteLangGrammarForms(); |
| 61 | + $hash = md5( serialize( $forms ) ); |
77 | 62 | |
78 | | - return $wgCacheEpoch; |
| 63 | + $result = $cache->get( $key ); |
| 64 | + if ( is_array( $result ) ) { |
| 65 | + if ( $result['hash'] === $hash ) { |
| 66 | + return $result['timestamp']; |
| 67 | + } |
| 68 | + } |
| 69 | + $timestamp = wfTimestamp(); |
| 70 | + $cache->set( $key, array( 'hash' => $hash, 'timestamp' => $timestamp ) ); |
| 71 | + return $timestamp; |
79 | 72 | } |
80 | 73 | |
81 | 74 | /** |