diff --git a/config/fileload.php b/config/fileload.php index d5920dd..cc48b4e 100644 --- a/config/fileload.php +++ b/config/fileload.php @@ -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 diff --git a/config/version.txt b/config/version.txt new file mode 100644 index 0000000..9084fa2 --- /dev/null +++ b/config/version.txt @@ -0,0 +1 @@ +1.1.0