Cache now supports multiple extension versions
[mailer.git] / inc / libs / cache_functions.php
index f3496a5ccb4f152aed76f2fac9e2d2c510583ad8..e8f750bee8f55e94767d3af40d451b666b024488 100644 (file)
@@ -193,6 +193,7 @@ class mxchange_cache
                if (FILE_READABLE($this->cache_inc)) {
                        // Prepare temporary array
                        $data = array();
+                       $cache_version = null;
 
                        // Load cache file
                        $this->cache_data = implode("", file($this->cache_inc));
@@ -205,7 +206,7 @@ class mxchange_cache
                                $this->cache_data = $data;
 
                                // Cache version found?
-                               if (isset($cache_version)) {
+                               if ((isset($cache_version)) && (is_array($cache_version))) {
                                        // Remember it as well...
                                        $this->cache_version = $cache_version;
                                } // END - if
@@ -351,7 +352,7 @@ class mxchange_cache
                        $ext_ver = GET_EXT_VERSION($ext_name);
 
                        // Write cache line to file
-                       @fwrite($this->cache_pointer, "\$cache_version = \"".$ext_ver."\";\n");
+                       @fwrite($this->cache_pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n");
                } else {
                        // Cannot create file
                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
@@ -367,7 +368,7 @@ class mxchange_cache
 
                //* DEBUG: */ echo __METHOD__.": ext_name={$ext_name},ext_ver={$ext_ver},cache_version={$this->cache_version}<br />\n";
                // Compare both
-               return ($ext_ver == $this->cache_version);
+               return ((isset($this->cache_version[$ext_name])) && ($this->cache_version[$ext_name] == $ext_ver));
        }
 
        function add_raw_row ($key, $value) {