From b0ad416de62c95c719ff8786bc8a238ed3139b2f Mon Sep 17 00:00:00 2001 From: William Allen <16820599+williamjallen@users.noreply.github.com> Date: Mon, 11 Dec 2023 13:23:55 -0500 Subject: [PATCH] Delete duplicate `version.php` configuration file (#1873) The laravel configuration file in `.../config/cdash.php` contains version information which duplicates the information in the legacy `version.php`. This PR eliminates the legacy configuration file, and migrates all of the version-checking code to Laravel's configuration system. --- app/Console/Commands/MigrateConfig.php | 2 -- app/Http/Controllers/AdminController.php | 11 ++--------- app/cdash/include/CDash/Config.php | 1 - app/cdash/include/ctestparser.php | 3 --- app/cdash/include/version.php | 21 --------------------- config/cdash.php | 1 - phpstan-baseline.neon | 2 +- 7 files changed, 3 insertions(+), 38 deletions(-) delete mode 100644 app/cdash/include/version.php diff --git a/app/Console/Commands/MigrateConfig.php b/app/Console/Commands/MigrateConfig.php index 93f7359458..d9191f9d55 100644 --- a/app/Console/Commands/MigrateConfig.php +++ b/app/Console/Commands/MigrateConfig.php @@ -85,7 +85,6 @@ public function handle() if (file_exists($config_dir . 'config.local.php')) { include $config_dir . 'config.local.php'; } - include $cdash_app_dir . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'version.php'; foreach (get_defined_vars() as $key => $value) { if (strpos($key, 'CDASH_') === 0) { $legacy_defaults[$key] = $value; @@ -122,7 +121,6 @@ public function handle() if (file_exists($config_dir . 'config.local.php')) { include $config_dir . 'config.local.php'; } - include $cdash_app_dir . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'version.php'; foreach (get_defined_vars() as $key => $value) { if ($key == 'OAUTH2_PROVIDERS') { foreach ($value as $k => $v) { diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 6a57b008d2..40c520758a 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -16,7 +16,6 @@ require_once 'include/api_common.php'; require_once 'include/ctestparser.php'; -require_once 'include/version.php'; require_once 'include/upgrade_functions.php'; final class AdminController extends AbstractController @@ -696,22 +695,16 @@ public function upgrade() */ public static function setVersion(): string { - $config = Config::getInstance(); - - $major = $config->get('CDASH_VERSION_MAJOR'); - $minor = $config->get('CDASH_VERSION_MINOR'); - $patch = $config->get('CDASH_VERSION_PATCH'); + $version = explode('.', config('cdash.version')); $stmt = DB::select('SELECT major FROM version'); - $version = [$major, $minor, $patch]; - if (count($stmt) === 0) { DB::insert('INSERT INTO version (major, minor, patch) VALUES (?, ?, ?)', $version); } else { DB::update('UPDATE version SET major=?, minor=?, patch=?', $version); } - return "$major.$minor.$patch"; + return config('cdash.version'); } public function install(): View diff --git a/app/cdash/include/CDash/Config.php b/app/cdash/include/CDash/Config.php index 1b15172b82..be8fe58530 100644 --- a/app/cdash/include/CDash/Config.php +++ b/app/cdash/include/CDash/Config.php @@ -8,7 +8,6 @@ class Config extends Singleton protected function __construct() { include 'config/config.php'; - include 'include/version.php'; $this->_config = get_defined_vars(); } diff --git a/app/cdash/include/ctestparser.php b/app/cdash/include/ctestparser.php index b9196b96ea..e46a46235d 100644 --- a/app/cdash/include/ctestparser.php +++ b/app/cdash/include/ctestparser.php @@ -180,9 +180,6 @@ function parse_put_submission($filehandler, $projectid, $expected_md5) /** Main function to parse the incoming xml from ctest */ function ctest_parse($filehandle, $projectid, $expected_md5 = '') { - - include 'include/version.php'; - // Check if this is a new style PUT submission. try { $handler = parse_put_submission($filehandle, $projectid, $expected_md5); diff --git a/app/cdash/include/version.php b/app/cdash/include/version.php deleted file mode 100644 index ff1b29f7b8..0000000000 --- a/app/cdash/include/version.php +++ /dev/null @@ -1,21 +0,0 @@ -