From: Felipe Pena Date: Fri, 4 Jun 2010 23:54:40 +0000 (+0000) Subject: - Fixed build on php-trunk X-Git-Tag: RELEASE_1_7_0~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ad5f896b03adaa073134a00108a9cdf00720673a;p=m6w6%2Fext-http - Fixed build on php-trunk --- diff --git a/http_api.c b/http_api.c index aca90e6..aebd434 100644 --- a/http_api.c +++ b/http_api.c @@ -253,9 +253,15 @@ STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header return FAILURE; } +#if PHP_VERSION_ID < 50399 if (!OG(ob_lock)) { php_end_ob_buffers(0 TSRMLS_CC); } +#else + if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_LOCKED) { + php_output_end_all(TSRMLS_C); + } +#endif if ((SUCCESS == sapi_send_headers(TSRMLS_C)) && body) { PHPWRITE(body, strlen(body)); } diff --git a/http_deflatestream_object.c b/http_deflatestream_object.c index c3c8045..f30cc6a 100644 --- a/http_deflatestream_object.c +++ b/http_deflatestream_object.c @@ -107,9 +107,13 @@ zend_object_value _http_deflatestream_object_new_ex(zend_class_entry *ce, http_e o->stream = s; } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_deflatestream_object, o); ov.handlers = &http_deflatestream_object_handlers; diff --git a/http_inflatestream_object.c b/http_inflatestream_object.c index 53e5571..18ca266 100644 --- a/http_inflatestream_object.c +++ b/http_inflatestream_object.c @@ -96,9 +96,13 @@ zend_object_value _http_inflatestream_object_new_ex(zend_class_entry *ce, http_e o->stream = s; } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_inflatestream_object, o); ov.handlers = &http_inflatestream_object_handlers; diff --git a/http_message_object.c b/http_message_object.c index a5b2ca8..c3585c1 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -513,9 +513,14 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message } } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + zend_object_std_init(&o->zo, ce TSRMLS_CC); + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_message_object, o); ov.handlers = &http_message_object_handlers; @@ -617,7 +622,11 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) zval *headers; getObjectEx(http_message_object, obj, object); http_message *msg = obj->message; +#if PHP_VERSION_ID < 50399 HashTable *props = OBJ_PROP(obj); +#else + HashTable *props = zend_std_get_properties(object TSRMLS_CC); +#endif zval array, *parent; INIT_ZARR(array, props); diff --git a/http_querystring_object.c b/http_querystring_object.c index 0e7b2ac..88d4c83 100644 --- a/http_querystring_object.c +++ b/http_querystring_object.c @@ -191,9 +191,13 @@ zend_object_value _http_querystring_object_new_ex(zend_class_entry *ce, void *no *ptr = o; } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_querystring_object, o); ov.handlers = &http_querystring_object_handlers; diff --git a/http_request_object.c b/http_request_object.c index 8ea09b0..f06157a 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -492,9 +492,13 @@ zend_object_value _http_request_object_new_ex(zend_class_entry *ce, CURL *ch, ht *ptr = o; } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_request_object, o); ov.handlers = &http_request_object_handlers; diff --git a/http_requestdatashare_object.c b/http_requestdatashare_object.c index 8eacef8..0604935 100644 --- a/http_requestdatashare_object.c +++ b/http_requestdatashare_object.c @@ -125,9 +125,13 @@ zend_object_value _http_requestdatashare_object_new_ex(zend_class_entry *ce, htt *ptr = o; } +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_requestdatashare_object, o); ov.handlers = &http_requestdatashare_object_handlers; @@ -147,7 +151,13 @@ void _http_requestdatashare_object_free(zend_object *object TSRMLS_DC) static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type ZEND_LITERAL_KEY_DC TSRMLS_DC) { - if (type == BP_VAR_W && zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) { + if (type == BP_VAR_W && +#if PHP_VERSION_ID < 50399 + zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) +#else + zend_get_property_info(THIS_CE, member, 1 TSRMLS_CC) +#endif + ) { zend_error(E_ERROR, "Cannot access HttpRequestDataShare default properties by reference or array key/index"); return NULL; } @@ -157,7 +167,11 @@ static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value ZEND_LITERAL_KEY_DC TSRMLS_DC) { +#if PHP_VERSION_ID < 50399 if (zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) { +#else + if (zend_get_property_info(THIS_CE, member, 1 TSRMLS_CC)) { +#endif int status; getObjectEx(http_requestdatashare_object, obj, object); diff --git a/http_requestpool_object.c b/http_requestpool_object.c index 653843a..43941bb 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -129,9 +129,13 @@ zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC) http_request_pool_init(&o->pool); +#if PHP_VERSION_ID < 50399 ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#else + object_properties_init(&o->zo, ce); +#endif ov.handle = putObject(http_requestpool_object, o); ov.handlers = &http_requestpool_object_handlers; diff --git a/http_send_api.c b/http_send_api.c index 319c7d6..d8bc1a0 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -34,12 +34,24 @@ static inline void _http_flush(void *nothing, const char *data, size_t data_len /* we really only need to flush when throttling is enabled, because we push the data as fast as possible anyway if not */ if (HTTP_G->send.throttle_delay >= HTTP_DIFFSEC) { +#if PHP_VERSION_ID < 50399 if (OG(ob_nesting_level)) { php_end_ob_buffer(1, 1 TSRMLS_CC); } if (!OG(implicit_flush)) { sapi_flush(TSRMLS_C); } +#else + int ob_level; + + if ((php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL, &ob_level TSRMLS_CC) == SUCCESS) && ob_level > 0) { + php_output_discard(TSRMLS_C); + } + + if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_IMPLICITFLUSH) { + sapi_flush(TSRMLS_C); + } +#endif http_sleep(HTTP_G->send.throttle_delay); } } diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 456ae74..1f8e45d 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -182,25 +182,9 @@ typedef int STATUS; # define getObject(t, o) getObjectEx(t, o, getThis()) # define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC)) # define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) _ ##t## _free, NULL TSRMLS_CC); -# ifndef WONKY -# define freeObject(o) \ - if (OBJ_GUARDS(o)) { \ - zend_hash_destroy(OBJ_GUARDS(o)); \ - FREE_HASHTABLE(OBJ_GUARDS(o)); \ - } \ - if (OBJ_PROP(o)) { \ - zend_hash_destroy(OBJ_PROP(o)); \ - FREE_HASHTABLE(OBJ_PROP(o)); \ - } \ +# define freeObject(o) \ + zend_object_std_dtor(&o->zo TSRMLS_CC); \ efree(o); -# else -# define freeObject(o) \ - if (OBJ_PROP(o)) { \ - zend_hash_destroy(OBJ_PROP(o)); \ - FREE_HASHTABLE(OBJ_PROP(o)); \ - } \ - efree(o); -# endif # define OBJ_PROP(o) (o)->zo.properties # define OBJ_GUARDS(o) (o)->zo.guards