Skip to content

Commit

Permalink
Delete duplicate version.php configuration file (#1873)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
williamjallen committed Dec 11, 2023
1 parent b586b0b commit b0ad416
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 38 deletions.
2 changes: 0 additions & 2 deletions app/Console/Commands/MigrateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 2 additions & 9 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/cdash/include/CDash/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Config extends Singleton
protected function __construct()
{
include 'config/config.php';
include 'include/version.php';
$this->_config = get_defined_vars();
}

Expand Down
3 changes: 0 additions & 3 deletions app/cdash/include/ctestparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 0 additions & 21 deletions app/cdash/include/version.php

This file was deleted.

1 change: 0 additions & 1 deletion config/cdash.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// read in all of our cdash config files
if ($cdash) {
include_once $cdash . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
include_once $cdash . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'version.php';
}

$unlimited_projects = json_decode(env('UNLIMITED_PROJECTS', ''), true);
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ parameters:
#^Call to deprecated method get\\(\\) of class CDash\\\\Config\\:
09/04/2023 Use config\\(\\) instead\\.$#
"""
count: 12
count: 9
path: app/Http/Controllers/AdminController.php

-
Expand Down

0 comments on commit b0ad416

Please sign in to comment.