This commit is contained in:
2026-01-26 01:10:10 +01:00
parent d36ebfece5
commit b3f0a2ca4e
2 changed files with 17 additions and 17 deletions

View File

@@ -33,25 +33,22 @@ if (!$bootstrapLoaded) {
throw new RuntimeException('No environment config found under config/.');
}
$versionFiles = [__DIR__ . '/versions.php'];
if ($envHint) {
$versionFiles[] = __DIR__ . '/' . $envHint . '/versions.php';
}
$versionLoaded = false;
foreach ($versionFiles as $versionFile) {
if ($versionFile && is_file($versionFile)) {
require_once $versionFile;
$versionLoaded = true;
$versionText = null;
$versionFile = __DIR__ . '/version.txt';
if (is_file($versionFile)) {
$raw = trim((string)@file_get_contents($versionFile));
if ($raw !== '') {
$versionText = $raw;
}
}
if (!$versionLoaded) {
$mainversion = $mainversion ?? 1;
$subversion = $subversion ?? 0;
$patchversion = $patchversion ?? 0;
$mainversion = null;
$subversion = null;
$patchversion = null;
if ($versionText && preg_match('/^(\\d+)\\.(\\d+)\\.(\\d+)$/', $versionText, $m)) {
$mainversion = (int)$m[1];
$subversion = (int)$m[2];
$patchversion = (int)$m[3];
}
$mainversion = (int)($mainversion ?? 1);
$subversion = (int)($subversion ?? 0);
$patchversion = (int)($patchversion ?? 0);
$emailtemplateConfigPath = __DIR__ . '/emailtemplate.conf.php';
if (is_file($emailtemplateConfigPath)) {
@@ -63,7 +60,9 @@ if (is_file($emailtemplateConfigPath)) {
$GLOBALS['app_env'] = APP_ENV;
$GLOBALS['app_base_url'] = APP_URL_PRIMARY;
$GLOBALS['app_api_base'] = $apiBaseUrl;
$GLOBALS['app_version'] = "{$mainversion}.{$subversion}.{$patchversion}";
$GLOBALS['app_version'] = ($mainversion !== null && $subversion !== null && $patchversion !== null)
? "{$mainversion}.{$subversion}.{$patchversion}"
: null;
if (!function_exists('get_version_badge_markup')) {
function get_version_badge_markup(): string