Skip to content

Commit 4ec1a2a

Browse files
committed
Merge branch 'PHP-5.4' of https://git.php.net/repository/php-src into PHP-5.4
* 'PHP-5.4' of https://git.php.net/repository/php-src: Merging PR #116 Merged GitHub PR #190: Support for the HTTP PATCH method in CLI webserver updated libary versions split tests for the new zlib version on win Fixed Bug #63103 (ext\curl\tests\bug62839.phpt broken)
2 parents 1a55451 + ee172ce commit 4ec1a2a

File tree

9 files changed

+178
-5
lines changed

9 files changed

+178
-5
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- CLI server:
66
. Changed response to unknown HTTP method to 501 according to RFC.
77
(Niklas Lindgren).
8+
. Support HTTP PATCH method. Patch by Niklas Lindgren, GitHub PR #190.
9+
(Lars)
810

911
- Core:
1012
. Added optional second argument for assert() to specify custom message. Patch

ext/curl/tests/bug62839.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Bug #62839 (curl_copy_handle segfault with CURLOPT_FILE)
77
<?php
88
$curl = curl_init();
99

10-
$fd = fopen('/tmp/test', 'wb');
10+
$fd = tmpfile();
1111
curl_setopt($curl, CURLOPT_FILE, $fd);
1212

1313
curl_copy_handle($curl);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
RecursiveDirectoryIterator::getBasePath() - basic test
3+
--CREDITS--
4+
Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl>
5+
#testfest AmsterdamPHP 2012-06-23
6+
--FILE--
7+
<?php
8+
$depth0 = md5('recursiveDirectoryIterator::getSubPath');
9+
$depth1 = md5('depth1');
10+
$depth2 = md5('depth2');
11+
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2;
12+
mkdir($targetDir, 0777, true);
13+
touch($targetDir . DIRECTORY_SEPARATOR . 'getSubPath_test.tmp');
14+
$iterator = new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . $depth0);
15+
$it = new RecursiveIteratorIterator($iterator);
16+
17+
$list = [];
18+
while($it->valid()) {
19+
$list[] = $it->getSubPath();
20+
$it->next();
21+
}
22+
asort($list);
23+
foreach ($list as $item) {
24+
echo $item . "\n";
25+
}
26+
?>
27+
==DONE==
28+
--CLEAN--
29+
<?php
30+
function rrmdir($dir) {
31+
foreach(glob($dir . '/*') as $file) {
32+
if(is_dir($file)) {
33+
rrmdir($file);
34+
} else {
35+
unlink($file);
36+
}
37+
}
38+
39+
rmdir($dir);
40+
}
41+
42+
$targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('recursiveDirectoryIterator::getSubPath');
43+
rrmdir($targetDir);
44+
?>
45+
46+
--EXPECT--
47+
a0c967a6c2c34786e4802f59af9356f5
48+
a0c967a6c2c34786e4802f59af9356f5
49+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507
50+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507
51+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507
52+
==DONE==
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
RecursiveDirectoryIterator::getBasePathname() - basic test
3+
--CREDITS--
4+
Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl>
5+
#testfest AmsterdamPHP 2012-06-23
6+
--FILE--
7+
<?php
8+
$depth0 = md5('recursiveDirectoryIterator::getSubPathname');
9+
$depth1 = md5('depth1');
10+
$depth2 = md5('depth2');
11+
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2;
12+
mkdir($targetDir, 0777, true);
13+
touch($targetDir . DIRECTORY_SEPARATOR . 'getSubPathname_test_2.tmp');
14+
touch(__DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . 'getSubPathname_test_3.tmp');
15+
touch(__DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . 'getSubPathname_test_1.tmp');
16+
$iterator = new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . $depth0);
17+
$it = new RecursiveIteratorIterator($iterator);
18+
19+
$list = [];
20+
while($it->valid()) {
21+
$list[] = $it->getSubPathname();
22+
$it->next();
23+
}
24+
asort($list);
25+
foreach ($list as $item) {
26+
echo $item . "\n";
27+
}
28+
?>
29+
==DONE==
30+
--CLEAN--
31+
<?php
32+
function rrmdir($dir) {
33+
foreach(glob($dir . '/*') as $file) {
34+
if(is_dir($file)) {
35+
rrmdir($file);
36+
} else {
37+
unlink($file);
38+
}
39+
}
40+
41+
rmdir($dir);
42+
}
43+
44+
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . md5('recursiveDirectoryIterator::getSubPathname');
45+
rrmdir($targetDir);
46+
?>
47+
--EXPECT--
48+
.
49+
.
50+
..
51+
a0c967a6c2c34786e4802f59af9356f5/.
52+
a0c967a6c2c34786e4802f59af9356f5/..
53+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507/.
54+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507/..
55+
a0c967a6c2c34786e4802f59af9356f5/9925aabb545352472e4d77942627b507/getSubPathname_test_2.tmp
56+
a0c967a6c2c34786e4802f59af9356f5/getSubPathname_test_3.tmp
57+
getSubPathname_test_1.tmp
58+
==DONE==
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Testing error on null parameter 1 of http_build_query()
3+
--CREDITS--
4+
Pawel Krynicki <pawel.krynicki [at] xsolve [dot] pl>
5+
#testfest AmsterdamPHP 2012-06-23
6+
--FILE--
7+
<?php
8+
9+
$result = http_build_query(null);
10+
11+
?>
12+
--EXPECTF--
13+
Warning: http_build_query(): Parameter 1 expected to be Array or Object. %s value given in %s on line %d

sapi/cli/php_http_parser.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static const char *method_strings[] =
8181
, "HEAD"
8282
, "POST"
8383
, "PUT"
84+
, "PATCH"
8485
, "CONNECT"
8586
, "OPTIONS"
8687
, "TRACE"
@@ -627,6 +628,8 @@ size_t php_http_parser_execute (php_http_parser *parser,
627628
parser->method = PHP_HTTP_PROPFIND; /* or HTTP_PROPPATCH */
628629
} else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'U') {
629630
parser->method = PHP_HTTP_PUT;
631+
} else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'A') {
632+
parser->method = PHP_HTTP_PATCH;
630633
} else if (index == 2 && parser->method == PHP_HTTP_UNLOCK && ch == 'S') {
631634
parser->method = PHP_HTTP_UNSUBSCRIBE;
632635
} else if (index == 4 && parser->method == PHP_HTTP_PROPFIND && ch == 'P') {

sapi/cli/php_http_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum php_http_method
8080
, PHP_HTTP_HEAD
8181
, PHP_HTTP_POST
8282
, PHP_HTTP_PUT
83+
, PHP_HTTP_PATCH
8384
/* pathological */
8485
, PHP_HTTP_CONNECT
8586
, PHP_HTTP_OPTIONS
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
Implement Req #61679 (Support HTTP PATCH method)
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
?>
7+
--FILE--
8+
<?php
9+
include "php_cli_server.inc";
10+
php_cli_server_start(<<<'PHP'
11+
var_dump($_SERVER['REQUEST_METHOD']);
12+
PHP
13+
);
14+
15+
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
16+
$port = intval($port)?:80;
17+
18+
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
19+
if (!$fp) {
20+
die("connect failed");
21+
}
22+
23+
if(fwrite($fp, <<<HEADER
24+
PATCH / HTTP/1.1
25+
Host: {$host}
26+
27+
28+
HEADER
29+
)) {
30+
while (!feof($fp)) {
31+
echo fgets($fp);
32+
}
33+
}
34+
35+
fclose($fp);
36+
?>
37+
--EXPECTF--
38+
HTTP/1.1 200 OK
39+
Host: %s
40+
Connection: close
41+
X-Powered-By: %s
42+
Content-type: text/html
43+
44+
string(5) "PATCH"

win32/build/libs_version.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ freetype-2.4.3
44
icu-4.6.1
55
jpeglib-6b
66
libcurl-7.24.0
7-
libiconv-1.11
7+
libiconv-1.14
88
libmcrypt-2.5.8
99
libmpir-2.5.1
1010
libpng-1.2.46
1111
libpq-8.3.6
1212
libssh2-1.3.0
1313
libtidy-20090325
14-
libxslt-1.1.23
15-
libxml-2.7.7
16-
openssl-0.9.8u
14+
libxslt-1.1.27
15+
libxml-2.7.8
16+
openssl-0.9.8x

0 commit comments

Comments
 (0)