From a11fb1a4ef279951479ee06eb830872eb8dd941e Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 19 Jan 2018 18:39:05 -0700 Subject: [PATCH] Update cache.lua Make the cache.lua more robust in case of missing key or value. --- .../scripts/resources/functions/cache.lua | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index e59359bd85..f7e7025ead 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -80,17 +80,32 @@ end -- convert cache key to memcache key local function key2key(key) - return (string.gsub(key, "\\", "\\\\")) + if (key) then + key = string.gsub(key, "\\", "\\\\"); + else + key = ''; + end + return key; end -- encode value to be able store it in memcache local function memcache_encode(value) - return (string.gsub(value, "'", "'"):gsub("\\", "\\\\")) + if (value) then + value = string.gsub(value, "'", "'"):gsub("\\", "\\\\"); + else + value = ''; + end + return value; end -- decode value retrived from memcache local function memcache_decode(value) - return (string.gsub(value, "'", "'")) + if (value) then + value = string.gsub(value, "'", "'"); + else + value = ''; + end + return value; end function Cache.support()