From: skodak <skodak>
Date: Sat, 15 Dec 2007 13:21:12 +0000 (+0000)
Subject: MDL-8992 eoas hack added only when really needed, removed slow fullclone; merged... 
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=15fb52fbcbb725a35ff60207f1b99399427597ba;p=moodle.git

MDL-8992 eoas hack added only when really needed, removed slow fullclone; merged from MOODLE_19_STABLE
---

diff --git a/filter/mediaplugin/filter.php b/filter/mediaplugin/filter.php
index ac925d48b3..e5f9117db5 100644
--- a/filter/mediaplugin/filter.php
+++ b/filter/mediaplugin/filter.php
@@ -31,7 +31,11 @@ function mediaplugin_filter($courseid, $text) {
 
     // We're using the UFO technique for flash to attain XHTML Strict 1.0
     // See: http://www.bobbyvandersluis.com/ufo/
-    $newtext = fullclone($text);
+    if (!is_string($text)) {
+        // non string data can not be filtered anyway
+        return $text;
+    }
+    $newtext = $text; // fullclone is slow and not needed here
 
     if ($CFG->filter_mediaplugin_enable_mp3) {
         $search = '/<a.*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';
@@ -83,8 +87,9 @@ function mediaplugin_filter($courseid, $text) {
         $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);
     }
 
-    if (is_null($newtext)) {
-        $newtext = $text;
+    if (is_null($newtext) or $newtext === $text) {
+        // error or not filtered
+        return $text;
     }
     
     if (!$eolas_fix_applied) {