From e9b129a6a47fff66c8fd8c05fce1feeee191d6ed Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 18 Apr 2008 16:59:47 +0000 Subject: [PATCH] MDL-14072 - Backported from HEAD. Prevent NULLs, empties and numbers to be processed by: - backup_encode_absolute_links() at backup - restore_decode_absolute_links() at restore --- backup/backuplib.php | 10 ++++++++++ backup/restorelib.php | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/backup/backuplib.php b/backup/backuplib.php index 58383e5a5df..5b23e449ea8 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1778,6 +1778,16 @@ global $CFG,$preferences; + /// MDL-14072: Prevent NULLs, empties and numbers to be processed by the + /// heavy interlinking. Just a few cpu cycles saved. + if ($content === NULL) { + return NULL; + } else if ($content === '') { + return ''; + } else if (is_numeric($content)) { + return $content; + } + //Use one static variable to cache all the require_once calls that, //under PHP5 seems to increase load too much, and we are requiring //them here thousands of times (one per content). MDL-8700. diff --git a/backup/restorelib.php b/backup/restorelib.php index d1d36b8fb5f..ee446118dc4 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2607,8 +2607,18 @@ //step in the restore execution, because we need to have it //finished to know all the oldid, newid equivaleces function restore_decode_absolute_links($content) { - - global $CFG,$restore; + + global $CFG,$restore; + + /// MDL-14072: Prevent NULLs, empties and numbers to be processed by the + /// heavy interlinking. Just a few cpu cycles saved. + if ($content === NULL) { + return NULL; + } else if ($content === '') { + return ''; + } else if (is_numeric($content)) { + return $content; + } //Now decode wwwroot and file.php calls $search = array ("$@FILEPHP@$");