mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
Add a cache purging action for URL for Math rendering
* MathRenderer passes purge state, the purge state has to be rechecked since implicitly it is true in the MathRenderer * for rechecking a new flag is introduced to isPurge function Bug: T348976 Change-Id: Ifdcea4b2c17ac963a50ee48e2d6437c0feafc602
This commit is contained in:
parent
d54a562d8f
commit
aa5bba5bf9
|
@ -17,6 +17,8 @@ class LocalChecker extends BaseChecker {
|
|||
private string $type;
|
||||
private WANObjectCache $cache;
|
||||
|
||||
private bool $purge = false;
|
||||
|
||||
private bool $isChecked = false;
|
||||
|
||||
public function __construct( WANObjectCache $cache, $tex = '', string $type = 'tex' ) {
|
||||
|
@ -25,6 +27,10 @@ class LocalChecker extends BaseChecker {
|
|||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setPurge( bool $purge ) {
|
||||
$this->purge = $purge;
|
||||
}
|
||||
|
||||
public function isValid(): bool {
|
||||
$this->run();
|
||||
return parent::isValid();
|
||||
|
@ -45,8 +51,12 @@ class LocalChecker extends BaseChecker {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
$cacheInputKey = $this->getInputCacheKey();
|
||||
if ( $this->purge ) {
|
||||
$this->cache->delete( $cacheInputKey, WANObjectCache::TTL_INDEFINITE );
|
||||
}
|
||||
$result = $this->cache->getWithSetCallback(
|
||||
$this->getInputCacheKey(),
|
||||
$cacheInputKey,
|
||||
WANObjectCache::TTL_INDEFINITE,
|
||||
[ $this, 'runCheck' ],
|
||||
[ 'version' => self::VERSION ],
|
||||
|
|
|
@ -28,7 +28,9 @@ class MathNativeMML extends MathMathML {
|
|||
}
|
||||
|
||||
protected function doRender(): StatusValue {
|
||||
$presentation = $this->getChecker()->getPresentationMathMLFragment();
|
||||
$checker = $this->getChecker();
|
||||
$checker->setPurge( $this->isPurge() );
|
||||
$presentation = $checker->getPresentationMathMLFragment();
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$attributes = [ 'class' => 'mwe-math-element' ];
|
||||
if ( $this->getID() !== '' ) {
|
||||
|
|
|
@ -514,7 +514,7 @@ abstract class MathRenderer {
|
|||
|
||||
/**
|
||||
* Checks if there is an explicit user request to rerender the math-tag.
|
||||
* @return bool
|
||||
* @return bool purge state
|
||||
*/
|
||||
public function isPurge() {
|
||||
if ( $this->purge ) {
|
||||
|
|
Loading…
Reference in a new issue