Merge "Revert "Follow-up ee320648fd1: output mw-content-{ltr,rtl} unconditionally""
[lhc/web/wiklou.git] / includes / parser / StripState.php
index d4f4559..7e38acc 100644 (file)
@@ -39,7 +39,7 @@ class StripState {
        /**
         * @param string $prefix
         */
-       function __construct( $prefix ) {
+       public function __construct( $prefix ) {
                $this->prefix = $prefix;
                $this->data = array(
                        'nowiki' => array(),
@@ -54,7 +54,7 @@ class StripState {
         * @param string $marker
         * @param string $value
         */
-       function addNoWiki( $marker, $value ) {
+       public function addNoWiki( $marker, $value ) {
                $this->addItem( 'nowiki', $marker, $value );
        }
 
@@ -62,7 +62,7 @@ class StripState {
         * @param string $marker
         * @param string $value
         */
-       function addGeneral( $marker, $value ) {
+       public function addGeneral( $marker, $value ) {
                $this->addItem( 'general', $marker, $value );
        }
 
@@ -84,7 +84,7 @@ class StripState {
         * @param string $text
         * @return mixed
         */
-       function unstripGeneral( $text ) {
+       public function unstripGeneral( $text ) {
                return $this->unstripType( 'general', $text );
        }
 
@@ -92,7 +92,7 @@ class StripState {
         * @param string $text
         * @return mixed
         */
-       function unstripNoWiki( $text ) {
+       public function unstripNoWiki( $text ) {
                return $this->unstripType( 'nowiki', $text );
        }
 
@@ -100,7 +100,7 @@ class StripState {
         * @param string $text
         * @return mixed
         */
-       function unstripBoth( $text ) {
+       public function unstripBoth( $text ) {
                $text = $this->unstripType( 'general', $text );
                $text = $this->unstripType( 'nowiki', $text );
                return $text;
@@ -117,12 +117,10 @@ class StripState {
                        return $text;
                }
 
-               wfProfileIn( __METHOD__ );
                $oldType = $this->tempType;
                $this->tempType = $type;
                $text = preg_replace_callback( $this->regex, array( $this, 'unstripCallback' ), $text );
                $this->tempType = $oldType;
-               wfProfileOut( __METHOD__ );
                return $text;
        }
 
@@ -146,7 +144,11 @@ class StripState {
                        }
                        $this->circularRefGuard[$marker] = true;
                        $this->recursionLevel++;
-                       $ret = $this->unstripType( $this->tempType, $this->data[$this->tempType][$marker] );
+                       $value = $this->data[$this->tempType][$marker];
+                       if ( $value instanceof Closure ) {
+                               $value = $value();
+                       }
+                       $ret = $this->unstripType( $this->tempType, $value );
                        $this->recursionLevel--;
                        unset( $this->circularRefGuard[$marker] );
                        return $ret;
@@ -163,7 +165,7 @@ class StripState {
         *
         * @return StripState
         */
-       function getSubState( $text ) {
+       public function getSubState( $text ) {
                $subState = new StripState( $this->prefix );
                $pos = 0;
                while ( true ) {
@@ -199,7 +201,7 @@ class StripState {
         * @param array $texts
         * @return array
         */
-       function merge( $otherState, $texts ) {
+       public function merge( $otherState, $texts ) {
                $mergePrefix = Parser::getRandomString();
 
                foreach ( $otherState->data as $type => $items ) {
@@ -229,7 +231,7 @@ class StripState {
         * @param string $text Input string
         * @return string
         */
-       function killMarkers( $text ) {
+       public function killMarkers( $text ) {
                return preg_replace( $this->regex, '', $text );
        }
 }