Skip to content
Snippets Groups Projects
Unverified Commit 1beffa05 authored by Morris Jobke's avatar Morris Jobke
Browse files

Cache final result of update check


If the parsed data is not a valid response we should not cache it and only cache the preprocessed result set.

Fixes #7442

Signed-off-by: default avatarMorris Jobke <hey@morrisjobke.de>
parent 3da92a9a
No related branches found
No related tags found
No related merge requests found
...@@ -101,12 +101,10 @@ class VersionCheck { ...@@ -101,12 +101,10 @@ class VersionCheck {
} else { } else {
libxml_clear_errors(); libxml_clear_errors();
} }
} else {
$data = [];
} }
// Cache the result // Cache the result
$this->config->setAppValue('core', 'lastupdateResult', json_encode($data)); $this->config->setAppValue('core', 'lastupdateResult', json_encode($tmp));
return $tmp; return $tmp;
} }
......
...@@ -161,7 +161,7 @@ class VersionCheckTest extends \Test\TestCase { ...@@ -161,7 +161,7 @@ class VersionCheckTest extends \Test\TestCase {
$this->config $this->config
->expects($this->at(6)) ->expects($this->at(6))
->method('setAppValue') ->method('setAppValue')
->with('core', 'lastupdateResult', 'false'); ->with('core', 'lastupdateResult', '[]');
$updateXml = 'Invalid XML Response!'; $updateXml = 'Invalid XML Response!';
$this->updater $this->updater
...@@ -265,4 +265,55 @@ class VersionCheckTest extends \Test\TestCase { ...@@ -265,4 +265,55 @@ class VersionCheckTest extends \Test\TestCase {
$this->assertSame($expectedResult, $this->updater->check()); $this->assertSame($expectedResult, $this->updater->check());
} }
public function testCheckWithMissingAttributeXmlResponse() {
$expectedResult = [
'version' => '',
'versionstring' => '',
'url' => '',
'web' => '',
'autoupdater' => '',
];
$this->config
->expects($this->at(0))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue(0));
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
->expects($this->at(4))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
->expects($this->at(5))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
// missing autoupdater element should still not fail
$updateXml = '<?xml version="1.0"?>
<owncloud>
<version></version>
<versionstring></versionstring>
<url></url>
<web></web>
</owncloud>';
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment