Fix issues identified by SpaceBeforeSingleLineComment sniff
[lhc/web/wiklou.git] / includes / parser / Preprocessor_Hash.php
index d1ad39c..f536d82 100644 (file)
@@ -200,7 +200,7 @@ class Preprocessor_Hash implements Preprocessor {
                $fakeLineStart = true;
 
                while ( true ) {
-                       //$this->memCheck();
+                       // $this->memCheck();
 
                        if ( $findOnlyinclude ) {
                                // Ignore all input up to the next <onlyinclude>
@@ -734,8 +734,12 @@ class Preprocessor_Hash implements Preprocessor {
                // Cache
                if ( $cacheable ) {
                        $cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . serialize( $rootNode );
-                       $wgMemc->set( $cacheKey, $cacheValue, 86400 );
-                       wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" );
+
+                       // T111289: Cache values should not exceed 1 Mb, but they do.
+                       if ( strlen( $cacheValue ) <= 1e6 ) {
+                               $wgMemc->set( $cacheKey, $cacheValue, 86400 );
+                               wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" );
+                       }
                }
 
                return $rootNode;
@@ -1124,9 +1128,11 @@ class PPFrame_Hash implements PPFrame {
                                } elseif ( $contextNode->name == 'comment' ) {
                                        # HTML-style comment
                                        # Remove it in HTML, pre+remove and STRIP_COMMENTS modes
-                                       if ( $this->parser->ot['html']
+                                       # Not in RECOVER_COMMENTS mode (msgnw) though.
+                                       if ( ( $this->parser->ot['html']
                                                || ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() )
                                                || ( $flags & PPFrame::STRIP_COMMENTS )
+                                               ) && !( $flags & PPFrame::RECOVER_COMMENTS )
                                        ) {
                                                $out .= '';
                                        } elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
@@ -1148,7 +1154,7 @@ class PPFrame_Hash implements PPFrame {
                                        ) {
                                                $out .= $contextNode->firstChild->value;
                                        } else {
-                                               //$out .= '';
+                                               // $out .= '';
                                        }
                                } elseif ( $contextNode->name == 'ext' ) {
                                        # Extension tag