From 222e854a9eeb7a5e01f1208094c970eb19d13bf5 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 4 Jul 2016 15:25:28 +0800 Subject: [PATCH] MDL-29738 file: Remove unused stylesheet functionality This functionality was commented out in 78946b9bdb1299a21f00b88d81c73ad8700c951e for MDL-20204 back in 2009. Since then it has been wasting cycles performing utterly pointless preg_match and preg_replace calls. --- lib/deprecatedlib.php | 12 ++++++++++ lib/filelib.php | 53 ------------------------------------------- lib/upgrade.txt | 2 ++ 3 files changed, 14 insertions(+), 53 deletions(-) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 8964b9b49a2..1e92aa4f695 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -4490,3 +4490,15 @@ function external_function_info($function, $strictness=MUST_EXIST) { return external_api::external_function_info($function, $strictness); } +/** + * Add includes (js and css) into uploaded files before returning them, + * useful for themes and utf.js includes. + * + * @param string $text text to search and replace + * @return string text + * @deprecated Moodle 3.1.1 See MDL-29738 + */ +function file_modify_html_header($text) { + debugging('file_modify_html_header() is deprecated and will not be replaced.', DEBUG_DEVELOPER); + return $text; +} diff --git a/lib/filelib.php b/lib/filelib.php index c26865d54c8..01002a9b603 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -2160,7 +2160,6 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring $options->nocache = true; // temporary workaround for MDL-5136 $text = $pathisstring ? $path : implode('', file($path)); - $text = file_modify_html_header($text); $output = format_text($text, FORMAT_HTML, $options, $COURSE->id); readstring_accel($output, $mimetype, false); @@ -2344,7 +2343,6 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa $options->noclean = true; $options->nocache = true; // temporary workaround for MDL-5136 $text = $stored_file->get_content(); - $text = file_modify_html_header($text); $output = format_text($text, FORMAT_HTML, $options, $COURSE->id); readstring_accel($output, $mimetype, false); @@ -2608,57 +2606,6 @@ function byteserving_send_file($handle, $mimetype, $ranges, $filesize) { } } -/** - * add includes (js and css) into uploaded files - * before returning them, useful for themes and utf.js includes - * - * @global stdClass $CFG - * @param string $text text to search and replace - * @return string text with added head includes - * @todo MDL-21120 - */ -function file_modify_html_header($text) { - // first look for tag - global $CFG; - - $stylesheetshtml = ''; -/* - foreach ($CFG->stylesheets as $stylesheet) { - //TODO: MDL-21120 - $stylesheetshtml .= ''."\n"; - } -*/ - // TODO The code below is actually a waste of CPU. When MDL-29738 will be implemented it should be re-evaluated too. - - preg_match('/\|\/', $text, $matches); - if ($matches) { - $replacement = ''.$stylesheetshtml; - $text = preg_replace('/\|\/', $replacement, $text, 1); - return $text; - } - - // if not, look for tag, and stick right after - preg_match('/\|\/', $text, $matches); - if ($matches) { - // replace tag with includes - $replacement = ''."\n".''.$stylesheetshtml.''; - $text = preg_replace('/\|\/', $replacement, $text, 1); - return $text; - } - - // if not, look for tag, and stick before body - preg_match('/\|\/', $text, $matches); - if ($matches) { - $replacement = ''.$stylesheetshtml.''."\n".''; - $text = preg_replace('/\|\/', $replacement, $text, 1); - return $text; - } - - // if not, just stick a tag at the beginning - $text = ''.$stylesheetshtml.''."\n".$text; - return $text; -} - /** * Tells whether the filename is executable. * diff --git a/lib/upgrade.txt b/lib/upgrade.txt index e22ff5d9acc..a39de0486df 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -7,6 +7,8 @@ information provided here is intended especially for developers. * The parameter $usepost of the following functions has been deprecated and is not used any more: - get_max_upload_file_size() - get_user_max_upload_file_size() +* The following functions have been deprecated and should not be used any more: + - file_modify_html_header() - See MDL-29738 for more information. === 3.1 ===