diff options
Diffstat (limited to 'main/SAPI.c')
-rw-r--r-- | main/SAPI.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index f9e4a9fe7f..bb6dc7c04e 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -136,14 +136,12 @@ PHP_FUNCTION(header_register_callback) efree(callback_name); - if (SG(callback_func)) { + if (Z_TYPE(SG(callback_func)) != IS_UNDEF) { zval_ptr_dtor(&SG(callback_func)); SG(fci_cache) = empty_fcall_info_cache; } - SG(callback_func) = callback_func; - - Z_ADDREF_P(SG(callback_func)); + ZVAL_COPY(&SG(callback_func), callback_func); RETURN_TRUE; } @@ -155,16 +153,16 @@ static void sapi_run_header_callback(TSRMLS_D) zend_fcall_info fci; char *callback_name = NULL; char *callback_error = NULL; - zval *retval_ptr = NULL; + zval retval; - if (zend_fcall_info_init(SG(callback_func), 0, &fci, &SG(fci_cache), &callback_name, &callback_error TSRMLS_CC) == SUCCESS) { - fci.retval_ptr_ptr = &retval_ptr; + if (zend_fcall_info_init(&SG(callback_func), 0, &fci, &SG(fci_cache), &callback_name, &callback_error TSRMLS_CC) == SUCCESS) { + fci.retval = &retval; error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC); if (error == FAILURE) { goto callback_failed; - } else if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); + } else { + zval_ptr_dtor(&retval); } } else { callback_failed: @@ -218,8 +216,8 @@ static void sapi_read_post_data(TSRMLS_D) } /* now try to find an appropriate POST content handler */ - if (zend_hash_find(&SG(known_post_content_types), content_type, - content_type_length+1, (void **) &post_entry) == SUCCESS) { + if ((post_entry = zend_hash_str_find_ptr(&SG(known_post_content_types), content_type, + content_type_length)) != NULL) { /* found one, register it for use */ SG(request_info).post_entry = post_entry; post_reader_func = post_entry->post_reader; @@ -453,7 +451,7 @@ SAPI_API void sapi_activate(TSRMLS_D) SG(sapi_headers).mimetype = NULL; SG(headers_sent) = 0; SG(callback_run) = 0; - SG(callback_func) = NULL; + ZVAL_UNDEF(&SG(callback_func)); SG(read_post_bytes) = 0; SG(request_info).request_body = NULL; SG(request_info).current_user = NULL; @@ -550,9 +548,7 @@ SAPI_API void sapi_deactivate(TSRMLS_D) SG(sapi_started) = 0; SG(headers_sent) = 0; SG(callback_run) = 0; - if (SG(callback_func)) { - zval_ptr_dtor(&SG(callback_func)); - } + zval_ptr_dtor(&SG(callback_func)); SG(request_info).headers_read = 0; SG(global_request_time) = 0; } @@ -795,7 +791,9 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) /* Disable possible output compression for images */ if (!strncmp(ptr, "image/", sizeof("image/")-1)) { - zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0); + zend_alter_ini_entry(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + STR_FREE(key); } mimetype = estrdup(ptr); @@ -821,8 +819,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) * do disable compression altogether. This contributes to making scripts * portable between setups that have and don't have zlib compression * enabled globally. See req #44164 */ - zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), + zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0); + zend_alter_ini_entry(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + STR_FREE(key); } else if (!STRCASECMP(header_line, "Location")) { if ((SG(sapi_headers).http_response_code < 300 || SG(sapi_headers).http_response_code > 307) && @@ -880,7 +880,7 @@ SAPI_API int sapi_send_headers(TSRMLS_D) SG(sapi_headers).send_default_content_type = 0; } - if (SG(callback_func) && !SG(callback_run)) { + if (Z_TYPE(SG(callback_func)) != IS_UNDEF && !SG(callback_run)) { SG(callback_run) = 1; sapi_run_header_callback(TSRMLS_C); } @@ -952,9 +952,9 @@ SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC) if (SG(sapi_started) && EG(in_execution)) { return FAILURE; } - return zend_hash_add(&SG(known_post_content_types), - post_entry->content_type, post_entry->content_type_len+1, - (void *) post_entry, sizeof(sapi_post_entry), NULL); + return zend_hash_str_add_mem(&SG(known_post_content_types), + post_entry->content_type, post_entry->content_type_len, + (void *) post_entry, sizeof(sapi_post_entry)) ? SUCCESS : FAILURE; } SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC) @@ -962,8 +962,8 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC) if (SG(sapi_started) && EG(in_execution)) { return; } - zend_hash_del(&SG(known_post_content_types), post_entry->content_type, - post_entry->content_type_len+1); + zend_hash_str_del(&SG(known_post_content_types), post_entry->content_type, + post_entry->content_type_len); } |