Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/Jobs/ProcessSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,31 @@ public function __construct($filename, $projectid, $buildid, $expected_md5)
$this->expected_md5 = $expected_md5;
}

private function renameSubmissionFile($src, $dst)
private function renameSubmissionFile($src, $dst): bool
{
if (config('cdash.remote_workers')) {
$url = config('app.url') . '/api/v1/deleteSubmissionFile.php';
$client = new \GuzzleHttp\Client();
$response = $client->request('DELETE', $url, ['query' => ['filename' => $src, 'dest' => $dst]]);
return $response->getStatusCode() == 200;
return $response->getStatusCode() === 200;
} else {
return Storage::move($src, $dst);
}
return false;
}

private function deleteSubmissionFile($filename)
private function deleteSubmissionFile($filename): bool
{
if (config('cdash.remote_workers')) {
$url = config('app.url') . '/api/v1/deleteSubmissionFile.php';
$client = new \GuzzleHttp\Client();
$response = $client->request('DELETE', $url, ['query' => ['filename' => $filename]]);
return $response->getStatusCode() == 200;
return $response->getStatusCode() === 200;
} else {
return Storage::delete($filename);
}
return false;
}

private function requeueSubmissionFile($buildid)
private function requeueSubmissionFile($buildid): bool
{
if (config('cdash.remote_workers')) {
$url = config('app.url') . '/api/v1/requeueSubmissionFile.php';
Expand Down Expand Up @@ -124,7 +122,7 @@ public function handle()
// Resubmit the file if necessary.
if (is_a($handler, 'DoneHandler') && $handler->shouldRequeue()) {
$build = $this->getBuildFromHandler($handler);
return $this->requeueSubmissionFile($build->Id);
$this->requeueSubmissionFile($build->Id);
}

if (config('cdash.backup_timeframe') === 0) {
Expand Down Expand Up @@ -158,6 +156,8 @@ public function failed(\Throwable $exception)
private function doSubmit($filename, $projectid, $buildid = null,
$expected_md5 = '')
{
$config = Config::getInstance();

$filehandle = $this->getSubmissionFileHandle($filename);
if ($filehandle === false) {
return false;
Expand All @@ -176,15 +176,15 @@ private function doSubmit($filename, $projectid, $buildid = null,

// We find the daily updates
// If we have php curl we do it asynchronously
$baseUrl = get_server_URI(false);
$baseUrl = $config->getBaseUrl();
$request = $baseUrl . '/ajax/dailyupdatescurl.php?projectid=' . $projectid;

if (config('cdash.daily_updates') && $this->curlRequest($request) === false) {
return false;
}

// Parse the XML file
$handler = ctest_parse($filehandle, $projectid, $buildid, $expected_md5);
$handler = ctest_parse($filehandle, $projectid, $expected_md5);
fclose($filehandle);
unset($filehandle);

Expand Down
5 changes: 0 additions & 5 deletions app/cdash/app/Controller/Api/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ public function getResponse()
switch ($page) {
case 'buildProperties.php':
return $this->chartForBuildProperties();
break;
case 'index.php':
return $this->chartForIndex();
break;
case 'testOverview.php':
return $this->chartForTestOverview();
break;
case 'viewBuildGroup.php':
return $this->chartForBuildGroup();
break;
default:
json_error_response('Unexpected value for page');
break;
Expand Down Expand Up @@ -230,7 +226,6 @@ private function chartForBuildGroup()
$this->colors[self::FAILURE],
$this->colors[self::ERROR]
];
$build_data = [];

$group_type = $buildgroup->GetType();
if ($group_type == 'Daily') {
Expand Down
3 changes: 0 additions & 3 deletions app/cdash/app/Controller/Api/ViewNotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

class ViewNotes extends BuildApi
{
private $extraMeasurements;
private $numExtraMeasurements;

public function __construct(Database $db, Build $build)
{
parent::__construct($db, $build);
Expand Down
8 changes: 1 addition & 7 deletions app/cdash/app/Controller/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Session
{
const EXTEND_GC_LIFETIME = 600;
const CACHE_NOCACHE = 'nocache';
const CACHE_PRIVATE_NO_EXPIRE = 'private_no_expire';

private $system;

Expand Down Expand Up @@ -83,7 +82,7 @@ public function exists()
*/
public function destroy()
{
$this->system->session_destroy();
session_destroy();

// TODO: explicit where the class is implicit, pick one
if (isset($_SESSION['cdash'])) {
Expand Down Expand Up @@ -119,9 +118,4 @@ public function isActive()
{
return $this->getStatus() === PHP_SESSION_ACTIVE;
}

public function writeClose()
{
$this->system->session_write_close();
}
}
9 changes: 6 additions & 3 deletions app/cdash/app/Model/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,8 @@ public function Save()

if ($hasErrors) {
$message = "$this->Name experienced errors";
$url = get_server_URI(false) .
$config = Config::getInstance();
$url = $config->getBaseUrl() .
"/viewBuildError.php?buildid=$this->Id";
$this->NotifyPullRequest($message, $url);
}
Expand Down Expand Up @@ -998,7 +999,8 @@ public function UpdateTestNumbers($numberTestsPassed, $numberTestsFailed, $numbe
// Should we should post test failures to a pull request?
if (!empty($this->PullRequest) && $numberTestsFailed > 0) {
$message = "$this->Name experienced failing tests";
$url = get_server_URI(false) .
$config = Config::getInstance();
$url = $config->getBaseUrl() .
"/viewTest.php?onlyfailed&buildid=$this->Id";
$this->NotifyPullRequest($message, $url);
}
Expand Down Expand Up @@ -2152,7 +2154,8 @@ public function SetNumberOfConfigureErrors($numErrors)
// Should we post configure errors to a pull request?
if (!empty($this->PullRequest) && $numErrors > 0) {
$message = "$this->Name failed to configure";
$url = get_server_URI(false) .
$config = Config::getInstance();
$url = $config->getBaseUrl() .
"/build/{$this->Id}/configure";
$this->NotifyPullRequest($message, $url);
}
Expand Down
12 changes: 0 additions & 12 deletions app/cdash/app/Model/BuildConfigure.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ public function __construct()
$this->PDO = Database::getInstance()->getPdo();
}

public function AddError($error)
{
$error->BuildId = $this->BuildId;
$error->Save();
}

public function AddErrorDifference($diff)
{
$diff->BuildId = $this->BuildId;
$diff->Save();
}

public function AddLabel($label)
{
$label->BuildId = $this->BuildId;
Expand Down
64 changes: 0 additions & 64 deletions app/cdash/app/Model/BuildEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,6 @@ public static function Log(NotificationInterface $notification, $sent)
}
}

/**
* Returns the record of a previously sent email given a user, a build, and a category.
*
* @param $userId
* @param $buildId
* @param $category
* @return BuildEmail
*/
public static function GetBuildEmailForUser($userId, $buildId, $category)
{
$buildEmail = new BuildEmail();

$sql = 'SELECT time FROM buildemail WHERE userid=:u AND buildid=:b AND category=:c LIMIT 1';
$db = Database::getInstance();
$stmt = $db->prepare($sql);
$stmt->bindParam(':u', $userId);
$stmt->bindParam(':b', $buildId);
$stmt->bindParam(':c', $category);
if ($db->execute($stmt)) {
$count = $stmt->rowCount();
if ($count) {
$time = $stmt->fetchColumn(0);
$buildEmail
->SetSent(true)
->SetUserId($userId)
->SetBuildId($buildId)
->SetTime($time);
}
}
return $buildEmail;
}

/**
* Returns a collection of emails sent given a build and category.
*
Expand Down Expand Up @@ -201,30 +169,6 @@ public function GetEmail()
return $this->Email;
}

/**
* @return bool
*/
public function WasSent()
{
return $this->Sent;
}

/**
* @return int
*/
public function GetUserId()
{
return $this->UserId;
}

/**
* @return int
*/
public function GetBuildId()
{
return $this->BuildId;
}

/**
* @return int
*/
Expand All @@ -233,14 +177,6 @@ public function GetCategory()
return $this->Category;
}

/**
* @return string
*/
public function GetTime()
{
return $this->Time;
}

/**
* @param $email
* @return $this
Expand Down
15 changes: 0 additions & 15 deletions app/cdash/app/Model/BuildFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ public function Insert()
]);
}

// Returns the buildid associated with this file's MD5 if it has been
// uploaded previously, false otherwise.
public function MD5Exists()
{
// Check if we already have a row
$existing_row =
\DB::table('buildfile')
->where('md5', $this->md5)
->first();
if (!$existing_row) {
return false;
}
return $existing_row->buildid;
}

/** Delete this BuildFile */
public function Delete()
{
Expand Down
15 changes: 0 additions & 15 deletions app/cdash/app/Model/BuildGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ public function GetStartTime()
return $this->StartTime;
}

public function SetStartTime($time)
{
$this->StartTime = pdo_real_escape_string($time);
}

/** Get/Set the end time */
public function GetEndTime()
{
if ($this->Id < 1) {
add_log('BuildGroup GetEndTime(): Id not set', 'GetEndTime', LOG_ERR);
return false;
}
return $this->EndTime;
}

public function SetEndTime($time)
{
$this->EndTime = pdo_real_escape_string($time);
Expand Down
33 changes: 7 additions & 26 deletions app/cdash/include/CDash/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,13 @@ public function set($name, $value)
$this->_config[$name] = $value;
}

/**
* @return string
*/
public static function getVersion()
public static function getVersion(): string
{
return file_get_contents(public_path('VERSION'));
}

/**
* @param bool $use_localhost
* @return string
*/
public function getServer($use_localhost = false)
public function getServer(): string
{
if ($use_localhost) {
return 'localhost';
}

$server = $this->get('CDASH_SERVER_NAME');
if (empty($server)) {
if (isset($_SERVER['SERVER_NAME'])) {
Expand All @@ -53,10 +42,7 @@ public function getServer($use_localhost = false)
return $server;
}

/**
* @return string
*/
public function getProtocol()
public function getProtocol(): string
{
$protocol = 'http';
if ($this->get('CDASH_USE_HTTPS') ||
Expand All @@ -78,27 +64,22 @@ public function getServerPort()
}
}

public function getPath()
public function getPath(): string
{
$path = config('cdash.curl_localhost_prefix') ?: $_SERVER['REQUEST_URI'];
if (strpos($path, '/') !== 0) {
if (!str_starts_with($path, '/')) {
$path = "/{$path}";
}
return $path;
}


/**
* @param bool $use_localhost
* @return string
*/
public function getBaseUrl($use_localhost = false)
public function getBaseUrl(): string
{
$uri = config('app.url');

if (!$uri) {
$protocol = $this->getProtocol();
$host = $this->getServer($use_localhost);
$host = $this->getServer();
$port = $this->getServerPort() ? ":{$this->getServerPort()}" : '';
$path = $this->getPath();

Expand Down
Loading