From 00c75d2f75c1399512f0f93aa152e4f49b00d661 Mon Sep 17 00:00:00 2001 From: joyqi Date: Sun, 30 Jan 2022 00:30:28 +0800 Subject: [PATCH] fix version compare --- var/Widget/Ajax.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/var/Widget/Ajax.php b/var/Widget/Ajax.php index 68e19de363..01a774b73f 100644 --- a/var/Widget/Ajax.php +++ b/var/Widget/Ajax.php @@ -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' ]; }