Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

In the check_directory() and check_file() functions in help.php, ther…

…e 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
  • Loading branch information...
commit 107cd394f53ed63a9b46d2d3b3ce68d67104d251 1 parent b7dca9d
@MarkMaldaba MarkMaldaba authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 help.php
View
8 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";
Please sign in to comment.
Something went wrong with that request. Please try again.