Skip to content

Commit 19b6e2c

Browse files
committed
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: (32 commits) fixed ZEND_DEBUG usage updated libmagic.patch added missing stdint header, bug #66907 fix macros /me blushes, really hard only build and test nts non-debug and ts debug builds as discussed at #654 Fix mysqli build when building against libmysqlclient. Fix author name on the #63228 patch. Fixed bug #67169: []= after_array_splice incorrect Revert "show leaks in their own group" using valgrind would be a bit too much for travis I guess. show leaks in their own group Use the right path for the suggested PHP invocation in ext_skel. Changed to more understandable NEWS message one heading is enough add new NEWS block for alpha3 XFAIL the leaking multibyte tests, we should really get to the bottom of this Fixed numbering in UPGRADING file Updated NEWS for fixed phpdbg issue #85 Added stdion/stdout/stderr constsnts and their php:// wrappers Fixes issue #85 Added stdion/stdout/stderr constsnts and their php:// wrappers Fixes issue #85 ...
2 parents 3491ef6 + bc92917 commit 19b6e2c

22 files changed

+240
-39
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ env:
1515
- PDO_MYSQL_TEST_USER=travis
1616
- PDO_MYSQL_TEST_PASS=
1717
- PDO_MYSQL_TEST_HOST=127.0.0.1
18-
matrix:
1918
- REPORT_EXIT_STATUS=1
19+
matrix:
20+
- ENABLE_MAINTAINER_ZTS=0 ENABLE_DEBUG=0
21+
- ENABLE_MAINTAINER_ZTS=1 ENABLE_DEBUG=1
2022

2123
before_script:
2224
# Compile PHP

Zend/tests/bug67169.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #67169: array_splice all elements, then []= gives wrong index
3+
--FILE--
4+
<?php
5+
6+
$array = array('a', 'b');
7+
array_splice($array, 0, 2);
8+
$array[] = 'c';
9+
var_dump($array);
10+
11+
$array = array('a', 'b');
12+
array_shift($array);
13+
array_shift($array);
14+
$array[] = 'c';
15+
var_dump($array);
16+
17+
?>
18+
--EXPECT--
19+
array(1) {
20+
[0]=>
21+
string(1) "c"
22+
}
23+
array(1) {
24+
[0]=>
25+
string(1) "c"
26+
}

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ ZEND_API void zend_deactivate(TSRMLS_D) /* {{{ */
954954

955955
zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC);
956956

957-
#ifdef ZEND_DEBUG
957+
#if ZEND_DEBUG
958958
if (GC_G(gc_enabled) && !CG(unclean_shutdown)) {
959959
gc_collect_cycles(TSRMLS_C);
960960
}

Zend/zend_hash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys) {
487487

488488
IS_CONSISTENT(ht);
489489
if (UNEXPECTED(ht->nNumOfElements == 0)) {
490+
ht->nNextFreeElement = 0;
490491
return;
491492
}
492493

ext/curl/interface.c

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,25 +2345,34 @@ static int _php_curl_setopt(php_curl *ch, php_int_t option, zval **zvalue TSRMLS
23452345
case CURLOPT_WRITEHEADER: {
23462346
FILE *fp = NULL;
23472347
int type;
2348-
void * what;
2348+
void *what = NULL;
23492349

2350-
what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
2351-
if (!what) {
2352-
return FAILURE;
2353-
}
2350+
if (Z_TYPE_PP(zvalue) != IS_NULL) {
2351+
what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
2352+
if (!what) {
2353+
return FAILURE;
2354+
}
23542355

2355-
if (FAILURE == php_stream_cast((php_stream *) what, PHP_STREAM_AS_STDIO, (void *) &fp, REPORT_ERRORS)) {
2356-
return FAILURE;
2357-
}
2356+
if (FAILURE == php_stream_cast((php_stream *) what, PHP_STREAM_AS_STDIO, (void *) &fp, REPORT_ERRORS)) {
2357+
return FAILURE;
2358+
}
23582359

2359-
if (!fp) {
2360-
return FAILURE;
2360+
if (!fp) {
2361+
return FAILURE;
2362+
}
23612363
}
23622364

23632365
error = CURLE_OK;
23642366
switch (option) {
23652367
case CURLOPT_FILE:
2366-
if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
2368+
if (!what) {
2369+
if (ch->handlers->write->stream) {
2370+
Z_DELREF_P(ch->handlers->write->stream);
2371+
ch->handlers->write->stream = NULL;
2372+
}
2373+
ch->handlers->write->fp = NULL;
2374+
ch->handlers->write->method = PHP_CURL_STDOUT;
2375+
} else if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
23672376
if (ch->handlers->write->stream) {
23682377
Z_DELREF_P(ch->handlers->write->stream);
23692378
}
@@ -2377,7 +2386,14 @@ static int _php_curl_setopt(php_curl *ch, php_int_t option, zval **zvalue TSRMLS
23772386
}
23782387
break;
23792388
case CURLOPT_WRITEHEADER:
2380-
if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
2389+
if (!what) {
2390+
if (ch->handlers->write_header->stream) {
2391+
Z_DELREF_P(ch->handlers->write_header->stream);
2392+
ch->handlers->write_header->stream = NULL;
2393+
}
2394+
ch->handlers->write_header->fp = NULL;
2395+
ch->handlers->write_header->method = PHP_CURL_IGNORE;
2396+
} else if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
23812397
if (ch->handlers->write_header->stream) {
23822398
Z_DELREF_P(ch->handlers->write_header->stream);
23832399
}
@@ -2391,16 +2407,30 @@ static int _php_curl_setopt(php_curl *ch, php_int_t option, zval **zvalue TSRMLS
23912407
}
23922408
break;
23932409
case CURLOPT_INFILE:
2394-
if (ch->handlers->read->stream) {
2395-
Z_DELREF_P(ch->handlers->read->stream);
2410+
if (!what) {
2411+
if (ch->handlers->read->stream) {
2412+
Z_DELREF_P(ch->handlers->read->stream);
2413+
ch->handlers->read->stream = NULL;
2414+
}
2415+
ch->handlers->read->fp = NULL;
2416+
ch->handlers->read->fd = 0;
2417+
} else {
2418+
if (ch->handlers->read->stream) {
2419+
Z_DELREF_P(ch->handlers->read->stream);
2420+
}
2421+
Z_ADDREF_PP(zvalue);
2422+
ch->handlers->read->fp = fp;
2423+
ch->handlers->read->fd = Z_IVAL_PP(zvalue);
2424+
ch->handlers->read->stream = *zvalue;
23962425
}
2397-
Z_ADDREF_PP(zvalue);
2398-
ch->handlers->read->fp = fp;
2399-
ch->handlers->read->fd = Z_IVAL_PP(zvalue);
2400-
ch->handlers->read->stream = *zvalue;
24012426
break;
24022427
case CURLOPT_STDERR:
2403-
if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
2428+
if (!what) {
2429+
if (ch->handlers->std_err) {
2430+
zval_ptr_dtor(&ch->handlers->std_err);
2431+
ch->handlers->std_err = NULL;
2432+
}
2433+
} else if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') {
24042434
if (ch->handlers->std_err) {
24052435
zval_ptr_dtor(&ch->handlers->std_err);
24062436
}

ext/curl/tests/bug54798.phpt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,13 @@ foreach($options_to_check as $option) {
5353
}
5454

5555
?>
56+
===DONE===
5657
--CLEAN--
5758
<?php @unlink(dirname(__FILE__) . '/bug54798.tmp'); ?>
5859
--EXPECTF--
59-
Warning: curl_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug54798.php on line %d
60-
* About to connect() %a
61-
* Closing connection %d
62-
Ok for CURLOPT_STDERR
63-
64-
Warning: curl_exec(): CURLOPT_WRITEHEADER resource has gone away, resetting to default in %sbug54798.php on line 24
65-
Ok for CURLOPT_WRITEHEADER
66-
67-
Warning: curl_exec(): CURLOPT_FILE resource has gone away, resetting to default in %sbug54798.php on line 24
60+
%a
61+
%aOk for CURLOPT_STDERR
62+
%aOk for CURLOPT_WRITEHEADER
6863
%aOk for CURLOPT_FILE
69-
70-
Warning: curl_exec(): CURLOPT_INFILE resource has gone away, resetting to default in %sbug54798.php on line %d
71-
Ok for CURLOPT_INFILE
64+
%aOk for CURLOPT_INFILE
65+
===DONE===

ext/curl/tests/bug64267.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Bug #64267 (CURLOPT_INFILE doesn't allow reset)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("curl") or die("skip need ext/curl");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
echo "TEST\n";
11+
12+
$c = curl_init("http://google.com");
13+
$f = fopen(__FILE__,"r");
14+
var_dump(curl_setopt_array($c, [
15+
CURLOPT_RETURNTRANSFER => true,
16+
CURLOPT_UPLOAD => true,
17+
CURLOPT_INFILE => $f,
18+
CURLOPT_INFILESIZE => filesize(__FILE__)
19+
]));
20+
fclose($f);
21+
var_dump(curl_setopt_array($c, [
22+
CURLOPT_UPLOAD => false,
23+
CURLOPT_INFILE => null,
24+
CURLOPT_INFILESIZE => 0,
25+
]));
26+
curl_exec($c);
27+
var_dump(curl_getinfo($c, CURLINFO_RESPONSE_CODE));
28+
?>
29+
===DONE===
30+
--EXPECTF--
31+
TEST
32+
bool(true)
33+
bool(true)
34+
int(30%d)
35+
===DONE===

ext/curl/tests/curl_basic_008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ curl_close($ch);
2525

2626
?>
2727
--EXPECTF--
28-
%unicode|string%(%d) "%r(Couldn't resolve host|Could not resolve host:)%r %Swww.%s"
28+
%s resolve%s
2929
int(6)

ext/curl/tests/curl_basic_010.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ curl_close($ch);
2626

2727
?>
2828
--EXPECTF--
29-
%unicode|string%(%d) "%r(Couldn't resolve proxy|Could not resolve proxy:|Could not resolve host:)%r %s"
29+
%unicode|string%(%d) "%r(Couldn't resolve proxy|Could not resolve proxy:|Could not resolve host:|Could not resolve:)%r %s"
3030
int(5)

ext/curl/tests/curl_reset.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ unlink($test_file);
3636
unlink($log_file);
3737

3838
?>
39+
40+
===DONE===
3941
--EXPECT--
4042
testtest
43+
===DONE===

ext/ext_skel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ To use your new extension, you will have to execute the following steps:
320320
3. $ ./buildconf
321321
4. $ ./configure --[with|enable]-$extname
322322
5. $ make
323-
6. $ ./php -f ext/$extname/$extname.php
323+
6. $ ./sapi/cli/php -f ext/$extname/$extname.php
324324
7. $ vi ext/$extname/$extname.c
325325
8. $ make
326326

ext/fileinfo/libmagic.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,4 +3286,16 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
32863286
break;
32873287
}
32883288
case FILE_INDIRECT:
3289+
diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
3290+
--- libmagic.orig/strcasestr.c Thu Dec 5 17:57:50 2013
3291+
+++ libmagic/strcasestr.c Sun May 4 21:29:20 2014
3292+
@@ -37,6 +37,8 @@
3293+
__RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
3294+
#endif /* LIBC_SCCS and not lint */
3295+
3296+
+#include "php_stdint.h"
3297+
+
3298+
#include <assert.h>
3299+
#include <ctype.h>
3300+
#include <string.h>
32893301

ext/fileinfo/libmagic/strcasestr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ __RCSID("$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
3737
__RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
3838
#endif /* LIBC_SCCS and not lint */
3939

40+
#include "php_stdint.h"
41+
4042
#include <assert.h>
4143
#include <ctype.h>
4244
#include <string.h>

ext/interbase/php_ibase_includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#define IB_STATUS (IBG(status))
3737

38+
/* XXX ZEND_DEBUG_ is misleading, it should be something like IBASE_DEBUG. */
3839
#ifdef ZEND_DEBUG_
3940
#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
4041
#endif

ext/mbstring/tests/zend_multibyte-08.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
22
zend multibyte (8)
3+
--SKIPIF--
4+
--XFAIL--
5+
https://bugs.php.net/bug.php?id=66582 - still leaks memory which causes fail in debug mode
36
--INI--
47
zend.multibyte=On
58
zend.script_encoding=ISO-8859-1

ext/mbstring/tests/zend_multibyte-10.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
22
zend multibyte (10)
3+
--SKIPIF--
4+
--XFAIL--
5+
https://bugs.php.net/bug.php?id=66582 - still leaks memory which causes fail in debug mode
36
--INI--
47
zend.multibyte=1
58
--FILE--

ext/mbstring/tests/zend_multibyte-11.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
22
zend multibyte (11)
3+
--SKIPIF--
4+
--XFAIL--
5+
https://bugs.php.net/bug.php?id=66582 - still leaks memory which causes fail in debug mode
36
--INI--
47
zend.multibyte=1
58
--FILE--

ext/mysqli/mysqli_nonapi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ PHP_FUNCTION(mysqli_query)
575575
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty query");
576576
RETURN_FALSE;
577577
}
578+
#ifdef MYSQLI_USE_MYSQLND
578579
if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~(MYSQLI_ASYNC | MYSQLI_STORE_RESULT_COPY_DATA)) != MYSQLI_STORE_RESULT) {
580+
#else
581+
if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~MYSQLI_ASYNC) != MYSQLI_STORE_RESULT) {
582+
#endif
579583
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for resultmode");
580584
RETURN_FALSE;
581585
}
@@ -609,7 +613,11 @@ PHP_FUNCTION(mysqli_query)
609613
RETURN_TRUE;
610614
}
611615

616+
#ifdef MYSQLI_USE_MYSQLND
612617
switch (resultmode & ~(MYSQLI_ASYNC | MYSQLI_STORE_RESULT_COPY_DATA)) {
618+
#else
619+
switch (resultmode & ~MYSQLI_ASYNC) {
620+
#endif
613621
case MYSQLI_STORE_RESULT:
614622
#ifdef MYSQLI_USE_MYSQLND
615623
if (resultmode & MYSQLI_STORE_RESULT_COPY_DATA) {

ext/standard/html.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ static inline size_t write_octet_sequence(unsigned char *buf, enum entity_charse
901901
#if 0
902902
return php_mb2_int_to_char(buf, code);
903903
#else
904-
#ifdef ZEND_DEBUG
904+
#if ZEND_DEBUG
905905
assert(code <= 0xFFU);
906906
#endif
907907
*buf = code;
@@ -912,7 +912,7 @@ static inline size_t write_octet_sequence(unsigned char *buf, enum entity_charse
912912
#if 0 /* idem */
913913
return php_mb2_int_to_char(buf, code);
914914
#else
915-
#ifdef ZEND_DEBUG
915+
#if ZEND_DEBUG
916916
assert(code <= 0xFFU);
917917
#endif
918918
*buf = code;

sapi/phpdbg/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then
2121
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c"
2222

2323
if test "$PHP_READLINE" != "no"; then
24-
PHPDBG_EXTRA_LIBS="-lreadline"
24+
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
2525
fi
2626

2727
PHP_SUBST(PHP_PHPDBG_CFLAGS)

0 commit comments

Comments
 (0)