Difference between revisions of "User:Bumsakalaka"
Jump to navigation
Jump to search
Bumsakalaka (talk | contribs) |
Bumsakalaka (talk | contribs) |
||
Line 718: | Line 718: | ||
** <p>Call public <code><nowiki>static function onArticlePurge( &$article ) { ... }</nowiki></code> | ** <p>Call public <code><nowiki>static function onArticlePurge( &$article ) { ... }</nowiki></code> | ||
<pre style="margin-left:5ex"><nowiki> | <pre style="margin-left:5ex"><nowiki> | ||
extension.json | |||
{ | { | ||
Line 728: | Line 726: | ||
} | } | ||
} | } | ||
extenstion file | |||
namespace MediaWiki\Extension\MyExtension; | namespace MediaWiki\Extension\MyExtension; | ||
Line 751: | Line 746: | ||
return true; | return true; | ||
} | } | ||
}</nowiki</pre> | }</nowiki></pre> | ||
</p> | </p> | ||
** Another solution CustomCacheKey,but it looks like not used that $thatus->value['cacheKey'] value when reading the cache, need to be tests. If this is working, this will be best solution. | |||
<pre><nowiki><?php | |||
extensions/CustomCacheKey/CustomCacheKey.php | |||
class CustomCacheKey { | |||
public static function onPageContentSaveComplete($wikiPage, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status) { | |||
// Your custom logic here | |||
// Modify the cache key based on the page content, user, or other factors | |||
$cacheKey = $wikiPage->getTitle()->getPrefixedDBkey(); | |||
if (wfMobileDetect()) { | |||
$cacheKey .= '_mobile'; // Add your custom suffix | |||
} | |||
// Set the modified cache key | |||
$status->value['cacheKey'] = $cacheKey; | |||
} | |||
} | |||
extension.json | |||
{ | |||
"Hooks": { | |||
"PageContentSaveComplete": "CustomCacheKey::onPageContentSaveComplete" | |||
} | |||
} | |||
</nowiki></pre> |