Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ PHP 8.5 UPGRADE NOTES
. Using a printf-family function with a formatter that did not specify the
precision previously incorrectly reset the precision instead of treating
it as a precision of 0. See GH-18897.
. Passing an invalid flag value to the second argument of scandir() will now
throw a ValueError. Previously, it would silently use the
SCANDIR_SORT_DESCENDING value.

========================================
2. New Features
Expand Down
8 changes: 6 additions & 2 deletions ext/standard/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,13 @@ PHP_FUNCTION(scandir)
n = php_stream_scandir(dirn, &namelist, context, (void *) php_stream_dirent_alphasort);
} else if (flags == PHP_SCANDIR_SORT_NONE) {
n = php_stream_scandir(dirn, &namelist, context, NULL);
} else {
} else if (flags == PHP_SCANDIR_SORT_DESCENDING) {
n = php_stream_scandir(dirn, &namelist, context, (void *) php_stream_dirent_alphasortr);
}
} else {
zend_argument_value_error(2, "must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING and SCANDIR_SORT_NONE constants");
RETURN_THROWS();
}

if (n < 0) {
php_error_docref(NULL, E_WARNING, "(errno %d): %s", errno, strerror(errno));
RETURN_FALSE;
Expand Down
12 changes: 12 additions & 0 deletions ext/standard/tests/dir/scandir_invalid_flag.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Provide wrong flags to scandir()
--FILE--
<?php
try {
scandir('something', -1);
} catch (ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
scandir(): Argument #2 ($sorting_order) must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING and SCANDIR_SORT_NONE constants
71 changes: 0 additions & 71 deletions ext/standard/tests/dir/scandir_variation9-win32-mb.phpt

This file was deleted.

65 changes: 0 additions & 65 deletions ext/standard/tests/dir/scandir_variation9.phpt

This file was deleted.