Skip to content

Commit 524c355

Browse files
committed
Reword unlink errors if argument is a directory.
1 parent 92b51f1 commit 524c355

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed
32 Bytes
Binary file not shown.

ext/standard/tests/file/unlink_error-win32-mb.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ bool(false)
104104

105105
-- Testing unlink() on directory --
106106

107-
Warning: unlink(): Is a directory (%s/unlink_error) in %s on line %d
107+
Warning: unlink(): (%s/unlink_error) Is a directory in %s on line %d
108108
bool(false)
109109
Done

ext/standard/tests/file/unlink_error-win32.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ bool(false)
101101

102102
-- Testing unlink() on directory --
103103

104-
Warning: unlink(): Is a directory (%s/unlink_error) in %s on line %d
104+
Warning: unlink(): (%s/unlink_error) Is a directory in %s on line %d
105105
bool(false)
106106
Done

ext/standard/tests/file/unlink_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ bool(false)
101101

102102
-- Testing unlink() on directory --
103103

104-
Warning: unlink(): %r(Is a directory|Operation not permitted)%r (%s/unlink_error) in %s on line %d
104+
Warning: unlink(): %r(|Operation not permitted )%r(%s/unlink_error)%r( Is a directory|)%r in %s on line %d
105105
bool(false)
106106
Done

ext/standard/tests/file/unlink_variation10.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ directory unlinked
102102

103103
--- try to unlink a directory ---
104104

105-
Warning: unlink(): %r(Is a directory|Operation not permitted)%r (unlinkVar10.tmp/linkme.tmp) in %s on line %d
105+
Warning: unlink(): %r(|Operation not permitted )%r(unlinkVar10.tmp/linkme.tmp)%r( Is a directory|)%r in %s on line %d
106106
===DONE===

main/streams/plain_wrapper.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,12 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url,
11481148
ret = VCWD_UNLINK(url);
11491149
if (ret == -1) {
11501150
if (options & REPORT_ERRORS) {
1151-
php_error_docref(NULL, E_WARNING, "%s (%s)", strerror(errno), url);
1151+
/* If error is "Is directory" show url after error message */
1152+
if (errno == EISDIR) {
1153+
php_error_docref(NULL, E_WARNING, "(%s) %s", url, strerror(errno));
1154+
} else {
1155+
php_error_docref(NULL, E_WARNING, "%s (%s)", strerror(errno), url);
1156+
}
11521157
}
11531158
return 0;
11541159
}

0 commit comments

Comments
 (0)