Skip to content

Commit 4e6a0bd

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Added tests for PHAR/OPCahce incompatibilities Update NEWS Fixed bug #65947 (basename is no more working after fgetcsv in certain situation) Update NEWS Fixed Bug #66043 (Segfault calling bind_param() on mysqli) NEWS entry NEWS entry Conflicts: NEWS
2 parents 756dc19 + 49fbe25 commit 4e6a0bd

File tree

7 files changed

+173
-2
lines changed

7 files changed

+173
-2
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
385385
/* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */
386386
my_bool tmp;
387387
#else
388-
uint tmp = 0;
388+
ulong tmp = 0;
389389
#endif
390390
stmt->result.buf[ofs].type = IS_STRING;
391391
/*

ext/mysqli/tests/bug66043.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #66043 (Segfault calling bind_param() on mysqli)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once("connect.inc");
7+
if ($IS_MYSQLND) {
8+
die("skip libmysql only test");
9+
}
10+
require_once('skipifconnectfailure.inc');
11+
?>
12+
--FILE--
13+
<?php
14+
require 'connect.inc';
15+
$db = new mysqli($host, $user, $passwd, 'mysql');
16+
17+
$stmt = $db->stmt_init();
18+
$stmt->prepare("SELECT User FROM user WHERE password=\"\"");
19+
$stmt->execute();
20+
$stmt->bind_result($testArg);
21+
echo "Okey";
22+
?>
23+
--EXPECTF--
24+
Okey

ext/opcache/tests/issue0115.phpt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
ISSUE #115 (path issue when using phar)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
phar.readonly=0
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
<?php if (!extension_loaded("phar")) die("skip"); ?>
10+
<?php if (php_sapi_name() != "cli") die("skip CLI only"); ?>
11+
--FILE--
12+
<?php
13+
$stub = '<?php
14+
Phar::interceptFileFuncs();
15+
require "phar://this/index.php";
16+
__HALT_COMPILER(); ?>';
17+
$p = new Phar(__DIR__ . '/issue0115_1.phar.php', 0, 'this');
18+
$p['index.php'] = '<?php
19+
echo "Hello from Index 1.\n";
20+
require_once "phar://this/hello.php";
21+
';
22+
$p['hello.php'] = "Hello World 1!\n";
23+
$p->setStub($stub);
24+
unset($p);
25+
$p = new Phar(__DIR__ . '/issue0115_2.phar.php', 0, 'this');
26+
$p['index.php'] = '<?php
27+
echo "Hello from Index 2.\n";
28+
require_once "phar://this/hello.php";
29+
';
30+
$p['hello.php'] = "Hello World 2!\n";
31+
$p->setStub($stub);
32+
unset($p);
33+
34+
include "php_cli_server.inc";
35+
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1');
36+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_1.phar.php');
37+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_2.phar.php');
38+
?>
39+
--CLEAN--
40+
<?php
41+
@unlink(__DIR__ . '/issue0115_1.phar.php');
42+
@unlink(__DIR__ . '/issue0115_2.phar.php');
43+
?>
44+
--EXPECT--
45+
Hello from Index 1.
46+
Hello World 1!
47+
Hello from Index 2.
48+
Hello World 2!

ext/opcache/tests/issue0149.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
ISSUE #149 (Phar mount points not working this OPcache enabled)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
phar.readonly=0
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
<?php if (!extension_loaded("phar")) die("skip"); ?>
10+
<?php if (php_sapi_name() != "cli") die("skip CLI only"); ?>
11+
--FILE--
12+
<?php
13+
$stub = "<?php header('Content-Type: text/plain;');
14+
Phar::mount('this.file', '". __FILE__ . "');
15+
echo 'OK\n';
16+
__HALT_COMPILER(); ?>";
17+
$p = new Phar(__DIR__ . '/issue0149.phar.php', 0, 'this');
18+
$p['index.php'] = ""; # A Phar must have at least one file, hence this dummy
19+
$p->setStub($stub);
20+
unset($p);
21+
22+
include "php_cli_server.inc";
23+
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1');
24+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
25+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
26+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
27+
?>
28+
--CLEAN--
29+
<?php
30+
@unlink(__DIR__ . '/issue0149.phar.php');
31+
?>
32+
--EXPECT--
33+
OK
34+
OK
35+
OK

ext/opcache/tests/php_cli_server.inc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
3+
define ("PHP_CLI_SERVER_PORT", 8964);
4+
define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
5+
6+
function php_cli_server_start($ini = "") {
7+
$php_executable = getenv('TEST_PHP_EXECUTABLE');
8+
$doc_root = __DIR__;
9+
10+
$descriptorspec = array(
11+
0 => STDIN,
12+
1 => STDOUT,
13+
2 => STDERR,
14+
);
15+
16+
if (substr(PHP_OS, 0, 3) == 'WIN') {
17+
$cmd = "{$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS;
18+
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
19+
} else {
20+
$cmd = "exec {$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS . " 2>/dev/null";
21+
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
22+
}
23+
24+
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
25+
// it might not be listening yet...need to wait until fsockopen() call returns
26+
$i = 0;
27+
while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) {
28+
usleep(10000);
29+
}
30+
31+
if ($fp) {
32+
fclose($fp);
33+
}
34+
35+
register_shutdown_function(
36+
function($handle) {
37+
proc_terminate($handle);
38+
},
39+
$handle
40+
);
41+
// don't bother sleeping, server is already up
42+
// server can take a variable amount of time to be up, so just sleeping a guessed amount of time
43+
// does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass
44+
// sleeping doesn't work.
45+
}
46+
?>
47+

ext/standard/php_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ PHPAPI char *php_strerror(int errnum);
156156
# define php_mblen(ptr, len) 1
157157
#else
158158
# if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
159-
# define php_mblen(ptr, len) ((ptr) == NULL ? mbsinit(&BG(mblen_state)): (int)mbrlen(ptr, len, &BG(mblen_state)))
159+
# define php_mblen(ptr, len) ((ptr) == NULL ? memset(&BG(mblen_state), 0, sizeof(BG(mblen_state))): (int)mbrlen(ptr, len, &BG(mblen_state)))
160160
# else
161161
# define php_mblen(ptr, len) mblen(ptr, len)
162162
# endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #65947 (basename is no more working after fgetcsv in certain situation)
3+
--SKIPIF--
4+
<?php if (!PHP_ZTS) { print "skip only for zts build"; }
5+
--FILE--
6+
<?php
7+
$filename = 'test.toto';
8+
// é in ISO-8859-1
9+
$csv = base64_decode('6Q==');
10+
$adata = str_getcsv($csv,";");
11+
$b2 = basename($filename);
12+
if ($filename != $b2)
13+
print "BUG";
14+
else
15+
print "OKEY";
16+
--EXPECTF--
17+
OKEY

0 commit comments

Comments
 (0)