Reception123 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/374609 )
Change subject: Convert MagicNoCache to use extension registration ...................................................................... Convert MagicNoCache to use extension registration Change-Id: Ibe97bef07b0227e23eb32022b875619769a5ea08 --- A MagicNoCache.hooks.php M MagicNoCache.php A extension.json 3 files changed, 52 insertions(+), 36 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MagicNoCache refs/changes/09/374609/1 diff --git a/MagicNoCache.hooks.php b/MagicNoCache.hooks.php new file mode 100644 index 0000000..3ab44cb --- /dev/null +++ b/MagicNoCache.hooks.php @@ -0,0 +1,14 @@ +<?php +class InternalParseBeforeLinks { + public static function( &$parser, &$text ) { + global $wgOut, $wgAction; + $mw = MagicWord::get( 'MAG_NOCACHE' ); + + // if it is there, remove it and disable caching + if ( !in_array( $wgAction, array( 'submit', 'edit') ) && $mw->matchAndRemove($text) ) { + $parser->disableCache(); + $wgOut->enableClientCache(false); + } + return true; + } +}; \ No newline at end of file diff --git a/MagicNoCache.php b/MagicNoCache.php index 43b7b16..88148ef 100644 --- a/MagicNoCache.php +++ b/MagicNoCache.php @@ -15,39 +15,14 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ -// Check to see if we are being called as an extension or directly -if ( !defined( 'MEDIAWIKI' ) ) { - die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); -} - -// Register this extension on Special:Version -$wgExtensionCredits['parserhook'][] = array( - 'path' => __FILE__, - 'name' => 'MagicNoCache', - 'version' => '1.4.0', - 'url' => 'https://www.mediawiki.org/wiki/Extension:MagicNoCache', - 'author' => array( - 'Kimon Andreou', - '[https://www.mediawiki.org/wiki/User:Pastakhov Pavel Astakhov]', - '...' - ), - 'descriptionmsg' => 'magicnocache-desc', - 'license-name' => 'GPL-2.0+' -); - -// Allow translations for this extension -$wgMessagesDirs['MagicNoCache'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['MagicNoCacheMagic'] = __DIR__ . '/MagicNoCache.i18n.magic.php'; - -// Check to see if we have the magic word in the article -$wgHooks['InternalParseBeforeLinks'][] = function( &$parser, &$text ) { - global $wgOut, $wgAction; - $mw = MagicWord::get( 'MAG_NOCACHE' ); - - // if it is there, remove it and disable caching - if ( !in_array( $wgAction, array( 'submit', 'edit') ) && $mw->matchAndRemove($text) ) { - $parser->disableCache(); - $wgOut->enableClientCache(false); - } - return true; -}; +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'MagicNoCache' ); + $wgMessageDirs['MagicNoCache'] = __DIR__ . '/i18n'; + wfWarn( + 'Deprecated PHP entry point used for MagicNoCache extension. ' . + 'Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + ); +} else { + die( 'This version of the MagicNoCache extension requires MediaWiki 1.29+' ); +} \ No newline at end of file diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..af703eb --- /dev/null +++ b/extension.json @@ -0,0 +1,27 @@ +{ + "name": "MagicNoCache", + "version": "1.4.0", + "author": [ + "[https://www.mediawiki.org/wiki/User:Kimon Kimon Andreou]" + "[https://www.mediawiki.org/wiki/User:Pastakhov Pavel Astakhov", + ], + "type": "parserhook", + "url": "https://www.mediawiki.org/wiki/Extension:MagicNoCache", + "descriptionmsg": "magicnocache-desc", + "license-name": "GPL-2.0+", + "AutoloadClasses": { + "MagicNoCache": "MagicNoCache.hooks.php", + }, + "MessagesDirs": { + "MagicNoCache": [ + "i18n" + ] + }, + "ExtensionMessagesFiles": { + "MagicNoCacheMagic": "MagicNoCacheMagic.i18n.magic.php", + }, + "Hooks": { + "InternalParseBeforeLinks": "MagicNoCacheHooks::magicwordCheck", + }, + "manifest_version": 2 +} -- To view, visit https://gerrit.wikimedia.org/r/374609 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe97bef07b0227e23eb32022b875619769a5ea08 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MagicNoCache Gerrit-Branch: master Gerrit-Owner: Reception123 <utilizator.receptie...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits