Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php	(revision 540)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php	(revision 541)
@@ -37,4 +37,5 @@
         $text = $this->replace_callback($text, $callback);
 
+        $tags = array();
         $offset=0;
         $textTmp = $text;
@@ -55,24 +56,28 @@
         }
 
-        ksort($tags);
+        if (!empty($tags)) {
+            ksort($tags);
 
-        $strtr = array("<!--FCK_SKIP_START-->" => "", "<!--FCK_SKIP_END-->" => "");
+            $strtr = array("<!--FCK_SKIP_START-->" => "", "<!--FCK_SKIP_END-->" => "");
 
-        $sum=0;
-        $lastSum=0;
-        $finalString = false;
-        $startingPos = 0;
-        $inner = "";
-        foreach ($tags as $pos=>$type) {
-            $sum += $type;
-            if ($sum == 1 && $lastSum == 0) {
-                $finalString .= parent::internalParse(strtr(substr($text, $startingPos, $pos - $startingPos), $strtr));
-                $startingPos = $pos;
+            $sum=0;
+            $lastSum=0;
+            $finalString = false;
+            $startingPos = 0;
+            $inner = "";
+            foreach ($tags as $pos=>$type) {
+                $sum += $type;
+                if ($sum == 1 && $lastSum == 0) {
+                    $finalString .= parent::internalParse(strtr(substr($text, $startingPos, $pos - $startingPos), $strtr));
+                    $startingPos = $pos;
+                }
+                else if ($sum == 0) {
+                    $finalString .= '<span class="fck_mw_template">' . strtr(substr($text, $startingPos, $pos - $startingPos + 19), $strtr) . '</span>';
+                    $startingPos = $pos + 19;
+                }
+                $lastSum = $sum;
             }
-            else if ($sum == 0) {
-                $finalString .= '<span class="fck_mw_template">' . strtr(substr($text, $startingPos, $pos - $startingPos + 19), $strtr) . '</span>';
-                $startingPos = $pos + 19;
-            }
-            $lastSum = $sum;
+        } else {
+            $finalString = parent::internalParse($text);
         }
 
@@ -104,5 +109,5 @@
     /*
     function replaceVariables( $text, $args = array(), $argsOnly = false ) {
-        return preg_replace("/\{\{([^}]+)\}\}(\}*)/", '<span class="fck_template">{{$1}}$2</span>', $text);
+    return preg_replace("/\{\{([^}]+)\}\}(\}*)/", '<span class="fck_template">{{$1}}$2</span>', $text);
     }
     */
