From 224dc52ea99f088597a7f5d1d09ddf68dca9dfb8 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Thu, 7 Nov 2013 18:15:15 -0800 Subject: [PATCH 1/7] NEWS entry --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index c3e70d94a3f..7e426956e50 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2013, PHP 5.4.23 +- PDO + . Fixed bug 65946 (sql_parser permanently converts values bound to strings) ?? ??? 2013, PHP 5.4.22 From caab95155d236c0222189aaef6e49c54777257e6 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Thu, 7 Nov 2013 18:16:12 -0800 Subject: [PATCH 2/7] NEWS entry --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 3a690bbafe6..8c2b651819b 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,7 @@ PHP NEWS - PDO: . Fixed bug #66033 (Segmentation Fault when constructor of PDO statement throws an exception). (Laruence) + . Fixed bug 65946 (sql_parser permanently converts values bound to strings) - Standard: . Fixed bug #64760 (var_export() does not use full precision for floating-point From fd3fa9b53c6bc8f34c1c8bf75141f7ee74dc8db0 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 8 Nov 2013 15:06:36 +0800 Subject: [PATCH 3/7] Fixed Bug #66043 (Segfault calling bind_param() on mysqli) Although the doc said it is (unsigned int *), but it is ulong* in the libmysql 5.0 's source codes --- NEWS | 4 ++++ ext/mysqli/mysqli_api.c | 2 +- ext/mysqli/tests/bug66043.phpt | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 ext/mysqli/tests/bug66043.phpt diff --git a/NEWS b/NEWS index 7e426956e50..091ae9aa814 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2013, PHP 5.4.23 + +- MySQLi: + . Fixed bug #66043 (Segfault calling bind_param() on mysqli). (Laruence) + - PDO . Fixed bug 65946 (sql_parser permanently converts values bound to strings) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 2cda0aa903c..6078a5e758d 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -384,7 +384,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc, /* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */ my_bool tmp; #else - uint tmp = 0; + ulong tmp = 0; #endif stmt->result.buf[ofs].type = IS_STRING; /* diff --git a/ext/mysqli/tests/bug66043.phpt b/ext/mysqli/tests/bug66043.phpt new file mode 100644 index 00000000000..d0e8b1c3d39 --- /dev/null +++ b/ext/mysqli/tests/bug66043.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #66043 (Segfault calling bind_param() on mysqli) +--SKIPIF-- + +--FILE-- +stmt_init(); +$stmt->prepare("SELECT User FROM user WHERE password=\"\""); +$stmt->execute(); +$stmt->bind_result($testArg); +echo "Okey"; +?> +--EXPECTF-- +Okey From f345152037b72b7d3155e366e6fbe091c228062b Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 8 Nov 2013 15:08:07 +0800 Subject: [PATCH 4/7] Update NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 8c2b651819b..02d8b0ec328 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ PHP NEWS - FPM: . Changed default listen() backlog to 65535. (Tony) +- MySQLi: + . Fixed bug #66043 (Segfault calling bind_param() on mysqli). (Laruence) + - OPcache . Increased limit for opcache.max_accelerated_files to 1,000,000. (Chris) From cf2626f10c92709f8db44afa15fc09ec6a9d8b0c Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 8 Nov 2013 15:32:28 +0800 Subject: [PATCH 5/7] Fixed bug #65947 (basename is no more working after fgetcsv in certain situation) previous codes: "#define php_mblen(ptr, len) ((ptr) == NULL ? mbsinit(&BG(mblen_state)): (int)mbrlen(ptr, len, &BG(mblen_state)))# it use mbsinit there, seems try to initialize the mblen_state, but: "This function does not change the state identified by ps. Typical ways to make the state pointed by ps an initial state are: memset (ps,0,sizeof(*ps)); // ps points to zero-valued object " http://www.cplusplus.com/reference/cwchar/mbsinit/?kw=mbsinit --- NEWS | 4 ++++ ext/standard/php_string.h | 2 +- ext/standard/tests/strings/bug65947.phpt | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug65947.phpt diff --git a/NEWS b/NEWS index 091ae9aa814..4689a436ca4 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2013, PHP 5.4.23 +- Core: + . Fixed bug #65947 (basename is no more working after fgetcsv in certain + situation). (Laruence) + - MySQLi: . Fixed bug #66043 (Segfault calling bind_param() on mysqli). (Laruence) diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 65219f257ad..1ce98ee07a2 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -156,7 +156,7 @@ PHPAPI char *php_strerror(int errnum); # define php_mblen(ptr, len) 1 #else # if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T) -# define php_mblen(ptr, len) ((ptr) == NULL ? mbsinit(&BG(mblen_state)): (int)mbrlen(ptr, len, &BG(mblen_state))) +# define php_mblen(ptr, len) ((ptr) == NULL ? memset(&BG(mblen_state), 0, sizeof(BG(mblen_state))): (int)mbrlen(ptr, len, &BG(mblen_state))) # else # define php_mblen(ptr, len) mblen(ptr, len) # endif diff --git a/ext/standard/tests/strings/bug65947.phpt b/ext/standard/tests/strings/bug65947.phpt new file mode 100644 index 00000000000..956aa6049a2 --- /dev/null +++ b/ext/standard/tests/strings/bug65947.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #65947 (basename is no more working after fgetcsv in certain situation) +--SKIPIF-- + Date: Fri, 8 Nov 2013 15:33:49 +0800 Subject: [PATCH 6/7] Update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 02d8b0ec328..0fd30ced060 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2013, PHP 5.5.6 - Core: + . Fixed bug #65947 (basename is no more working after fgetcsv in certain + situation). (Laruence) . Improved performance of array_merge() and func_get_args() by eliminating useless copying. (Dmitry) . Fixed bug #65939 (Space before ";" breaks php.ini parsing). From 49fbe2579e9cbb4314346c8eaf959c670de0abdb Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 8 Nov 2013 13:50:57 +0400 Subject: [PATCH 7/7] Added tests for PHAR/OPCahce incompatibilities --- ext/opcache/tests/issue0115.phpt | 48 ++++++++++++++++++++++++++++ ext/opcache/tests/issue0149.phpt | 35 ++++++++++++++++++++ ext/opcache/tests/php_cli_server.inc | 47 +++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 ext/opcache/tests/issue0115.phpt create mode 100644 ext/opcache/tests/issue0149.phpt create mode 100644 ext/opcache/tests/php_cli_server.inc diff --git a/ext/opcache/tests/issue0115.phpt b/ext/opcache/tests/issue0115.phpt new file mode 100644 index 00000000000..a1e469ff2fe --- /dev/null +++ b/ext/opcache/tests/issue0115.phpt @@ -0,0 +1,48 @@ +--TEST-- +ISSUE #115 (path issue when using phar) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +phar.readonly=0 +--SKIPIF-- + + + +--FILE-- +'; +$p = new Phar(__DIR__ . '/issue0115_1.phar.php', 0, 'this'); +$p['index.php'] = 'setStub($stub); +unset($p); +$p = new Phar(__DIR__ . '/issue0115_2.phar.php', 0, 'this'); +$p['index.php'] = 'setStub($stub); +unset($p); + +include "php_cli_server.inc"; +php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_1.phar.php'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_2.phar.php'); +?> +--CLEAN-- + +--EXPECT-- +Hello from Index 1. +Hello World 1! +Hello from Index 2. +Hello World 2! diff --git a/ext/opcache/tests/issue0149.phpt b/ext/opcache/tests/issue0149.phpt new file mode 100644 index 00000000000..7044d393883 --- /dev/null +++ b/ext/opcache/tests/issue0149.phpt @@ -0,0 +1,35 @@ +--TEST-- +ISSUE #149 (Phar mount points not working this OPcache enabled) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +phar.readonly=0 +--SKIPIF-- + + + +--FILE-- +"; +$p = new Phar(__DIR__ . '/issue0149.phar.php', 0, 'this'); +$p['index.php'] = ""; # A Phar must have at least one file, hence this dummy +$p->setStub($stub); +unset($p); + +include "php_cli_server.inc"; +php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php'); +?> +--CLEAN-- + +--EXPECT-- +OK +OK +OK diff --git a/ext/opcache/tests/php_cli_server.inc b/ext/opcache/tests/php_cli_server.inc new file mode 100644 index 00000000000..0878bfafc0d --- /dev/null +++ b/ext/opcache/tests/php_cli_server.inc @@ -0,0 +1,47 @@ + STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $cmd = "{$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS; + $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); + } else { + $cmd = "exec {$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS . " 2>/dev/null"; + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + } + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $i = 0; + while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) { + usleep(10000); + } + + if ($fp) { + fclose($fp); + } + + register_shutdown_function( + function($handle) { + proc_terminate($handle); + }, + $handle + ); + // don't bother sleeping, server is already up + // server can take a variable amount of time to be up, so just sleeping a guessed amount of time + // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass + // sleeping doesn't work. +} +?> +