From 46ccf11e8ede9d747581de1738fe385ab9b64088 Mon Sep 17 00:00:00 2001 From: Moritz Schubotz Date: Wed, 15 Mar 2017 18:41:45 +0100 Subject: [PATCH] Purge formulae on action=purge Previously, the 'action=purge' parameter could not be accessed by the math extension, since 'action=purge' caused a reload of the page, even before the math extension was called. However, before MediaWiki 1.29.+ additional GET request parameter were forwarded to the next page and could be evaluated by the math extension. Thus, an additional parameter 'mathpurge=true' was added to re-render formulae. However, it seems that this additional GET parameter is no longer being forwarded. This change reads the refer header to check if 'action=purge' was passed. This makes the mathpurge parameter obsolete. Bug: T74537 Change-Id: Ia09c039de3a7232a28bfdd5a97daf1029e5d7c40 --- MathRenderer.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/MathRenderer.php b/MathRenderer.php index b6916eb29..99216f8c6 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -522,17 +522,15 @@ abstract class MathRenderer { if ( $this->purge ) { return true; } - $request = RequestContext::getMain()->getRequest(); - // TODO: Figure out if ?action=purge - // $action = $request->getText('action'); //always returns '' - // until this issue is resolved we use ?mathpurge=true instead - $mathpurge = $request->getBool( 'mathpurge', false ); - if ( $mathpurge ) { - LoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' ); - return true; - } else { - return false; + $refererHeader = RequestContext::getMain()->getRequest()->getHeader( 'REFERER' ); + if ( $refererHeader ) { + parse_str( parse_url( $refererHeader, PHP_URL_QUERY ), $refererParam ); + if ( isset( $refererParam['action'] ) && $refererParam['action'] === 'purge' ) { + LoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' ); + return true; + } } + return false; } /**