Skip to content

Commit

Permalink
Remove legacy configuration system (#2228)
Browse files Browse the repository at this point in the history
This PR removes the last traces of our legacy configuration system.
While somewhat substantial in size, I made an attempt to break this into
incremental commits, which may be easier to review.
  • Loading branch information
williamjallen authored May 31, 2024
1 parent 0803420 commit 79af657
Show file tree
Hide file tree
Showing 41 changed files with 67 additions and 1,171 deletions.
226 changes: 0 additions & 226 deletions app/Console/Commands/MigrateConfig.php

This file was deleted.

16 changes: 2 additions & 14 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use App\Models\User;
use App\Validators\Password;
use CDash\Config;
use CDash\Model\Project;
use Exception;
use Illuminate\Http\RedirectResponse;
Expand Down Expand Up @@ -121,8 +120,6 @@ public function removeBuilds(): View|RedirectResponse

public function upgrade()
{
$config = Config::getInstance();

@set_time_limit(0);

$xml = begin_XML_for_XSLT();
Expand All @@ -141,7 +138,7 @@ public function upgrade()
@$Audit = $_POST['Audit'];
@$ClearAudit = $_POST['Clear'];

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

// Compute the testtime
if ($ComputeTestTiming) {
Expand Down Expand Up @@ -323,8 +320,6 @@ public function install(): View
->with('xsl_content', '<font color="#FF0000">Your PHP installation does not support XSL. Please install the XSL extension.</font>');
}

$config = Config::getInstance();

if (config('app.env') === 'production') {
return $this->view('cdash', 'Installation')
->with('xsl', true)
Expand Down Expand Up @@ -394,13 +389,6 @@ public function install(): View
$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>';
Expand Down Expand Up @@ -479,7 +467,7 @@ public function install(): View

// If we are with PostGreSQL we need to add some extra functions
if ($db_type == 'pgsql') {
$sqlfile = $config->get('CDASH_ROOT_DIR') . '/sql/pgsql/cdash.ext.sql';
$sqlfile = base_path('/app/cdash/sql/pgsql/cdash.ext.sql');

// Create the language. PgSQL has no way to know if the language already
// exists
Expand Down
8 changes: 1 addition & 7 deletions app/Http/Controllers/CoverageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use App\Models\User;
use App\Utils\PageTimer;
use App\Utils\TestingDay;
use CDash\Config;
use CDash\Database;
use CDash\Model\Build;
use CDash\Model\Coverage;
Expand Down Expand Up @@ -260,15 +259,10 @@ public function manageCoverage(): View|RedirectResponse

$messagePlainText .= 'Details on the submission can be found at ';

$config = Config::getInstance();
$messagePlainText .= url('/');
$messagePlainText .= "\n\n";
$serverName = $config->get('CDASH_SERVER_NAME');
if (strlen($serverName) == 0) {
$serverName = $_SERVER['SERVER_NAME'];
}

$messagePlainText .= "\n-CDash on " . $serverName . "\n";
$messagePlainText .= "\n-CDash\n";

// Send the email
$title = 'CDash [' . $Project->GetName() . '] - Low Coverage';
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Controllers/ManageProjectRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace App\Http\Controllers;

use App\Models\User;
use CDash\Config;
use CDash\Database;
use CDash\Model\Project;
use App\Models\Project as EloquentProject;
Expand Down Expand Up @@ -395,8 +394,7 @@ public function viewPage(): View|RedirectResponse
}
}

$config = Config::getInstance();
if ($config->get('CDASH_FULL_EMAIL_WHEN_ADDING_USER') == 1) {
if ((bool) config('require_full_email_when_adding_user')) {
$xml .= add_XML_value('fullemail', '1');
}
if ((config('auth.project_admin_registration_form_enabled') === true) || $current_user->admin) {
Expand Down Expand Up @@ -511,7 +509,7 @@ public function ajaxFindUserProject(): View

$search = $_GET['search'] ?? '';
$params = [];
if (intval(Config::getInstance()->get('CDASH_FULL_EMAIL_WHEN_ADDING_USER')) === 1) {
if ((bool) config('require_full_email_when_adding_user')) {
$sql = 'email=?';
$params[] = $search;
} else {
Expand Down
7 changes: 2 additions & 5 deletions app/Http/Controllers/ManageUsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace App\Http\Controllers;

use App\Models\User;
use CDash\Config;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;
Expand Down Expand Up @@ -76,16 +75,14 @@ public function showPage(): View|RedirectResponse
->with('warning', $warning)
->with('error', $error)
->with('search', $_POST['search'] ?? '')
->with('fullemail', Config::getInstance()->get('CDASH_FULL_EMAIL_WHEN_ADDING_USER'));
->with('fullemail', boolval(config('require_full_email_when_adding_user')) ? 1 : 0);
}

public function ajaxFindUsers(): View
{
$config = Config::getInstance();

$search = trim($_GET['search'] ?? '');
if ($search !== '') {
if ($config->get('CDASH_FULL_EMAIL_WHEN_ADDING_USER') == 1) {
if ((bool) config('require_full_email_when_adding_user')) {
$sql = "email=?";
$params = [$search];
} else {
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App\Http\Controllers;

use App\Utils\PageTimer;
use CDash\Config;
use CDash\Model\Project;
use CDash\Model\Repository;
use CDash\Model\UserProject;
Expand All @@ -18,7 +17,6 @@ final class ProjectController extends AbstractProjectController
public function apiCreateProject(): JsonResponse
{
$pageTimer = new PageTimer();
$config = Config::getInstance();

if (isset($_GET['projectid'])) {
// We're editing a project if a projectid was specified
Expand Down
Loading

0 comments on commit 79af657

Please sign in to comment.