Skip to content

Commit

Permalink
fix version compare
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqi committed Jan 29, 2022
1 parent 1eedc48 commit 00c75d2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions var/Widget/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,17 @@ public function checkVersion()
$json = json_decode($response, true);

if (!empty($json)) {
[$soft, $version] = explode(' ', $this->options->generator);
$current = explode('/', $version);
$version = $this->options->version;

if (
isset($json['release']) && isset($json['version'])
isset($json['release'])
&& preg_match("/^[0-9\.]+$/", $json['release'])
&& preg_match("/^[0-9\.]+$/", $json['version'])
&& version_compare($json['release'], $current[0], '>=')
&& version_compare($json['version'], $current[1], '>')
&& version_compare($json['release'], $version, '>=')
) {
$result = [
'available' => 1,
'latest' => $json['release'] . '-' . $json['version'],
'current' => $current[0] . '-' . $current[1],
'latest' => $json['release'],
'current' => $version,
'link' => 'http://typecho.org/download'
];
}
Expand Down

0 comments on commit 00c75d2

Please sign in to comment.