fix PHP-5.3 compatibility
authorMichael Wallner <mike@php.net>
Mon, 11 Aug 2014 15:13:05 +0000 (17:13 +0200)
committerMichael Wallner <mike@php.net>
Mon, 11 Aug 2014 15:13:05 +0000 (17:13 +0200)
php_http_env_response.c
php_http_message.c
tests/params015.phpt

index 4d6ef037471fb9bb02faf0a32f2773e052a631e1..c155dde3263bde5cba07c77ec108a4f7abd80077 100644 (file)
@@ -1096,7 +1096,11 @@ static PHP_METHOD(HttpEnvResponse, __invoke)
 
                php_http_message_object_init_body_object(obj);
                php_http_message_body_append(obj->message->body, ob_str, ob_len);
+#if PHP_VERSION_ID >= 50400
                RETURN_TRUE;
+#else
+               RETURN_EMPTY_STRING();
+#endif
        }
 }
 
index cc04edcf3850285742935ce626e74b76fdb816ef..88def26b8eccccc27bb914fa211059555a144464 100644 (file)
@@ -98,6 +98,19 @@ php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_h
                                        zval_dtor(&tval);
                                }
                        }
+#else
+                       if (OG(ob_nesting_level)) {
+                               if (php_get_output_start_filename(TSRMLS_C)) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_get_output_start_filename(TSRMLS_C), php_get_output_start_lineno(TSRMLS_C));
+                                       goto error;
+                               } else if (SUCCESS != php_ob_get_buffer(&tval TSRMLS_CC)) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body");
+                                       goto error;
+                               } else {
+                                       php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
+                                       zval_dtor(&tval);
+                               }
+                       }
 #endif
                        break;
                        
index ad3948cb0581cda7dd60ec86a4c4a36768f30eb0..7501167971d0a0dcc5b573d1f325ee6390d772ec 100644 (file)
@@ -7,7 +7,7 @@ include "skipif.inc";
 --FILE--
 <?php
 echo "Test\n";
-$p = new http\Params(["attachment"=>["filename"=>"foo.bar"]]);
+$p = new http\Params(array("attachment"=>array("filename"=>"foo.bar")));
 var_dump($p->params);
 var_dump((string)$p);
 ?>