From: Michael Wallner Date: Thu, 19 Feb 2015 07:40:49 +0000 (+0100) Subject: restore php-5.3 compatibility X-Git-Tag: RELEASE_2_3_0_RC1~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=5016399a1e84ca8d23fa74934300e703155e586b;p=m6w6%2Fext-http restore php-5.3 compatibility --- diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 97408bd..44b2c21 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -2344,7 +2344,8 @@ static int apply_available_options(void *pDest TSRMLS_DC, int num_args, va_list if (Z_TYPE(opt->defval) == IS_STRING && !Z_STRVAL(opt->defval)) { ZVAL_NULL(entry); } else { - ZVAL_ZVAL(entry, &opt->defval, 1, 0); + ZVAL_COPY_VALUE(entry, &opt->defval); + zval_copy_ctor(entry); } } diff --git a/php_http_object.c b/php_http_object.c index 7d902ea..ba6d28c 100644 --- a/php_http_object.c +++ b/php_http_object.c @@ -53,6 +53,15 @@ STATUS php_http_new(zend_object_value *ovp, zend_class_entry *ce, php_http_new_t return SUCCESS; } +static inline zend_function *get_object_method(zval *zobject, zval *zmeth TSRMLS_DC) +{ +#if PHP_VERSION_ID >= 50400 + return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth), NULL TSRMLS_CC); +#else + return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth) TSRMLS_CC); +#endif +} + php_http_object_method_t *php_http_object_method_init(php_http_object_method_t *cb, zval *zobject, const char *method_str, size_t method_len TSRMLS_DC) { zval *zfn; @@ -70,7 +79,7 @@ php_http_object_method_t *php_http_object_method_init(php_http_object_method_t * cb->fci.function_name = zfn; cb->fcc.initialized = 1; cb->fcc.calling_scope = cb->fcc.called_scope = Z_OBJCE_P(zobject); - cb->fcc.function_handler = Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(cb->fci.function_name), Z_STRLEN_P(cb->fci.function_name), NULL TSRMLS_CC); + cb->fcc.function_handler = get_object_method(zobject, cb->fci.function_name TSRMLS_CC); return cb; } @@ -108,7 +117,7 @@ STATUS php_http_object_method_call(php_http_object_method_t *cb, zval *zobject, if (cb->fcc.called_scope != Z_OBJCE_P(zobject)) { cb->fcc.called_scope = Z_OBJCE_P(zobject); - cb->fcc.function_handler = Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(cb->fci.function_name), Z_STRLEN_P(cb->fci.function_name), NULL TSRMLS_CC); + cb->fcc.function_handler = get_object_method(zobject, cb->fci.function_name TSRMLS_CC); } rv = zend_call_function(&cb->fci, &cb->fcc TSRMLS_CC); diff --git a/tests/bug66891.phpt b/tests/bug66891.phpt index 0fd84f8..30f9d7e 100644 --- a/tests/bug66891.phpt +++ b/tests/bug66891.phpt @@ -12,7 +12,7 @@ header("WWW-Authenticate: none"); $r = new http\Env\Response; $r->setResponseCode(200); $r->send(); -var_dump(http_response_code()); +var_dump(http\Env::getResponseCode()); ?> --EXPECT-- int(200) \ No newline at end of file diff --git a/tests/client008.phpt b/tests/client008.phpt index f8b8774..98fc8f8 100644 --- a/tests/client008.phpt +++ b/tests/client008.phpt @@ -18,7 +18,7 @@ server("pipeline.inc", function($port, $stdin) { $request = new http\Client\Request("GET", "http://localhost:$port"); $client = new http\Client(); - $client->configure(["pipelining" => true, "use_eventloop" => true]); + $client->configure(array("pipelining" => true, "use_eventloop" => true)); $client->enqueue($request); $client->send(); diff --git a/tests/client015.phpt b/tests/client015.phpt index 70b5f43..f378653 100644 --- a/tests/client015.phpt +++ b/tests/client015.phpt @@ -16,8 +16,8 @@ server("proxy.inc", function($port) { $client1 = new http\Client; $client2 = new http\Client; - $client1->configure(["use_eventloop" => true]); - $client2->configure(["use_eventloop" => true]); + $client1->configure(array("use_eventloop" => true)); + $client2->configure(array("use_eventloop" => true)); $client1->enqueue(new http\Client\Request("GET", "http://localhost:$port/")); $client2->enqueue(new http\Client\Request("GET", "http://localhost:$port/")); diff --git a/tests/client016.phpt b/tests/client016.phpt index 58f97c1..d2aef07 100644 --- a/tests/client016.phpt +++ b/tests/client016.phpt @@ -17,7 +17,7 @@ server("proxy.inc", function($port) { foreach (http\Client::getAvailableDrivers() as $driver) { $client = new http\Client($driver); - $client->configure(["use_eventloop" => true]); + $client->configure(array("use_eventloop" => true)); $client->enqueue($request); while ($client->once()) { diff --git a/tests/client017.phpt b/tests/client017.phpt index ea54146..a505028 100644 --- a/tests/client017.phpt +++ b/tests/client017.phpt @@ -12,7 +12,7 @@ skip_client_test(); echo "Test\n"; $client = new http\Client; -$client->setOptions(["compress" => true]); +$client->setOptions(array("compress" => true)); $client->enqueue(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.print_request.php")); $client->send(); diff --git a/tests/client018.phpt b/tests/client018.phpt index 7acb911..c3ca9f9 100644 --- a/tests/client018.phpt +++ b/tests/client018.phpt @@ -17,7 +17,7 @@ server("pipeline.inc", function($port, $stdin, $stdout, $stderr) { fputs($stdin, "3\n"); $client = new http\Client(null); - $client->configure(["pipelining" => true, "max_host_connections" => 0]); + $client->configure(array("pipelining" => true, "max_host_connections" => 0)); /* this is just to let curl know the server may be capable of pipelining */ $client->enqueue(new http\Client\Request("GET", "http://localhost:$port")); diff --git a/tests/client021.phpt b/tests/client021.phpt index 41a220a..1335aaa 100644 --- a/tests/client021.phpt +++ b/tests/client021.phpt @@ -14,10 +14,10 @@ echo "Test\n"; $tmpfile = tempnam(sys_get_temp_dir(), "cookie."); $request = new http\Client\Request("GET", "http://localhost"); -$request->setOptions(["cookiestore" => $tmpfile]); +$request->setOptions(array("cookiestore" => $tmpfile)); server("cookie.inc", function($port) use($request) { - $request->setOptions(["port" => $port]); + $request->setOptions(array("port" => $port)); $client = new http\Client; echo $client->requeue($request)->send()->getResponse(); echo $client->requeue($request)->send()->getResponse(); @@ -25,7 +25,7 @@ server("cookie.inc", function($port) use($request) { }); server("cookie.inc", function($port) use($request) { - $request->setOptions(["port" => $port]); + $request->setOptions(array("port" => $port)); $client = new http\Client; echo $client->requeue($request)->send()->getResponse(); echo $client->requeue($request)->send()->getResponse(); @@ -33,7 +33,7 @@ server("cookie.inc", function($port) use($request) { }); server("cookie.inc", function($port) use($request) { - $request->setOptions(["port" => $port, "cookiesession" => true]); + $request->setOptions(array("port" => $port, "cookiesession" => true)); $client = new http\Client; echo $client->requeue($request)->send()->getResponse(); echo $client->requeue($request)->send()->getResponse(); @@ -41,7 +41,7 @@ server("cookie.inc", function($port) use($request) { }); server("cookie.inc", function($port) use($request) { - $request->setOptions(["port" => $port, "cookiesession" => false]); + $request->setOptions(array("port" => $port, "cookiesession" => false)); $client = new http\Client; echo $client->requeue($request)->send()->getResponse(); echo $client->requeue($request)->send()->getResponse(); diff --git a/tests/client023.phpt b/tests/client023.phpt index b09c2e2..77ea7ce 100644 --- a/tests/client023.phpt +++ b/tests/client023.phpt @@ -22,11 +22,11 @@ foreach ($avail as $k => $v) { $oo = $opt[$k]; foreach ($v as $kk => $vv) { if (isset($vv) && $oo[$kk] !== $vv) { - var_dump([$kk => [$vv, $oo[$kk]]]); + var_dump(array($kk => array($vv, $oo[$kk]))); } } } else if (isset($v) && $opt[$k] !== $v) { - var_dump([$k => [$v, $opt[$k]]]); + var_dump(array($k => array($v, $opt[$k]))); } } var_dump($client === $client->configure($client->getAvailableConfiguration())); diff --git a/tests/client025.phpt b/tests/client025.phpt index 18c5095..866cd2e 100644 --- a/tests/client025.phpt +++ b/tests/client025.phpt @@ -14,7 +14,7 @@ echo "Test\n"; server("proxy.inc", function($port) { $client = new http\Client; $request = new http\Client\Request("PUT", "http://localhost:$port"); - $request->setOptions(["resume" => 1, "expect_100_timeout" => 0]); + $request->setOptions(array("resume" => 1, "expect_100_timeout" => 0)); $request->getBody()->append("123"); echo $client->enqueue($request)->send()->getResponse(); }); diff --git a/tests/client026.phpt b/tests/client026.phpt index d89e98e..1bafdc1 100644 --- a/tests/client026.phpt +++ b/tests/client026.phpt @@ -19,7 +19,7 @@ server("proxy.inc", function($port) { for ($i = 0, $data = str_repeat("a",1024); $i < 128*1024; ++$i) { $request->getBody()->append($data); } - $request->setOptions(["timeout" => 10, "expect_100_timeout" => 0]); + $request->setOptions(array("timeout" => 10, "expect_100_timeout" => 0)); $client->enqueue($request); $client->send(); var_dump($client->getResponse()->getHeaders()); diff --git a/tests/envresponse004.phpt b/tests/envresponse004.phpt index deee3f2..da5801d 100644 --- a/tests/envresponse004.phpt +++ b/tests/envresponse004.phpt @@ -20,6 +20,7 @@ echo "bar"; ob_end_flush(); $r->send(); +?> --EXPECTHEADERS-- Accept-Ranges: bytes Cache-Control: public,must-revalidate,max-age=0 diff --git a/tests/envresponse017.phpt b/tests/envresponse017.phpt index ffa40cb..4c832f2 100644 --- a/tests/envresponse017.phpt +++ b/tests/envresponse017.phpt @@ -10,7 +10,7 @@ echo "Test\n"; $req = new http\Env\Request; $req->setRequestMethod("CONNECT"); -$req->setRequestUrl(["host"=>"www.example.com", "port"=>80]); +$req->setRequestUrl(array("host"=>"www.example.com", "port"=>80)); echo $req; diff --git a/tests/headerparser001.phpt b/tests/headerparser001.phpt index 0a1eb37..cdd55e4 100644 --- a/tests/headerparser001.phpt +++ b/tests/headerparser001.phpt @@ -8,16 +8,16 @@ include "skipif.inc"; "FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE"]; +$states = array(-1=>"FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE"); $parser = new http\Header\Parser; do { $state = $parser->parse($part = array_shift($headers), diff --git a/tests/headerparser002.phpt b/tests/headerparser002.phpt index c5a02f1..67e6681 100644 --- a/tests/headerparser002.phpt +++ b/tests/headerparser002.phpt @@ -8,14 +8,14 @@ include "skipif.inc"; setEnvRequest($msg) + $r = new http\Env\Response; + $r->setEnvRequest($msg) ->setHeader("X-Req", $msg->getRequestUrl()) ->send($client); } diff --git a/tests/helper/server.inc b/tests/helper/server.inc index 0605adc..aa8559f 100644 --- a/tests/helper/server.inc +++ b/tests/helper/server.inc @@ -1,11 +1,16 @@ getState()], $file); } diff --git a/tests/skipif.inc b/tests/skipif.inc index cceeaf0..4ab631e 100644 --- a/tests/skipif.inc +++ b/tests/skipif.inc @@ -21,9 +21,11 @@ function skip_client_test($message = "skip need a client driver\n") { } function skip_http2_test($message = "skip need http2 support (nghttpd in PATH)\n") { - foreach (explode(":", $_ENV["PATH"]) as $path) { - if (is_executable($path . "/nghttpd")) { - return; + if (defined("http\\Client\\Curl\\HTTP_VERSION_2_0")) { + foreach (explode(":", $_ENV["PATH"]) as $path) { + if (is_executable($path . "/nghttpd")) { + return; + } } } die($message);