Skip to content

Commit 22f20e2

Browse files
committed
add flags to suppress the verbosity
1 parent 978f74a commit 22f20e2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

main/php_open_temporary_file.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/* $Id$ */
2020

2121
#include "php.h"
22+
#include "php_open_temporary_file.h"
2223

2324
#include <errno.h>
2425
#include <sys/types.h>
@@ -249,7 +250,7 @@ PHPAPI const char* php_get_temporary_directory(void)
249250
* This function should do its best to return a file pointer to a newly created
250251
* unique file, on every platform.
251252
*/
252-
PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, zend_bool open_basedir_check)
253+
PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, uint32_t flags)
253254
{
254255
int fd;
255256
const char *temp_dir;
@@ -265,7 +266,7 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_strin
265266
def_tmp:
266267
temp_dir = php_get_temporary_directory();
267268

268-
if (temp_dir && *temp_dir != '\0' && (!open_basedir_check || !php_check_open_basedir(temp_dir))) {
269+
if (temp_dir && *temp_dir != '\0' && (!(flags & PHP_TMP_FILE_OPEN_BASEDIR_CHECK) || !php_check_open_basedir(temp_dir))) {
269270
return php_do_open_temporary_file(temp_dir, pfx, opened_path_p);
270271
} else {
271272
return -1;
@@ -276,7 +277,9 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_strin
276277
fd = php_do_open_temporary_file(dir, pfx, opened_path_p);
277278
if (fd == -1) {
278279
/* Use default temporary directory. */
279-
php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
280+
if (!(flags & PHP_TMP_FILE_SILENT)) {
281+
php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
282+
}
280283
goto def_tmp;
281284
}
282285
return fd;

main/php_open_temporary_file.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
#ifndef PHP_OPEN_TEMPORARY_FILE_H
2222
#define PHP_OPEN_TEMPORARY_FILE_H
2323

24+
#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK (1<<0)
25+
#define PHP_TMP_FILE_SILENT (1<<1)
26+
2427
BEGIN_EXTERN_C()
2528
PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, zend_string **opened_path_p);
26-
PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, zend_bool open_basedir_check);
29+
PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, uint32_t flags);
2730
PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, zend_string **opened_path_p);
2831
PHPAPI const char *php_get_temporary_directory(void);
2932
END_EXTERN_C()

0 commit comments

Comments
 (0)