From 5012fcb3caa1b3dcaca8e2c8a63acfd948b3794c Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 16 Feb 2009 21:08:54 +0000 Subject: [PATCH] BUGFIX Fix errors if empty array passed for vars in Requirements_Backend::javascriptTemplate() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71905 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Requirements.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Requirements.php b/core/Requirements.php index 784a5ba67..45c3e9f54 100644 --- a/core/Requirements.php +++ b/core/Requirements.php @@ -427,10 +427,14 @@ class Requirements_Backend { */ function javascriptTemplate($file, $vars, $uniquenessID = null) { $script = file_get_contents(Director::getAbsFile($file)); - foreach($vars as $k => $v) { + $search = array(); + $replace = array(); + + if($vars) foreach($vars as $k => $v) { $search[] = '$' . $k; $replace[] = str_replace("\\'","'", Convert::raw2js($v)); } + $script = str_replace($search, $replace, $script); $this->customScript($script, $uniquenessID); }