Skip to content

Commit

Permalink
Remove remaining pre-3.0 upgrade logic (#1948)
Browse files Browse the repository at this point in the history
#1801 removed most of the CDash 2.x migration logic, and rendered the
upgrade button useless on `upgrade.php`. This PR eliminates the upgrade
button, and associated logic. Since the button was the last place using
the contents of the `version` database table, I created a migration to
delete it.
  • Loading branch information
williamjallen authored Jan 23, 2024
1 parent 023b451 commit a9cc461
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 375 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public/js/controllers/buildProperties.js
public/js/cdash_angular.js
public/js/cdashViewCoverage.js
public/js/cdashUploadFilesSorter.js
public/js/cdashUpgrade.js
public/js/cdashSortable.js
public/js/cdashSiteSorter.js
public/js/cdashProjectRole.js
Expand Down
34 changes: 0 additions & 34 deletions app/Console/Commands/SetVersion.php

This file was deleted.

59 changes: 3 additions & 56 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,53 +129,20 @@ public function upgrade()
$xml .= '<menutitle>CDash</menutitle>';
$xml .= '<menusubtitle>Maintenance</menusubtitle>';

// Should be the database version not the current on
$version = pdo_query('SELECT major,minor FROM version');
$version_array = pdo_fetch_array($version);
$xml .= '<minversion>' . $version_array['major'] . '.' . $version_array['minor'] . '</minversion>';

@$AssignBuildToDefaultGroups = $_POST['AssignBuildToDefaultGroups'];
@$FixBuildBasedOnRule = $_POST['FixBuildBasedOnRule'];
@$DeleteBuildsWrongDate = $_POST['DeleteBuildsWrongDate'];
@$CheckBuildsWrongDate = $_POST['CheckBuildsWrongDate'];
@$ComputeTestTiming = $_POST['ComputeTestTiming'];
@$ComputeUpdateStatistics = $_POST['ComputeUpdateStatistics'];

@$Upgrade = $_POST['Upgrade'];
@$Cleanup = $_POST['Cleanup'];
@$Dependencies = $_POST['Dependencies'];
@$Audit = $_POST['Audit'];
@$ClearAudit = $_POST['Clear'];

$configFile = $config->get('CDASH_ROOT_DIR') . "/AuditReport.log";

// When adding new tables they should be added to the SQL installation file
// and here as well
if ($Upgrade) {
// check if the backup directory is writable
if (!is_writable(Storage::path('inbox'))) {
$xml .= '<backupwritable>0</backupwritable>';
} else {
$xml .= '<backupwritable>1</backupwritable>';
}

// check if the log directory is writable
if ($config->get('CDASH_LOG_FILE') !== false && !is_writable($config->get('CDASH_LOG_DIRECTORY'))) {
$xml .= '<logwritable>0</logwritable>';
} else {
$xml .= '<logwritable>1</logwritable>';
}

// check if the upload directory is writable
if (!is_writable(Storage::path('upload'))) {
$xml .= '<uploadwritable>0</uploadwritable>';
} else {
$xml .= '<uploadwritable>1</uploadwritable>';
}

$xml .= '<upgrade>1</upgrade>';
}

// Compress the test output
if (isset($_POST['CompressTestOutput'])) {
// Do it slowly so we don't take all the memory
Expand Down Expand Up @@ -366,23 +333,6 @@ public function upgrade()
->with('xsl_content', generate_XSLT($xml, base_path() . '/app/cdash/public/upgrade', true));
}

/**
* Set the CDash version number in the database
*/
public static function setVersion(): string
{
$version = explode('.', config('cdash.version'));

$stmt = DB::select('SELECT major FROM version');
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 config('cdash.version');
}

public function install(): View
{
@set_time_limit(0);
Expand Down Expand Up @@ -560,7 +510,7 @@ public function install(): View
$query = '';
foreach ($file_content as $sql_line) {
$tsl = trim($sql_line);
if (($sql_line != '') && (substr($tsl, 0, 2) != '--')) {
if ($sql_line !== '' && !str_starts_with($tsl, '--')) {
$query .= $sql_line;
$possemicolon = strrpos($query, ';');
if ($possemicolon !== false && substr_count($query, '\'', 0, $possemicolon) % 2 == 0) {
Expand All @@ -572,7 +522,7 @@ public function install(): View
$result = pdo_query($query);
if (!$result) {
$xml .= '<db_created>0</db_created>';
die(pdo_error());
abort(500, pdo_error());
}
$query = '';
}
Expand All @@ -582,7 +532,7 @@ public function install(): View
// Check the version of PostgreSQL
$result_version = pdo_query('SELECT version()');
$version_array = pdo_fetch_array($result_version);
if (strpos(strtolower($version_array[0]), 'postgresql 9.') !== false) {
if (str_contains(strtolower($version_array[0]), 'postgresql 9.')) {
// For PgSQL 9.0 we need to set the bytea_output to 'escape' (it was changed to hexa)
@pdo_query("ALTER DATABASE {$db_name} SET bytea_output TO 'escape'");
}
Expand All @@ -596,9 +546,6 @@ public function install(): View
$user->Admin = 1;
$user->Save();
$xml .= '<db_created>1</db_created>';

// Set the database version
$this::setVersion();
}
}
}
Expand Down
201 changes: 0 additions & 201 deletions app/cdash/public/js/cdashUpgrade.js

This file was deleted.

Loading

0 comments on commit a9cc461

Please sign in to comment.