Skip to content

Commit 064ea9c

Browse files
authored
Inlines the behaviour of php_mkdir_ex() into plain wrapper mkdir handler (#15520)
This effectively inlines the behaviour of php_mkdir_ex() which is a deprecated API from at least 17 years ago, and also fixes some of the return values. This also removes a dependency on ext/standard
1 parent 8a5ada4 commit 064ea9c

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

UPGRADING.INTERNALS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
376376
- The deprecated php_uint32 and php_int32 typedefs have been removed from
377377
ext/standard/basic_functions.h. Use the standard uint32_t and int32_t
378378
types instead.
379+
- The php_mkdir() and php_mkdir_ex() APIs have been removed, use
380+
php_stream_mkdir() instead.
379381
- The php_strtoupper(), php_string_toupper(), php_strtolower(), and
380382
php_string_tolower() functions has been removed, use zend_str_toupper(),
381383
zend_string_toupper(), zend_str_tolower(), and zend_string_tolower()

ext/standard/file.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,30 +1109,6 @@ PHPAPI PHP_FUNCTION(fseek)
11091109
}
11101110
/* }}} */
11111111

1112-
/* {{{ php_mkdir */
1113-
1114-
/* DEPRECATED APIs: Use php_stream_mkdir() instead */
1115-
PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options)
1116-
{
1117-
int ret;
1118-
1119-
if (php_check_open_basedir(dir)) {
1120-
return -1;
1121-
}
1122-
1123-
if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) < 0 && (options & REPORT_ERRORS)) {
1124-
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
1125-
}
1126-
1127-
return ret;
1128-
}
1129-
1130-
PHPAPI int php_mkdir(const char *dir, zend_long mode)
1131-
{
1132-
return php_mkdir_ex(dir, mode, REPORT_ERRORS);
1133-
}
1134-
/* }}} */
1135-
11361112
/* {{{ Create a directory */
11371113
PHP_FUNCTION(mkdir)
11381114
{

ext/standard/file.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ PHPAPI int php_le_stream_context(void);
4040
PHPAPI zend_result php_copy_file(const char *src, const char *dest);
4141
PHPAPI zend_result php_copy_file_ex(const char *src, const char *dest, int src_flags);
4242
PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_flags, php_stream_context *ctx);
43-
PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options);
44-
PHPAPI int php_mkdir(const char *dir, zend_long mode);
4543
PHPAPI void php_fstat(php_stream *stream, zval *return_value);
4644
PHPAPI void php_flock_common(php_stream *stream, zend_long operation, uint32_t operation_arg_num,
4745
zval *wouldblock, zval *return_value);

main/streams/plain_wrapper.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,17 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
13741374
}
13751375

13761376
if (!(options & PHP_STREAM_MKDIR_RECURSIVE)) {
1377-
return php_mkdir(dir, mode) == 0;
1377+
if (php_check_open_basedir(dir)) {
1378+
return 0;
1379+
}
1380+
1381+
int ret = VCWD_MKDIR(dir, (mode_t)mode);
1382+
if (ret < 0 && (options & REPORT_ERRORS)) {
1383+
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
1384+
return 0;
1385+
}
1386+
1387+
return 1;
13781388
}
13791389

13801390
char buf[MAXPATHLEN];

0 commit comments

Comments
 (0)