Merge "Add tags for undo edits"
[lhc/web/wiklou.git] / includes / parser / LinkHolderArray.php
index e7712f2..816f7f7 100644 (file)
@@ -134,7 +134,7 @@ class LinkHolderArray {
                                $maxId = $newKey > $maxId ? $newKey : $maxId;
                        }
                }
-               $texts = preg_replace_callback( '/(<!--LINK \d+:)(\d+)(-->)/',
+               $texts = preg_replace_callback( '/(<!--LINK\'" \d+:)(\d+)(-->)/',
                        [ $this, 'mergeForeignCallback' ], $texts );
 
                # Renumber interwiki links
@@ -143,7 +143,7 @@ class LinkHolderArray {
                        $this->interwikis[$newKey] = $entry;
                        $maxId = $newKey > $maxId ? $newKey : $maxId;
                }
-               $texts = preg_replace_callback( '/(<!--IWLINK )(\d+)(-->)/',
+               $texts = preg_replace_callback( '/(<!--IWLINK\'" )(\d+)(-->)/',
                        [ $this, 'mergeForeignCallback' ], $texts );
 
                # Set the parent link ID to be beyond the highest used ID
@@ -172,7 +172,7 @@ class LinkHolderArray {
                # Internal links
                $pos = 0;
                while ( $pos < strlen( $text ) ) {
-                       if ( !preg_match( '/<!--LINK (\d+):(\d+)-->/',
+                       if ( !preg_match( '/<!--LINK\'" (\d+):(\d+)-->/',
                                $text, $m, PREG_OFFSET_CAPTURE, $pos )
                        ) {
                                break;
@@ -186,7 +186,7 @@ class LinkHolderArray {
                # Interwiki links
                $pos = 0;
                while ( $pos < strlen( $text ) ) {
-                       if ( !preg_match( '/<!--IWLINK (\d+)-->/', $text, $m, PREG_OFFSET_CAPTURE, $pos ) ) {
+                       if ( !preg_match( '/<!--IWLINK\'" (\d+)-->/', $text, $m, PREG_OFFSET_CAPTURE, $pos ) ) {
                                break;
                        }
                        $key = $m[1][0];
@@ -249,12 +249,12 @@ class LinkHolderArray {
                                // Use a globally unique ID to keep the objects mergable
                                $key = $this->parent->nextLinkID();
                                $this->interwikis[$key] = $entry;
-                               $retVal = "<!--IWLINK $key-->{$trail}";
+                               $retVal = "<!--IWLINK'\" $key-->{$trail}";
                        } else {
                                $key = $this->parent->nextLinkID();
                                $ns = $nt->getNamespace();
                                $this->internals[$ns][$key] = $entry;
-                               $retVal = "<!--LINK $ns:$key-->{$trail}";
+                               $retVal = "<!--LINK'\" $ns:$key-->{$trail}";
                        }
                        $this->size++;
                }
@@ -264,7 +264,7 @@ class LinkHolderArray {
        /**
         * Replace <!--LINK--> link placeholders with actual links, in the buffer
         *
-        * @param string $text
+        * @param string &$text
         */
        public function replace( &$text ) {
                $this->replaceInternal( $text );
@@ -273,7 +273,7 @@ class LinkHolderArray {
 
        /**
         * Replace internal links
-        * @param string $text
+        * @param string &$text
         */
        protected function replaceInternal( &$text ) {
                if ( !$this->internals ) {
@@ -374,7 +374,7 @@ class LinkHolderArray {
                                $title = $entry['title'];
                                $query = isset( $entry['query'] ) ? $entry['query'] : [];
                                $key = "$ns:$index";
-                               $searchkey = "<!--LINK $key-->";
+                               $searchkey = "<!--LINK'\" $key-->";
                                $displayText = $entry['text'];
                                if ( isset( $entry['selflink'] ) ) {
                                        $replacePairs[$searchkey] = Linker::makeSelfLinkObj( $title, $displayText, $query );
@@ -408,7 +408,7 @@ class LinkHolderArray {
 
                # Do the thing
                $text = preg_replace_callback(
-                       '/(<!--LINK .*?-->)/',
+                       '/(<!--LINK\'" .*?-->)/',
                        $replacer->cb(),
                        $text
                );
@@ -416,7 +416,7 @@ class LinkHolderArray {
 
        /**
         * Replace interwiki links
-        * @param string $text
+        * @param string &$text
         */
        protected function replaceInterwiki( &$text ) {
                if ( empty( $this->interwikis ) ) {
@@ -437,14 +437,14 @@ class LinkHolderArray {
                $replacer = new HashtableReplacer( $replacePairs, 1 );
 
                $text = preg_replace_callback(
-                       '/<!--IWLINK (.*?)-->/',
+                       '/<!--IWLINK\'" (.*?)-->/',
                        $replacer->cb(),
                        $text );
        }
 
        /**
         * Modify $this->internals and $colours according to language variant linking rules
-        * @param array $colours
+        * @param array &$colours
         */
        protected function doVariants( &$colours ) {
                global $wgContLang;
@@ -612,8 +612,8 @@ class LinkHolderArray {
         */
        public function replaceText( $text ) {
                $text = preg_replace_callback(
-                       '/<!--(LINK|IWLINK) (.*?)-->/',
-                       [ &$this, 'replaceTextCallback' ],
+                       '/<!--(LINK|IWLINK)\'" (.*?)-->/',
+                       [ $this, 'replaceTextCallback' ],
                        $text );
 
                return $text;