Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Commit

Permalink
More release tweaks (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
amiga-500 authored Jan 12, 2017
1 parent 11eeed1 commit 7fcb54d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
25 changes: 24 additions & 1 deletion inc/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]');
Expand Down Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions lib/W3/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/W3/ConfigData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/W3/ConfigWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 7fcb54d

Please sign in to comment.