fix PHP5.1 build
authorMichael Wallner <mike@php.net>
Mon, 27 Jul 2009 14:04:55 +0000 (14:04 +0000)
committerMichael Wallner <mike@php.net>
Mon, 27 Jul 2009 14:04:55 +0000 (14:04 +0000)
fix access of HttpMessage properties across 5.x branches

http_message_object.c
package2.xml
php_http.h

index 121337bae962e0ad262a795a5448dda722b2057d..49b76e009fbfac16bef94ece4d2bb2ddbed34709 100644 (file)
@@ -414,11 +414,15 @@ void _http_message_object_free(zend_object *object TSRMLS_DC)
        freeObject(o);
 }
 
-static zval **_http_message_object_get_prop_ptr(zval *object, zval *member TSRMLS_DC) {
-       getObjectEx(http_message_object, obj, object);
-       zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
-       
-       if (!pinfo || pinfo->ce != http_message_object_ce) {
+static zval **_http_message_object_get_prop_ptr(zval *object, zval *member TSRMLS_DC)
+{
+       int member_len = Z_STRLEN_P(member);
+
+#ifndef WONKY
+       member_len += 1;
+#endif
+
+       if (!zend_hash_exists(&http_message_object_ce->properties_info, Z_STRVAL_P(member), member_len)) {
                return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member TSRMLS_CC);
        }
        zend_error(E_ERROR, "Cannot access HttpMessage properties by reference or array key/index");
@@ -430,17 +434,16 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
        getObjectEx(http_message_object, obj, object);
        http_message *msg = obj->message;
        zval *return_value;
-#ifdef WONKY
-       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
-#else
-       zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
-       
-       if (!pinfo || pinfo->ce != http_message_object_ce) {
-               return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC);
-       }
+       int member_len = Z_STRLEN_P(member);
+
+#ifndef WONKY
+       member_len += 1;
 #endif
 
-       if (type == BP_VAR_W) {
+       if (!zend_hash_exists(&http_message_object_ce->properties_info, Z_STRVAL_P(member), member_len)) {
+               return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC);
+       }
+       if (type != BP_VAR_R) {
                zend_error(E_ERROR, "Cannot access HttpMessage properties by reference or array key/index");
                return NULL;
        }
@@ -454,11 +457,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
        return_value->is_ref = 0;
 #endif
 
-#ifdef WONKY
-       switch (h)
-#else
-       switch (pinfo->h)
-#endif
+       switch (zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1))
        {
                case HTTP_MSG_PROPHASH_TYPE:
                case HTTP_MSG_CHILD_PROPHASH_TYPE:
@@ -529,6 +528,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
                
                default:
                        FREE_ZVAL(return_value);
+                       zend_error(E_WARNING, "possible bug accessing HttpMessage property");
                        return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC);
        }
 
@@ -540,22 +540,18 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
        getObjectEx(http_message_object, obj, object);
        http_message *msg = obj->message;
        zval *cpy = NULL;
-#ifdef WONKY
-       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
-#else
-       zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
-       
-       if (!pinfo || pinfo->ce != http_message_object_ce) {
+       int member_len = Z_STRLEN_P(member);
+
+#ifndef WONKY
+       member_len += 1;
+#endif
+
+       if (!zend_hash_exists(&http_message_object_ce->properties_info, Z_STRVAL_P(member), member_len)) {
                zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC);
                return;
        }
-#endif
        
-#ifdef WONKY
-       switch (h)
-#else
-       switch (pinfo->h)
-#endif
+       switch (zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1))
        {
                case HTTP_MSG_PROPHASH_TYPE:
                case HTTP_MSG_CHILD_PROPHASH_TYPE:
index 36b8a8b50cba6b41a6d6cabfdf468caa3f3663f7..fa3c60068284c14f5437e2a16b2909f281eafa5c 100644 (file)
@@ -30,7 +30,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </lead>
  <date>2009-07-24</date>
  <version>
-  <release>1.6.4</release>
+  <release>1.6.5-dev</release>
   <api>1.6.0</api>
  </version>
  <stability>
@@ -39,12 +39,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed PHP4 build
-* Fixed PHP5.3 issue in the negotiation API
-* Fixed HttpMessage::toMessageTypeObject() to honor non-string arguments
-* Fixed memory leaks and unterminated string issues with HttpMessage
-* Fixed bug #16577 typo in http_request_object.c (HttpRequest::addBody)
-* Fixed bug #16700 child classes of HttpMessage cannot not have array properties
+* Fixed PHP5.1 build
 ]]></notes>
  <contents>
   <dir name="/">
index 5ff14887a53b6829539d6de4926b2187aaba130b..bc149a681ba616b867df70f702605d23ff177e7a 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_HTTP_VERSION "1.6.4"
+#define PHP_HTTP_VERSION "1.6.5-dev"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"