summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-10-25 16:01:25 +0200
committerOndřej Surý <ondrej@sury.org>2012-10-25 16:01:25 +0200
commitb57a2691d5b72c3894e2d4e0f945cecc6b3a1953 (patch)
tree012a1408ce8a738d45ae429ca7d7f5389c159915 /main
parent45c0aa447e02c80bd21a23245574231a110cf5a1 (diff)
downloadphp-b57a2691d5b72c3894e2d4e0f945cecc6b3a1953.tar.gz
Imported Upstream version 5.4.8upstream/5.4.8
Diffstat (limited to 'main')
-rw-r--r--main/main.c11
-rw-r--r--main/output.c2
-rw-r--r--main/php_version.h6
-rw-r--r--main/streams/userspace.c197
4 files changed, 94 insertions, 122 deletions
diff --git a/main/main.c b/main/main.c
index 709c6dd3d..44c61c600 100644
--- a/main/main.c
+++ b/main/main.c
@@ -597,6 +597,7 @@ PHPAPI int php_get_module_initialized(void)
{
return module_initialized;
}
+/* }}} */
/* {{{ php_log_err
*/
@@ -627,7 +628,15 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
char *error_time_str;
time(&error_time);
- error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 0 TSRMLS_CC);
+#ifdef ZTS
+ if (!php_during_module_startup()) {
+ error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1 TSRMLS_CC);
+ } else {
+ error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 0 TSRMLS_CC);
+ }
+#else
+ error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1 TSRMLS_CC);
+#endif
len = spprintf(&tmp, 0, "[%s] %s%s", error_time_str, log_message, PHP_EOL);
#ifdef PHP_WIN32
php_flock(fd, 2);
diff --git a/main/output.c b/main/output.c
index d4eaa6701..e100057ca 100644
--- a/main/output.c
+++ b/main/output.c
@@ -214,7 +214,7 @@ PHPAPI void php_output_register_constants(TSRMLS_D)
* Used by SAPIs to disable output */
PHPAPI void php_output_set_status(int status TSRMLS_DC)
{
- OG(flags) = status & 0xf;
+ OG(flags) = (OG(flags) & ~0xf) | (status & 0xf);
}
/* }}} */
diff --git a/main/php_version.h b/main/php_version.h
index 8fd49ecf7..cdd377472 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -2,7 +2,7 @@
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 4
-#define PHP_RELEASE_VERSION 6
+#define PHP_RELEASE_VERSION 8
#define PHP_EXTRA_VERSION ""
-#define PHP_VERSION "5.4.6"
-#define PHP_VERSION_ID 50405
+#define PHP_VERSION "5.4.8"
+#define PHP_VERSION_ID 50408
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 96a5195ed..3b277160d 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -281,43 +281,22 @@ typedef struct _php_userstream_data php_userstream_data_t;
}}} **/
-static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
+static zval *user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context TSRMLS_DC)
{
- struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
- php_userstream_data_t *us;
- zval *zfilename, *zmode, *zopened, *zoptions, *zretval = NULL, *zfuncname;
- zval **args[4];
- int call_result;
- php_stream *stream = NULL;
- zend_bool old_in_user_include;
-
- /* Try to catch bad usage without preventing flexibility */
- if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented");
- return NULL;
- }
- FG(user_stream_current_filename) = filename;
+ zval *object;
+ /* create an instance of our class */
+ ALLOC_ZVAL(object);
+ object_init_ex(object, uwrap->ce);
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
- /* if the user stream was registered as local and we are in include context,
- we add allow_url_include restrictions to allow_url_fopen ones */
- /* we need only is_url == 0 here since if is_url == 1 and remote wrappers
- were restricted we wouldn't get here */
- old_in_user_include = PG(in_user_include);
- if(uwrap->wrapper.is_url == 0 &&
- (options & STREAM_OPEN_FOR_INCLUDE) &&
- !PG(allow_url_include)) {
- PG(in_user_include) = 1;
+ if (context) {
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
+ } else {
+ add_property_null(object, "context");
}
- us = emalloc(sizeof(*us));
- us->wrapper = uwrap;
-
- /* create an instance of our class */
- ALLOC_ZVAL(us->object);
- object_init_ex(us->object, uwrap->ce);
- Z_SET_REFCOUNT_P(us->object, 1);
- Z_SET_ISREF_P(us->object);
-
if (uwrap->ce->constructor) {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -327,7 +306,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
fci.function_table = &uwrap->ce->function_table;
fci.function_name = NULL;
fci.symbol_table = NULL;
- fci.object_ptr = us->object;
+ fci.object_ptr = object;
fci.retval_ptr_ptr = &retval_ptr;
fci.param_count = 0;
fci.params = NULL;
@@ -336,16 +315,13 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
fcc.initialized = 1;
fcc.function_handler = uwrap->ce->constructor;
fcc.calling_scope = EG(scope);
- fcc.called_scope = Z_OBJCE_P(us->object);
- fcc.object_ptr = us->object;
+ fcc.called_scope = Z_OBJCE_P(object);
+ fcc.object_ptr = object;
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name, uwrap->ce->constructor->common.function_name);
- zval_dtor(us->object);
- FREE_ZVAL(us->object);
- efree(us);
- FG(user_stream_current_filename) = NULL;
- PG(in_user_include) = old_in_user_include;
+ zval_dtor(object);
+ FREE_ZVAL(object);
return NULL;
} else {
if (retval_ptr) {
@@ -353,12 +329,46 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
}
}
}
+ return object;
+}
- if (context) {
- add_property_resource(us->object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(us->object, "context");
+static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
+{
+ struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
+ php_userstream_data_t *us;
+ zval *zfilename, *zmode, *zopened, *zoptions, *zretval = NULL, *zfuncname;
+ zval **args[4];
+ int call_result;
+ php_stream *stream = NULL;
+ zend_bool old_in_user_include;
+
+ /* Try to catch bad usage without preventing flexibility */
+ if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented");
+ return NULL;
+ }
+ FG(user_stream_current_filename) = filename;
+
+ /* if the user stream was registered as local and we are in include context,
+ we add allow_url_include restrictions to allow_url_fopen ones */
+ /* we need only is_url == 0 here since if is_url == 1 and remote wrappers
+ were restricted we wouldn't get here */
+ old_in_user_include = PG(in_user_include);
+ if(uwrap->wrapper.is_url == 0 &&
+ (options & STREAM_OPEN_FOR_INCLUDE) &&
+ !PG(allow_url_include)) {
+ PG(in_user_include) = 1;
+ }
+
+ us = emalloc(sizeof(*us));
+ us->wrapper = uwrap;
+
+ us->object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(us->object == NULL) {
+ FG(user_stream_current_filename) = NULL;
+ PG(in_user_include) = old_in_user_include;
+ efree(us);
+ return NULL;
}
/* call it's stream_open method - set up params first */
@@ -447,17 +457,11 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filen
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
- /* create an instance of our class */
- ALLOC_ZVAL(us->object);
- object_init_ex(us->object, uwrap->ce);
- Z_SET_REFCOUNT_P(us->object, 1);
- Z_SET_ISREF_P(us->object);
-
- if (context) {
- add_property_resource(us->object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(us->object, "context");
+ us->object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(us == NULL) {
+ FG(user_stream_current_filename) = NULL;
+ efree(us);
+ return NULL;
}
/* call it's dir_open method - set up params first */
@@ -1157,16 +1161,9 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
int ret = 0;
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ return ret;
}
/* call the unlink method */
@@ -1211,16 +1208,9 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
int ret = 0;
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ return ret;
}
/* call the rename method */
@@ -1270,16 +1260,9 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, char *url, int mode,
int ret = 0;
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ return ret;
}
/* call the mkdir method */
@@ -1335,16 +1318,9 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int option
int ret = 0;
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ return ret;
}
/* call the rmdir method */
@@ -1420,16 +1396,10 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, char *url, int opt
}
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ zval_ptr_dtor(&zvalue);
+ return ret;
}
/* call the mkdir method */
@@ -1484,16 +1454,9 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, int fla
int ret = -1;
/* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
-
- if (context) {
- add_property_resource(object, "context", context->rsrc_id);
- zend_list_addref(context->rsrc_id);
- } else {
- add_property_null(object, "context");
+ object = user_stream_create_object(uwrap, context TSRMLS_CC);
+ if(object == NULL) {
+ return ret;
}
/* call it's stat_url method - set up params first */