X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FPreprocessor_Hash.php;h=bc2b68658f1745eb662d40771a98a39a50664733;hb=5e6151b3904b4438785e16a2c4e5b2a06bede597;hp=a46446116565691c5c21f2171bc0f3c979f8ae49;hpb=348a0bead146d133b3773e1b34bc30e524b6c1bb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index a464461165..bc2b68658f 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -919,6 +919,14 @@ class PPFrame_Hash implements PPFrame { */ var $depth; + private $volatile = false; + private $ttl = null; + + /** + * @var array + */ + protected $childExpansionCache; + /** * Construct a new preprocessor frame. * @param Preprocessor $preprocessor The parent preprocessor @@ -930,6 +938,7 @@ class PPFrame_Hash implements PPFrame { $this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false ); $this->loopCheckHash = array(); $this->depth = 0; + $this->childExpansionCache = array(); } /** @@ -972,6 +981,18 @@ class PPFrame_Hash implements PPFrame { return new PPTemplateFrame_Hash( $this->preprocessor, $this, $numberedArgs, $namedArgs, $title ); } + /** + * @throws MWException + * @param string|int $key + * @param string|PPNode_Hash|DOMDocument $root + * @param int $flags + * @return string + */ + function cachedExpand( $key, $root, $flags = 0 ) { + // we don't have a parent, so we don't have a cache + return $this->expand( $root, $flags ); + } + /** * @throws MWException * @param string|PPNode$root @@ -1372,6 +1393,44 @@ class PPFrame_Hash implements PPFrame { function getTitle() { return $this->title; } + + /** + * Set the volatile flag + * + * @param bool $flag + */ + function setVolatile( $flag = true ) { + $this->volatile = $flag; + } + + /** + * Get the volatile flag + * + * @return bool + */ + function isVolatile() { + return $this->volatile; + } + + /** + * Set the TTL + * + * @param int $ttl + */ + function setTTL( $ttl ) { + if ( $ttl !== null && ( $this->ttl === null || $ttl < $this->ttl ) ) { + $this->ttl = $ttl; + } + } + + /** + * Get the TTL + * + * @return int|null + */ + function getTTL() { + return $this->ttl; + } } /** @@ -1426,6 +1485,24 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { return $s; } + /** + * @throws MWException + * @param string|int $key + * @param string|PPNode_Hash|DOMDocument $root + * @param int $flags + * @return string + */ + function cachedExpand( $key, $root, $flags = 0 ) { + if ( isset( $this->parent->childExpansionCache[$key] ) ) { + return $this->parent->childExpansionCache[$key]; + } + $retval = $this->expand( $root, $flags ); + if ( !$this->isVolatile() ) { + $this->parent->childExpansionCache[$key] = $retval; + } + return $retval; + } + /** * Returns true if there are no arguments in this frame * @@ -1524,6 +1601,16 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { function isTemplate() { return true; } + + function setVolatile( $flag = true ) { + parent::setVolatile( $flag ); + $this->parent->setVolatile( $flag ); + } + + function setTTL( $ttl ) { + parent::setTTL( $ttl ); + $this->parent->setTTL( $ttl ); + } } /**