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:
Stegmujo 2023-10-16 12:41:16 +00:00
parent d54a562d8f
commit aa5bba5bf9
No known key found for this signature in database
GPG key ID: BB616B7CC84186BE
3 changed files with 15 additions and 3 deletions

View file

@ -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 ],

View file

@ -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() !== '' ) {

View file

@ -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 ) {