diff --git a/classes/rpc.php b/classes/rpc.php index 84c9cfe92..af5bdf52c 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -590,15 +590,20 @@ class RPC extends Handler_Protected { function checkforupdates() { $rv = []; - if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && defined("GIT_VERSION_TIMESTAMP")) { + $git_timestamp = false; + $git_commit = false; + + get_version($git_commit, $git_timestamp); + + if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) { $content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]); if ($content) { $content = json_decode($content, true); if ($content && isset($content["changeset"])) { - if ((int)GIT_VERSION_TIMESTAMP < (int)$content["changeset"]["timestamp"] && - GIT_VERSION_HEAD != $content["changeset"]["id"]) { + if ($git_timestamp < (int)$content["changeset"]["timestamp"] && + $git_commit != $content["changeset"]["id"]) { $rv = $content["changeset"]; } diff --git a/include/functions.php b/include/functions.php index 0a3082ec1..18885b1ea 100644 --- a/include/functions.php +++ b/include/functions.php @@ -560,7 +560,6 @@ session_regenerate_id(true); $_SESSION["uid"] = $user_id; - $_SESSION["version"] = VERSION_STATIC; $_SESSION["auth_module"] = $auth_module; $pdo = DB::pdo(); diff --git a/include/version.php b/include/version.php index db5c2ec80..1851dea20 100644 --- a/include/version.php +++ b/include/version.php @@ -1,43 +1,30 @@ 0) { + list ($timestamp, $commit) = explode(" ", $output[0], 2); - if (!file_exists("$root_dir/.git/$ref")) - return VERSION_STATIC; - $suffix = substr(trim(file_get_contents("$root_dir/.git/$ref")), 0, 7); - $timestamp = filemtime("$root_dir/.git/$ref"); + $git_commit = $commit; + $git_timestamp = $timestamp; - define("GIT_VERSION_HEAD", $suffix); - define("GIT_VERSION_TIMESTAMP", $timestamp); - - return VERSION_STATIC . " ($suffix)"; - - } else { - $suffix = substr(trim($head), 0, 7); - $timestamp = filemtime("$root_dir/.git/HEAD"); - - define("GIT_VERSION_HEAD", $suffix); - define("GIT_VERSION_TIMESTAMP", $timestamp); - - return VERSION_STATIC . " ($suffix)"; + $version = strftime("%y.%m", $timestamp) . "-$commit"; } } } - return VERSION_STATIC; - + return $version; } define('VERSION', get_version());