Commit 814ac4a6 authored by mku's avatar mku

ZP-493 #comment Z-Push state version file is broken

git-svn-id: https://z-push.org/svn/z-push/trunk@1793 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 6b66df18
...@@ -331,8 +331,15 @@ class FileStateMachine implements IStateMachine { ...@@ -331,8 +331,15 @@ class FileStateMachine implements IStateMachine {
* @return int * @return int
*/ */
public function GetStateVersion() { public function GetStateVersion() {
if (file_exists($this->settingsfilename)) if (file_exists($this->settingsfilename)) {
$settings = unserialize(file_get_contents($this->settingsfilename)); $settings = unserialize(file_get_contents($this->settingsfilename));
if (strtolower(gettype($settings) == "string") && strtolower($settings) == '2:1:{s:7:"version";s:1:"2";}') {
ZLog::Write(LOGLEVEL_INFO, "Broken state version file found. Attempt to autofix it. See https://jira.zarafa.com/browse/ZP-493 for more information.");
unlink($this->settingsfilename);
$this->SetStateVersion(IStateMachine::STATEVERSION_02);
$settings = array(self::VERSION => IStateMachine::STATEVERSION_02);
}
}
else { else {
$filecontents = @file_get_contents($this->userfilename); $filecontents = @file_get_contents($this->userfilename);
if ($filecontents) if ($filecontents)
...@@ -356,9 +363,9 @@ class FileStateMachine implements IStateMachine { ...@@ -356,9 +363,9 @@ class FileStateMachine implements IStateMachine {
*/ */
public function SetStateVersion($version) { public function SetStateVersion($version) {
if (file_exists($this->settingsfilename)) if (file_exists($this->settingsfilename))
$settings = file_get_contents($this->settingsfilename); $settings = unserialize(file_get_contents($this->settingsfilename));
else else
array(self::VERSION => IStateMachine::STATEVERSION_01); $settings = array(self::VERSION => IStateMachine::STATEVERSION_01);
$settings[self::VERSION] = $version; $settings[self::VERSION] = $version;
ZLog::Write(LOGLEVEL_INFO, sprintf("FileStateMachine->SetStateVersion() saving supported state version, value '%d'", $version)); ZLog::Write(LOGLEVEL_INFO, sprintf("FileStateMachine->SetStateVersion() saving supported state version, value '%d'", $version));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment