From 107cd394f53ed63a9b46d2d3b3ce68d67104d251 Mon Sep 17 00:00:00 2001 From: "MarkMaldaba (aka HappyDog)" Date: Sat, 28 Apr 2012 15:34:05 +0100 Subject: [PATCH] In the check_directory() and check_file() functions in help.php, there are a bunch of checks that will fail with a PHP notice if the file/directory doesn't exist. Also, checks such as whether the file is readable are a bit meaningless for non-existent items. This commit updates the functions so that they bail out after the first test if the item does not exist. This avoids the PHP errors and meaningless information that is otherwise displayed. Logged as an issue at ProjectPier, with patch file attached: http://www.projectpier.org/node/3244 --- help.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/help.php b/help.php index e52b7cb..35fb2a3 100644 --- a/help.php +++ b/help.php @@ -4,6 +4,10 @@ function check_directory($d) { echo "\nDirectory $d\n"; echo '1.' . ( file_exists($d) ? ' exists' : ' does NOT exist' ) . " \n"; + if (!file_exists($d)) { + echo 'Remaining checks skipped' . " \n"; + return; + } echo '2. is' . ( is_dir($d) ? '' : ' NOT' ) . " a directory\n"; echo '3. is' . ( is_readable($d) ? '' : ' NOT' ) . " readable\n"; echo '4. is' . ( is_writable($d) ? '' : ' NOT' ) . " writable\n"; @@ -26,6 +30,10 @@ function check_directory($d) { function check_file($f) { echo "\nFile $f\n"; echo '1.' . ( file_exists($f) ? ' exists' : ' does NOT exist' ) . " \n"; + if (!file_exists($f)) { + echo 'Remaining checks skipped' . " \n"; + return; + } echo '2. is' . ( is_file($f) ? '' : ' NOT' ) . " a file\n"; echo '3. is' . ( is_readable($f) ? '' : ' NOT' ) . " readable\n"; echo '4. is' . ( is_writable($f) ? '' : ' NOT' ) . " writable\n";