diff --git a/inc/define.php b/inc/define.php index 7733e65..1fbb3f7 100644 --- a/inc/define.php +++ b/inc/define.php @@ -5,7 +5,7 @@ } define('W3TC', true); -define('W3TC_VERSION', '0.9.4.6'); +define('W3TC_VERSION', '0.9.4.6.1'); define("W3TC_TESTED_ON_WP_VERSION", '4.7.1'); define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION); define('W3TC_EMAIL', 'w3tc@w3-edge.com'); @@ -121,6 +121,29 @@ function w3_microtime() { return ((double) $usec + (double) $sec); } +/** + * Returns the W3TC current version (4 digit limit for config reading) + * + * @return string + */ +function w3_current_version() + { + static $ver = null; + + if ($ver === null) + { + if (preg_match('/(\d+)\.(\d+)\.(\d+)\.(\d+)\.?(\d+)?/',W3TC_VERSION,$match)) { + array_shift($match); + if (count($match) == 5) array_pop($match); + $ver = implode(".",$match); + } + else { + $ver = W3TC_VERSION; + } + } + return $ver; +} + /** * Check if content is HTML or XML * diff --git a/lib/W3/Config.php b/lib/W3/Config.php index d6eb620..19c6b4c 100644 --- a/lib/W3/Config.php +++ b/lib/W3/Config.php @@ -262,14 +262,14 @@ private function _read($filename) { $config = @unserialize($content); if (is_array($config)) { if (isset($config['version']) - && $config['version'] == W3TC_VERSION) { + && $config['version'] == w3_current_version()) { return $config; } } } return null; } - + private function _flush_cache($forced_preview = null) { $this->_md5 = null; if ($this->_blog_id > 0) diff --git a/lib/W3/ConfigData.php b/lib/W3/ConfigData.php index d232751..f060182 100644 --- a/lib/W3/ConfigData.php +++ b/lib/W3/ConfigData.php @@ -31,7 +31,7 @@ class W3_ConfigData { * Constructor */ function __construct($keys) { - $this->data = array('version' => W3TC_VERSION); + $this->data = array('version' => w3_current_version()); $this->_keys = $keys; $this->_http_keys_map = array(); @@ -61,7 +61,7 @@ function resolve_http_key($http_key) { * Removes data */ function clear() { - $this->data = array('version' => W3TC_VERSION); + $this->data = array('version' => w3_current_version()); } /** diff --git a/lib/W3/ConfigWriter.php b/lib/W3/ConfigWriter.php index d59d8f8..4910edd 100644 --- a/lib/W3/ConfigWriter.php +++ b/lib/W3/ConfigWriter.php @@ -101,7 +101,7 @@ function create_compiled_config($cache_filename, $write = true) { // append data from blog config $config_admin = w3_instance('W3_ConfigAdmin'); $data = W3_ConfigData::get_array_from_file($this->_get_config_filename()); - if (isset($data['version']) && version_compare($data['version'], W3TC_VERSION, '<')) { + if (isset($data['version']) && version_compare($data['version'], w3_current_version(), '<')) { /** * @var W3_ConfigCompatibility $config_comp */