Index: trunk/extensions/PurgeCache.php |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * Special page used to wipe the OBJECTCACHE table
|
| 6 | + * I use it on test wikis when I'm fiddling about with things en masse that could be cached
|
| 7 | + *
|
| 8 | + * @package MediaWiki
|
| 9 | + * @subpackage Extensions
|
| 10 | + * @author Rob Church <robchur@gmail.com>
|
| 11 | + * @licence Public domain
|
| 12 | + */
|
| 13 | +
|
| 14 | +if( defined( 'MEDIAWIKI' ) ) {
|
| 15 | +
|
| 16 | + require_once( 'SpecialPage.php' );
|
| 17 | + $wgExtensionFunctions[] = 'efPurgeCache';
|
| 18 | + $wgAvailableRights[] = 'purgecache';
|
| 19 | + $wgGroupPermissions['developer']['purgecache'] = true;
|
| 20 | +
|
| 21 | + function efPurgeCache() {
|
| 22 | + global $wgMessageCache;
|
| 23 | + $wgMessageCache->addMessage( 'purgecache', 'Purge cache' );
|
| 24 | + SpecialPage::addPage( new PurgeCache() );
|
| 25 | + }
|
| 26 | +
|
| 27 | + class PurgeCache extends SpecialPage {
|
| 28 | +
|
| 29 | + function PurgeCache() {
|
| 30 | + SpecialPage::SpecialPage( 'PurgeCache', 'purgecache' );
|
| 31 | + }
|
| 32 | +
|
| 33 | + function execute() {
|
| 34 | + global $wgUser, $wgRequest, $wgOut;
|
| 35 | + $this->setHeaders();
|
| 36 | + if( $wgUser->isAllowed( 'purgecache' ) ) {
|
| 37 | + if( $wgRequest->getCheck( 'purge' ) && $wgRequest->wasPosted() ) {
|
| 38 | + $dbw =& wfGetDB( DB_MASTER );
|
| 39 | + $dbw->delete( 'objectcache', '*', 'PurgeCache::execute' );
|
| 40 | + $wgOut->addWikiText( 'The cache has been purged.' );
|
| 41 | + } else {
|
| 42 | + $wgOut->addWikiText( 'This will purge the cache tables.' );
|
| 43 | + $wgOut->addHtml( $this->makeForm() );
|
| 44 | + }
|
| 45 | + } else {
|
| 46 | + $wgOut->permissionRequired( 'purgecache' );
|
| 47 | + }
|
| 48 | + }
|
| 49 | +
|
| 50 | + function makeForm() {
|
| 51 | + $self = $this->getTitle();
|
| 52 | + $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
|
| 53 | + $form .= wfElement( 'input', array( 'type' => 'submit', 'name' => 'purge', 'value' => 'Purge' ) );
|
| 54 | + $form .= wfCloseElement( 'form' );
|
| 55 | + return $form;
|
| 56 | + }
|
| 57 | +
|
| 58 | + }
|
| 59 | +
|
| 60 | +} else {
|
| 61 | + echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
|
| 62 | + die( -1 );
|
| 63 | +}
|
| 64 | +
|
| 65 | +?> |
\ No newline at end of file |