From 2ce9a9c3f699539afcd65bd9eb85eb47ce50a4e0 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sat, 8 Apr 2023 10:08:45 -0400 Subject: [PATCH] QA: Add more checks to is_resource_writable() --- lib/functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index 5c8d88ef34..6718f6443e 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -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; @@ -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);