Skip to content

Commit 216fede

Browse files
committed
Remove HAVE_GLOBs
We now always have a glob implementation that works. HAVE_GLOB should only be used to check if we have a system implementation, for if we decide to wrap the system implementation instead.
1 parent 8264628 commit 216fede

9 files changed

+3
-39
lines changed

Zend/Optimizer/zend_func_infos.h

-2
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,7 @@ static const func_info_t func_infos[] = {
518518
F1("getcwd", MAY_BE_STRING|MAY_BE_FALSE),
519519
F1("readdir", MAY_BE_STRING|MAY_BE_FALSE),
520520
F1("scandir", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
521-
#if defined(HAVE_GLOB)
522521
F1("glob", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
523-
#endif
524522
F1("exec", MAY_BE_STRING|MAY_BE_FALSE),
525523
F1("system", MAY_BE_STRING|MAY_BE_FALSE),
526524
F1("escapeshellcmd", MAY_BE_STRING),

ext/spl/spl_directory.c

-10
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ static inline bool spl_intern_is_glob(const spl_filesystem_object *intern)
211211

212212
PHPAPI zend_string *spl_filesystem_object_get_path(const spl_filesystem_object *intern) /* {{{ */
213213
{
214-
#ifdef HAVE_GLOB
215214
if (intern->type == SPL_FS_DIR && spl_intern_is_glob(intern)) {
216215
size_t len = 0;
217216
char *tmp = php_glob_stream_get_path(intern->u.dir.dirp, &len);
@@ -220,7 +219,6 @@ PHPAPI zend_string *spl_filesystem_object_get_path(const spl_filesystem_object *
220219
}
221220
return zend_string_init(tmp, len, /* persistent */ false);
222221
}
223-
#endif
224222
if (!intern->path) {
225223
return NULL;
226224
}
@@ -641,14 +639,12 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec
641639
spl_set_private_debug_info_property(spl_ce_SplFileInfo, "fileName", strlen("fileName"), debug_info, &tmp);
642640
}
643641
if (intern->type == SPL_FS_DIR) {
644-
#ifdef HAVE_GLOB
645642
if (spl_intern_is_glob(intern)) {
646643
ZVAL_STR_COPY(&tmp, intern->path);
647644
} else {
648645
ZVAL_FALSE(&tmp);
649646
}
650647
spl_set_private_debug_info_property(spl_ce_DirectoryIterator, "glob", strlen("glob"), debug_info, &tmp);
651-
#endif
652648
if (intern->u.dir.sub_path) {
653649
ZVAL_STR_COPY(&tmp, intern->u.dir.sub_path);
654650
} else {
@@ -721,13 +717,11 @@ static void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_l
721717

722718
/* spl_filesystem_dir_open() may emit an E_WARNING */
723719
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
724-
#ifdef HAVE_GLOB
725720
if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_GLOB) && !zend_string_starts_with_literal(path, "glob://")) {
726721
path = zend_strpprintf(0, "glob://%s", ZSTR_VAL(path));
727722
spl_filesystem_dir_open(intern, path);
728723
zend_string_release(path);
729724
} else
730-
#endif
731725
{
732726
spl_filesystem_dir_open(intern, path);
733727

@@ -1582,7 +1576,6 @@ PHP_METHOD(RecursiveDirectoryIterator, __construct)
15821576
}
15831577
/* }}} */
15841578

1585-
#ifdef HAVE_GLOB
15861579
/* {{{ Cronstructs a new dir iterator from a glob expression (no glob:// needed). */
15871580
PHP_METHOD(GlobIterator, __construct)
15881581
{
@@ -1607,7 +1600,6 @@ PHP_METHOD(GlobIterator, count)
16071600
RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
16081601
}
16091602
/* }}} */
1610-
#endif /* HAVE_GLOB */
16111603

16121604
/* {{{ forward declarations to the iterator handlers */
16131605
static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter);
@@ -2782,11 +2774,9 @@ PHP_MINIT_FUNCTION(spl_directory)
27822774
spl_filesystem_object_check_handlers.clone_obj = NULL;
27832775
spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check;
27842776

2785-
#ifdef HAVE_GLOB
27862777
spl_ce_GlobIterator = register_class_GlobIterator(spl_ce_FilesystemIterator, zend_ce_countable);
27872778
spl_ce_GlobIterator->create_object = spl_filesystem_object_new;
27882779
spl_ce_GlobIterator->default_object_handlers = &spl_filesystem_object_check_handlers;
2789-
#endif
27902780

27912781
spl_ce_SplFileObject = register_class_SplFileObject(spl_ce_SplFileInfo, spl_ce_RecursiveIterator, spl_ce_SeekableIterator);
27922782
spl_ce_SplFileObject->default_object_handlers = &spl_filesystem_object_check_handlers;

ext/spl/spl_directory.stub.php

-2
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,13 @@ public function getSubPath(): string {}
207207
public function getSubPathname(): string {}
208208
}
209209

210-
#ifdef HAVE_GLOB
211210
class GlobIterator extends FilesystemIterator implements Countable
212211
{
213212
public function __construct(string $pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
214213

215214
/** @tentative-return-type */
216215
public function count(): int {}
217216
}
218-
#endif
219217

220218
class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
221219
{

ext/spl/spl_directory_arginfo.h

+2-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions.c

-2
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
339339

340340
php_register_url_stream_wrapper("php", &php_stream_php_wrapper);
341341
php_register_url_stream_wrapper("file", &php_plain_files_wrapper);
342-
#ifdef HAVE_GLOB
343342
php_register_url_stream_wrapper("glob", &php_glob_stream_wrapper);
344-
#endif
345343
php_register_url_stream_wrapper("data", &php_stream_rfc2397_wrapper);
346344
php_register_url_stream_wrapper("http", &php_stream_http_wrapper);
347345
php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper);

ext/standard/basic_functions.stub.php

-2
Original file line numberDiff line numberDiff line change
@@ -2687,13 +2687,11 @@ function readdir($dir_handle = null): string|false {}
26872687
*/
26882688
function scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array|false {}
26892689

2690-
#ifdef HAVE_GLOB
26912690
/**
26922691
* @return array<int, string>|false
26932692
* @refcount 1
26942693
*/
26952694
function glob(string $pattern, int $flags = 0): array|false {}
2696-
#endif
26972695

26982696
/* exec.c */
26992697

ext/standard/basic_functions_arginfo.h

+1-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main/streams/plain_wrapper.c

-2
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,9 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, const
10881088
DIR *dir = NULL;
10891089
php_stream *stream = NULL;
10901090

1091-
#ifdef HAVE_GLOB
10921091
if (options & STREAM_USE_GLOB_DIR_OPEN) {
10931092
return php_glob_stream_wrapper.wops->dir_opener((php_stream_wrapper*)&php_glob_stream_wrapper, path, mode, options, opened_path, context STREAMS_REL_CC);
10941093
}
1095-
#endif
10961094

10971095
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path)) {
10981096
return NULL;

win32/build/config.w32.h.in

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
#endif
9393
#define SIZEOF_OFF_T 4
9494
#define HAVE_FNMATCH
95-
#define HAVE_GLOB
9695
#define PHP_SHLIB_SUFFIX "dll"
9796
#define PHP_SHLIB_EXT_PREFIX "php_"
9897

0 commit comments

Comments
 (0)