Skip to content

Commit

Permalink
QA: Add more checks to is_resource_writable()
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Apr 8, 2023
1 parent 78dd0aa commit 2ce9a9c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,9 @@ function is_resource_writable(string $path) {
}

if (file_exists($path)) {
if (is_writable($path) && ($f = @fopen($path, 'a'))) {
if (is_writable($path)) {
return true;
} elseif ($f = @fopen($path, 'a')) {
fclose($f);

return true;
Expand All @@ -7563,7 +7565,9 @@ function is_resource_writable(string $path) {
return false;
}

if (is_writable($path) && ($f = @fopen($path, 'w'))) {
if (is_writable($path)) {
return true;
} elseif ($f = @fopen($path, 'w')) {
fclose($f);
unlink($path);

Expand Down

0 comments on commit 2ce9a9c

Please sign in to comment.