Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cdash_unlink() helper #2650

Merged
merged 1 commit into from
Jan 6, 2025
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
5 changes: 2 additions & 3 deletions app/cdash/include/dailyupdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,8 @@ function addDailyChanges(int $projectid): void
$files = Storage::allFiles($dir_to_clean);
foreach ($files as $filename) {
$filepath = Storage::path($filename);
if (file_exists($filepath) && is_file($filepath) &&
time() - filemtime($filepath) > $timeframe * 3600) {
cdash_unlink($filepath);
if (file_exists($filepath) && is_file($filepath) && time() - filemtime($filepath) > $timeframe * 3600) {
Storage::delete($filepath);
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions app/cdash/include/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
use Illuminate\Support\Facades\Log;
use \Psr\Log\LogLevel;

if (!function_exists('cdash_unlink')) {
function cdash_unlink($filename)
{
unlink($filename);

if (file_exists($filename)) {
throw new Exception("file still exists after unlink: $filename");
}

return true;
}
}

if (!function_exists('to_psr3_level')) {
function to_psr3_level($type)
{
Expand Down
18 changes: 9 additions & 9 deletions app/cdash/xml_handlers/upload_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ public function endElement($parser, $name): void
unset($whandle);

// Delete base64 encoded file
$success = cdash_unlink($this->Base64TmpFilename);
if (!$success) {
if (!unlink($this->Base64TmpFilename)) {
Log::warning("Failed to delete file '{$this->Base64TmpFilename}'");
}

Expand All @@ -195,7 +194,9 @@ public function endElement($parser, $name): void
if ($upload_file_size > $this->GetProject()->UploadQuota) {
Log::error("Size of uploaded file {$this->TmpFilename} is {$upload_file_size} bytes, which is greater than the total upload quota for this project ({$this->GetProject()->UploadQuota} bytes)");
$this->UploadError = true;
cdash_unlink($this->TmpFilename);
if (!unlink($this->TmpFilename)) {
Log::warning("Failed to delete file '{$this->TmpFilename}'");
}
return;
}

Expand Down Expand Up @@ -227,7 +228,7 @@ public function endElement($parser, $name): void
$fp_to_upload = fopen($this->TmpFilename, 'r');
if ($fp_to_upload === false) {
Log::error("Failed to open temporary file {$this->TmpFilename} for upload");
cdash_unlink($this->TmpFilename);
unlink($this->TmpFilename);
$this->UploadError = true;
return;
}
Expand All @@ -239,7 +240,7 @@ public function endElement($parser, $name): void
fclose($fp_to_upload);
if (!$response->successful()) {
Log::error('Error uploading file via API: ' . $response->status() . ' ' . $response->body());
cdash_unlink($this->TmpFilename);
unlink($this->TmpFilename);
$this->UploadError = true;
return;
}
Expand All @@ -251,13 +252,13 @@ public function endElement($parser, $name): void
$fileToUpload = new File($this->TmpFilename);
} catch (FileNotFoundException $e) {
Log::error("Could not find file {$this->TmpFilename} to upload");
cdash_unlink($this->TmpFilename);
unlink($this->TmpFilename);
$this->UploadError = true;
return;
}
if (Storage::putFileAs('upload', $fileToUpload, (string) $this->UploadFile->Sha1Sum) === false) {
Log::error("Failed to store {$this->TmpFilename} as {$uploadFilepath}");
cdash_unlink($this->TmpFilename);
unlink($this->TmpFilename);
$this->UploadError = true;
return;
}
Expand All @@ -266,8 +267,7 @@ public function endElement($parser, $name): void
}

// Delete decoded temporary file.
$success = cdash_unlink($this->TmpFilename);
if (!$success) {
if (!unlink($this->TmpFilename)) {
Log::error("Failed to delete file '{$this->TmpFilename}");
}

Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15200,16 +15200,6 @@ parameters:
count: 1
path: app/cdash/include/log.php

-
message: "#^Function cdash_unlink\\(\\) has no return type specified\\.$#"
count: 1
path: app/cdash/include/log.php

-
message: "#^Function cdash_unlink\\(\\) has parameter \\$filename with no type specified\\.$#"
count: 1
path: app/cdash/include/log.php

-
message: "#^Function to_psr3_level\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Loading