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
This commit is contained in:
Moritz Schubotz 2017-03-15 18:41:45 +01:00
parent 81d0df0d5c
commit 46ccf11e8e

View file

@ -522,18 +522,16 @@ abstract class MathRenderer {
if ( $this->purge ) { if ( $this->purge ) {
return true; return true;
} }
$request = RequestContext::getMain()->getRequest(); $refererHeader = RequestContext::getMain()->getRequest()->getHeader( 'REFERER' );
// TODO: Figure out if ?action=purge if ( $refererHeader ) {
// $action = $request->getText('action'); //always returns '' parse_str( parse_url( $refererHeader, PHP_URL_QUERY ), $refererParam );
// until this issue is resolved we use ?mathpurge=true instead if ( isset( $refererParam['action'] ) && $refererParam['action'] === 'purge' ) {
$mathpurge = $request->getBool( 'mathpurge', false );
if ( $mathpurge ) {
LoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' ); LoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' );
return true; return true;
} else {
return false;
} }
} }
return false;
}
/** /**
* Sets purge. If set to true the render is forced to rerender and must not * Sets purge. If set to true the render is forced to rerender and must not