Merge "Update list item newline handling to follow Parsoid's model"
[lhc/web/wiklou.git] / includes / parser / Preprocessor_Hash.php
index cb652ac..ad61eec 100644 (file)
@@ -919,6 +919,8 @@ class PPFrame_Hash implements PPFrame {
         */
        var $depth;
 
+       private $volatile = false;
+
        /**
         * @var array
         */
@@ -1390,6 +1392,24 @@ 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;
+       }
 }
 
 /**
@@ -1452,10 +1472,14 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
         * @return string
         */
        function cachedExpand( $key, $root, $flags = 0 ) {
-               if ( !isset( $this->parent->childExpansionCache[$key] ) ) {
-                       $this->parent->childExpansionCache[$key] = $this->expand( $root, $flags );
+               if ( isset( $this->parent->childExpansionCache[$key] ) ) {
+                       return $this->parent->childExpansionCache[$key];
                }
-               return $this->parent->childExpansionCache[$key];
+               $retval = $this->expand( $root, $flags );
+               if ( !$this->isVolatile() ) {
+                       $this->parent->childExpansionCache[$key] = $retval;
+               }
+               return $retval;
        }
 
        /**
@@ -1556,6 +1580,11 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
        function isTemplate() {
                return true;
        }
+
+       function setVolatile( $flag = true ) {
+               parent::setVolatile( $flag );
+               $this->parent->setVolatile( $flag );
+       }
 }
 
 /**