diff --git a/MathMathML.php b/MathMathML.php index 26ee1b3a9..722dfc994 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -81,12 +81,16 @@ class MathMathML extends MathRenderer { public function render( $forceReRendering = false ) { global $wgMathFullRestbaseURL; try { + if ( $forceReRendering ) { + $this->setPurge( true ); + } if ( in_array( $this->inputType, $this->restbaseInputTypes ) && $this->mode == 'mathml' ) { if ( !$this->rbi ) { $this->rbi = new MathRestbaseInterface( $this->getTex(), $this->getInputType() ); + $this->rbi->setPurge( $this->isPurge() ); } $rbi = $this->rbi; if ( $rbi->getSuccess() ) { @@ -99,9 +103,6 @@ class MathMathML extends MathRenderer { $this->changed = false; return $rbi->getSuccess(); } - if ( $forceReRendering ) { - $this->setPurge( true ); - } if ( $this->renderingRequired() ) { return $this->doRender(); } diff --git a/MathRenderer.php b/MathRenderer.php index e5ed80444..87c427a48 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -385,6 +385,7 @@ abstract class MathRenderer { */ public function setRestbaseInterface( $param ) { $this->rbi = $param; + $this->rbi->setPurge( $this->isPurge() ); } /** diff --git a/MathRestbaseInterface.php b/MathRestbaseInterface.php index 3f4283289..bf2e59053 100644 --- a/MathRestbaseInterface.php +++ b/MathRestbaseInterface.php @@ -18,6 +18,8 @@ class MathRestbaseInterface { private $error; private $mathoidStyle; private $mml; + /** @var boolean is there a request to purge the existing mathematical content */ + private $purge = false; /** * MathRestbaseInterface constructor. @@ -66,6 +68,18 @@ class MathRestbaseInterface { } } + /** + * Lets this instance know if this is a purge request. When set to true, + * it will cause the object to issue the first content request with a + * 'Cache-Control: no-cache' header to prompt the regeneration of the + * renders. + * + * @param bool $purge whether this is a purge request + */ + public function setPurge( $purge = true ) { + $this->purge = $purge; + } + /** * @return string MathML code * @throws MWException @@ -383,6 +397,12 @@ class MathRestbaseInterface { 'method' => 'GET', 'url' => $this->getUrl( "media/math/render/$type/{$this->hash}" ) ]; + if ( $this->purge ) { + $request['headers'] = [ + 'Cache-Control' => 'no-cache' + ]; + $this->purge = false; + } return $request; }