diff options
Diffstat (limited to 'ext')
307 files changed, 1795 insertions, 481 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index d7d5c51c4d..b57ce1bd07 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1606,9 +1606,9 @@ PHP_FUNCTION(curl_copy_handle) dupch->uses = 0; ch->uses++; if (ch->handlers->write->stream) { - Z_ADDREF_P(dupch->handlers->write->stream); - dupch->handlers->write->stream = ch->handlers->write->stream; + Z_ADDREF_P(ch->handlers->write->stream); } + dupch->handlers->write->stream = ch->handlers->write->stream; dupch->handlers->write->method = ch->handlers->write->method; dupch->handlers->write->type = ch->handlers->write->type; if (ch->handlers->read->stream) { diff --git a/ext/curl/tests/bug62839.phpt b/ext/curl/tests/bug62839.phpt new file mode 100644 index 0000000000..39e6fc9cbe --- /dev/null +++ b/ext/curl/tests/bug62839.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #62839 (curl_copy_handle segfault with CURLOPT_FILE) +--SKIPIF-- +<?php if (!extension_loaded("curl")) print "skip"; +?> +--FILE-- +<?php +$curl = curl_init(); + +$fd = fopen('/tmp/test', 'wb'); +curl_setopt($curl, CURLOPT_FILE, $fd); + +curl_copy_handle($curl); + +echo 'DONE!'; +?> +--EXPECTF-- +DONE! diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 13e7b753d3..7c4e7820bb 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2467,6 +2467,9 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) { convert_to_long(*z_timezone_type); if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) { + zend_error_handling error_handling; + + zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); convert_to_string(*z_timezone); switch (Z_LVAL_PP(z_timezone_type)) { @@ -2474,9 +2477,9 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat case TIMELIB_ZONETYPE_ABBR: { char *tmp = emalloc(Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2); snprintf(tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2, "%s %s", Z_STRVAL_PP(z_date), Z_STRVAL_PP(z_timezone)); - php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC); + php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 1 TSRMLS_CC); efree(tmp); - return 1; + break; } case TIMELIB_ZONETYPE_ID: @@ -2490,10 +2493,15 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat tzobj->tzi.tz = tzi; tzobj->initialized = 1; - php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC); + php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 1 TSRMLS_CC); zval_ptr_dtor(&tmp_obj); - return 1; + break; + default: + zend_restore_error_handling(&error_handling TSRMLS_CC); + return 0; } + zend_restore_error_handling(&error_handling TSRMLS_CC); + return 1; } } } diff --git a/ext/date/tests/bug62852.phpt b/ext/date/tests/bug62852.phpt new file mode 100644 index 0000000000..6426a80fb8 --- /dev/null +++ b/ext/date/tests/bug62852.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62852 (Unserialize invalid DateTime causes crash) +--INI-- +date.timezone=GMT +--FILE-- +<?php +try { + $datetime = unserialize('O:8:"DateTime":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}'); + var_dump($datetime); +} catch (Exception $e) { + var_dump($e->getMessage()); +} +?> +--EXPECTF-- +string(%d) "DateTime::__wakeup(): Failed to parse time string (%s) at position 12 (0): Double time specification" diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c index d61ba796ab..eee3b5f887 100644 --- a/ext/dom/documenttype.c +++ b/ext/dom/documenttype.c @@ -205,7 +205,11 @@ int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_ if (buff != NULL) { xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); xmlOutputBufferFlush(buff); +#ifdef LIBXML2_NEW_BUFFER + ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), xmlOutputBufferGetSize(buff), 1); +#else ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1); +#endif (void)xmlOutputBufferClose(buff); return SUCCESS; } diff --git a/ext/dom/element.c b/ext/dom/element.c index c6a1902129..02fded9f1a 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -832,7 +832,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns) } if (errorcode == 0 && is_xmlns == 0) { - attr = xmlSetNsProp(elemp, nsptr, (xmlChar *)localname, (xmlChar *)value); + xmlSetNsProp(elemp, nsptr, (xmlChar *)localname, (xmlChar *)value); } } else { name_valid = xmlValidateName((xmlChar *) localname, 0); @@ -844,7 +844,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns) if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) { node_list_unlink(attr->children TSRMLS_CC); } - attr = xmlSetProp(elemp, (xmlChar *)localname, (xmlChar *)value); + xmlSetProp(elemp, (xmlChar *)localname, (xmlChar *)value); } } } diff --git a/ext/dom/node.c b/ext/dom/node.c index 4e58421e4a..4dbce4d790 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ RETVAL_FALSE; } else { if (mode == 0) { +#ifdef LIBXML2_NEW_BUFFER + ret = xmlOutputBufferGetSize(buf); +#else ret = buf->buffer->use; +#endif if (ret > 0) { +#ifdef LIBXML2_NEW_BUFFER + RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1); +#else RETVAL_STRINGL((char *) buf->buffer->content, ret, 1); +#endif } else { RETVAL_EMPTY_STRING(); } diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 2d784ebbef..357f3cb034 100755 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -730,6 +730,7 @@ PHP_FUNCTION(enchant_dict_quick_check) if (sugg) { zval_dtor(sugg); + array_init(sugg); } PHP_ENCHANT_GET_DICT; @@ -743,8 +744,6 @@ PHP_FUNCTION(enchant_dict_quick_check) RETURN_FALSE; } - array_init(sugg); - suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st); memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg)); if (suggs && n_sugg) { diff --git a/ext/exif/tests/bug60150.phpt b/ext/exif/tests/bug60150.phpt index 63cf0a9daf..be01998fd8 100755 --- a/ext/exif/tests/bug60150.phpt +++ b/ext/exif/tests/bug60150.phpt @@ -12,7 +12,7 @@ var_dump(exif_read_data($infile)); ?> ===DONE=== --EXPECTF-- -Warning: exif_read_data(bug60150.jpg): Process tag(x9003=DateTimeOri): Illegal pointer offset(x%x + x%x = x%x > x%x) in %s on line %d +Warning: exif_read_data(bug60150.jpg): Process tag(x9003=DateTimeOri): Illegal pointer offset(%s) in %s on line %d Warning: exif_read_data(bug60150.jpg): Error reading from file: got=x%x(=%d) != itemlen-%d=x%x(=%d) in %s on line %d diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 757ba04ac1..e5e52f0995 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -270,7 +270,7 @@ ZEND_GET_MODULE(fileinfo) PHP_MINFO_FUNCTION(fileinfo) { php_info_print_table_start(); - php_info_print_table_header(2, "fileinfo support", "enabled"); + php_info_print_table_row(2, "fileinfo support", "enabled"); php_info_print_table_row(2, "version", PHP_FILEINFO_VERSION); php_info_print_table_end(); } diff --git a/ext/gmp/tests/022-win32.phpt b/ext/gmp/tests/022-win32.phpt deleted file mode 100644 index 7abb0e82bd..0000000000 --- a/ext/gmp/tests/022-win32.phpt +++ /dev/null @@ -1,90 +0,0 @@ ---TEST-- -gmp_gcdext() basic tests ---SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; -if(substr(PHP_OS, 0, 3) != 'WIN' ) { - die('skip windows only test'); -} -?> ---FILE-- -<?php - -$n = gmp_init("34293864345"); -$n1 = gmp_init("23434293864345"); - -$a = array( - array(123,45), - array(4341,9734), - array(23487,333), - array(-234234,-123123), - array(-100,-2234), - array(345,"34587345"), - array(345,"0"), - array("345556456",345873), - array("34545345556456","323432445873"), - array($n, $n1), - ); - -foreach ($a as $val) { - $r = gmp_gcdext($val[0],$val[1]); - var_dump(gmp_strval($r['g'])); - var_dump(gmp_strval($r['s'])); - var_dump(gmp_strval($r['t'])); -} - -var_dump(gmp_gcdext($val[0],array())); -var_dump(gmp_gcdext(array(),array())); -var_dump(gmp_gcdext(array(),array(),1)); -var_dump(gmp_gcdext(array())); -var_dump(gmp_gcdext()); - -echo "Done\n"; -?> ---EXPECTF-- -string(1) "3" -string(2) "41" -string(4) "-112" -string(1) "1" -string(4) "-805" -string(3) "359" -string(1) "3" -string(2) "32" -string(5) "-2257" -string(4) "3003" -string(3) "-10" -string(2) "19" -string(1) "2" -string(2) "67" -string(2) "-3" -string(2) "15" -string(7) "-601519" -string(1) "6" -string(3) "345" -string(1) "1" -string(1) "0" -string(1) "1" -string(5) "84319" -string(9) "-84241831" -string(1) "1" -string(12) "167180205823" -string(15) "-17856272782919" -string(3) "195" -string(15) "-23387298979862" -string(11) "34225091793" - -Warning: gmp_gcdext(): Unable to convert variable to GMP - wrong type in %s on line %d -bool(false) - -Warning: gmp_gcdext(): Unable to convert variable to GMP - wrong type in %s on line %d -bool(false) - -Warning: gmp_gcdext() expects exactly 2 parameters, 3 given in %s on line %d -NULL - -Warning: gmp_gcdext() expects exactly 2 parameters, 1 given in %s on line %d -NULL - -Warning: gmp_gcdext() expects exactly 2 parameters, 0 given in %s on line %d -NULL -Done - diff --git a/ext/gmp/tests/022.phpt b/ext/gmp/tests/022.phpt index f699e8283d..469aa3013d 100644 --- a/ext/gmp/tests/022.phpt +++ b/ext/gmp/tests/022.phpt @@ -2,9 +2,6 @@ gmp_gcdext() basic tests --SKIPIF-- <?php if (!extension_loaded("gmp")) print "skip"; -if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip.. only for Non Windows Systems'); -} ?> --FILE-- <?php diff --git a/ext/gmp/tests/gmp_nextprime-win32.phpt b/ext/gmp/tests/gmp_nextprime-win32.phpt deleted file mode 100644 index e725315a13..0000000000 --- a/ext/gmp/tests/gmp_nextprime-win32.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -gmp_nextprime() ---SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; -if(substr(PHP_OS, 0, 3) != 'WIN' ) { - die('skip windows only test'); -} -?> ---FILE-- -<?php - -$n = gmp_nextprime(-1); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(0); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(-1000); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(1000); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(100000); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(array()); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(""); -var_dump(gmp_strval($n)); -$n = gmp_nextprime(new stdclass()); -var_dump(gmp_strval($n)); - -echo "Done\n"; -?> ---EXPECTF-- -string(1) "2" -string(1) "2" -string(4) "-997" -string(4) "1009" -string(6) "100003" - -Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d -string(1) "0" -string(1) "0" - -Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d -string(1) "0" -Done - diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt index 623ccbed07..5683c8c31f 100644 --- a/ext/gmp/tests/gmp_nextprime.phpt +++ b/ext/gmp/tests/gmp_nextprime.phpt @@ -2,9 +2,6 @@ gmp_nextprime() --SKIPIF-- <?php if (!extension_loaded("gmp")) print "skip"; -if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip.. only for Non Windows Systems'); -} ?> --FILE-- <?php diff --git a/ext/intl/CREDITS b/ext/intl/CREDITS index 0e7fd55dc1..0e7fd55dc1 100755..100644 --- a/ext/intl/CREDITS +++ b/ext/intl/CREDITS diff --git a/ext/intl/TODO b/ext/intl/TODO index 6fd1b27814..6fd1b27814 100755..100644 --- a/ext/intl/TODO +++ b/ext/intl/TODO diff --git a/ext/intl/collator/collator.c b/ext/intl/collator/collator.c index 047a738028..047a738028 100755..100644 --- a/ext/intl/collator/collator.c +++ b/ext/intl/collator/collator.c diff --git a/ext/intl/collator/collator.h b/ext/intl/collator/collator.h index 96e7aa097b..96e7aa097b 100755..100644 --- a/ext/intl/collator/collator.h +++ b/ext/intl/collator/collator.h diff --git a/ext/intl/collator/collator_attr.c b/ext/intl/collator/collator_attr.c index 684e72cc58..684e72cc58 100755..100644 --- a/ext/intl/collator/collator_attr.c +++ b/ext/intl/collator/collator_attr.c diff --git a/ext/intl/collator/collator_attr.h b/ext/intl/collator/collator_attr.h index 85636cc486..85636cc486 100755..100644 --- a/ext/intl/collator/collator_attr.h +++ b/ext/intl/collator/collator_attr.h diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c index d1fa10ef2c..d1fa10ef2c 100755..100644 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.c diff --git a/ext/intl/collator/collator_class.h b/ext/intl/collator/collator_class.h index 835abd66c8..7a56dfce50 100755..100644 --- a/ext/intl/collator/collator_class.h +++ b/ext/intl/collator/collator_class.h @@ -20,8 +20,9 @@ #include <php.h> -#include "intl_common.h" -#include "intl_error.h" +#include "../intl_common.h" +#include "../intl_error.h" +#include "../intl_data.h" #include <unicode/ucol.h> @@ -54,9 +55,7 @@ extern zend_class_entry *Collator_ce_ptr; Collator_object* co = NULL; \ intl_error_reset( NULL TSRMLS_CC ); \ -#define COLLATOR_METHOD_FETCH_OBJECT \ - co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC ); \ - intl_error_reset( COLLATOR_ERROR_P( co ) TSRMLS_CC ); \ +#define COLLATOR_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(Collator, co) // Macro to check return value of a ucol_* function call. #define COLLATOR_CHECK_STATUS( co, msg ) \ diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c index 4384558ac6..4384558ac6 100755..100644 --- a/ext/intl/collator/collator_compare.c +++ b/ext/intl/collator/collator_compare.c diff --git a/ext/intl/collator/collator_compare.h b/ext/intl/collator/collator_compare.h index 4e38b79309..4e38b79309 100755..100644 --- a/ext/intl/collator/collator_compare.h +++ b/ext/intl/collator/collator_compare.h diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c index e989d4c65a..e989d4c65a 100755..100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.c diff --git a/ext/intl/collator/collator_convert.h b/ext/intl/collator/collator_convert.h index 8322ea998b..8322ea998b 100755..100644 --- a/ext/intl/collator/collator_convert.h +++ b/ext/intl/collator/collator_convert.h diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c index 0f0cc193e4..b2a9968af4 100755..100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.c @@ -45,7 +45,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS) } INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); - co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC ); + COLLATOR_METHOD_FETCH_OBJECT; if(locale_len == 0) { locale = INTL_G(default_locale); diff --git a/ext/intl/collator/collator_create.h b/ext/intl/collator/collator_create.h index b740e82d68..b740e82d68 100755..100644 --- a/ext/intl/collator/collator_create.h +++ b/ext/intl/collator/collator_create.h diff --git a/ext/intl/collator/collator_error.c b/ext/intl/collator/collator_error.c index c4e41250a2..c4e41250a2 100755..100644 --- a/ext/intl/collator/collator_error.c +++ b/ext/intl/collator/collator_error.c diff --git a/ext/intl/collator/collator_error.h b/ext/intl/collator/collator_error.h index b2f44ea2a3..b2f44ea2a3 100755..100644 --- a/ext/intl/collator/collator_error.h +++ b/ext/intl/collator/collator_error.h diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.c index a8abfac12b..a8abfac12b 100755..100644 --- a/ext/intl/collator/collator_is_numeric.c +++ b/ext/intl/collator/collator_is_numeric.c diff --git a/ext/intl/collator/collator_is_numeric.h b/ext/intl/collator/collator_is_numeric.h index 585d58917a..585d58917a 100755..100644 --- a/ext/intl/collator/collator_is_numeric.h +++ b/ext/intl/collator/collator_is_numeric.h diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c index b30b021ee8..b30b021ee8 100755..100644 --- a/ext/intl/collator/collator_locale.c +++ b/ext/intl/collator/collator_locale.c diff --git a/ext/intl/collator/collator_locale.h b/ext/intl/collator/collator_locale.h index bda90cd3b9..bda90cd3b9 100755..100644 --- a/ext/intl/collator/collator_locale.h +++ b/ext/intl/collator/collator_locale.h diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index 0785111c96..0785111c96 100755..100644 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c diff --git a/ext/intl/collator/collator_sort.h b/ext/intl/collator/collator_sort.h index a990cdf089..a990cdf089 100755..100644 --- a/ext/intl/collator/collator_sort.h +++ b/ext/intl/collator/collator_sort.h diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.c index a0ee7c145f..a0ee7c145f 100755..100644 --- a/ext/intl/common/common_error.c +++ b/ext/intl/common/common_error.c diff --git a/ext/intl/common/common_error.h b/ext/intl/common/common_error.h index 8716222124..8716222124 100755..100644 --- a/ext/intl/common/common_error.h +++ b/ext/intl/common/common_error.h diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index 0477c7f59d..0477c7f59d 100755..100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index 437fedb7d3..437fedb7d3 100755..100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c index b399a39fcb..8aded18bd6 100755..100644 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.c @@ -108,7 +108,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) goto error; } - DATE_FORMAT_METHOD_FETCH_OBJECT; + DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; if (DATE_FORMAT_OBJECT(dfo) != NULL) { intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/intl/dateformat/dateformat.h b/ext/intl/dateformat/dateformat.h index f11918b79f..f11918b79f 100755..100644 --- a/ext/intl/dateformat/dateformat.h +++ b/ext/intl/dateformat/dateformat.h diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c index 6131cedc95..b8c5f25e3a 100755..100644 --- a/ext/intl/dateformat/dateformat_attr.c +++ b/ext/intl/dateformat/dateformat_attr.c @@ -17,8 +17,9 @@ #include "config.h" #endif -#include "php_intl.h" -#include "intl_convert.h" +#include "../php_intl.h" +#include "dateformat_class.h" +#include "../intl_convert.h" #include "dateformat_class.h" #include "dateformat_attr.h" diff --git a/ext/intl/dateformat/dateformat_attr.h b/ext/intl/dateformat/dateformat_attr.h index bf28824d63..bf28824d63 100755..100644 --- a/ext/intl/dateformat/dateformat_attr.h +++ b/ext/intl/dateformat/dateformat_attr.h diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index a9e06c147d..801ca3379e 100755..100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -23,6 +23,8 @@ #include "dateformat.h" #include "dateformat_attr.h" +#include <zend_exceptions.h> + zend_class_entry *IntlDateFormatter_ce_ptr = NULL; static zend_object_handlers IntlDateFormatter_handlers; @@ -88,18 +90,23 @@ zend_object_value IntlDateFormatter_object_clone(zval *object TSRMLS_DC) zend_object_handle handle = Z_OBJ_HANDLE_P(object); IntlDateFormatter_object *dfo, *new_dfo; - DATE_FORMAT_METHOD_FETCH_OBJECT; + DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; + new_obj_val = IntlDateFormatter_ce_ptr->create_object(IntlDateFormatter_ce_ptr TSRMLS_CC); new_dfo = (IntlDateFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_dfo->zo, new_obj_val, &dfo->zo, handle TSRMLS_CC); /* clone formatter object */ - DATE_FORMAT_OBJECT(new_dfo) = udat_clone(DATE_FORMAT_OBJECT(dfo), &INTL_DATA_ERROR_CODE(new_dfo)); - if(U_FAILURE(INTL_DATA_ERROR_CODE(new_dfo))) { - /* set up error in case error handler is interested */ - intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_dfo), "Failed to clone IntlDateFormatter object", 0 TSRMLS_CC ); - IntlDateFormatter_object_dtor(new_dfo, new_obj_val.handle TSRMLS_CC); /* free new object */ - zend_error(E_ERROR, "Failed to clone IntlDateFormatter object"); + if (dfo->datef_data.udatf != NULL) { + DATE_FORMAT_OBJECT(new_dfo) = udat_clone(DATE_FORMAT_OBJECT(dfo), &INTL_DATA_ERROR_CODE(dfo)); + if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + /* set up error in case error handler is interested */ + intl_errors_set(INTL_DATA_ERROR_P(dfo), INTL_DATA_ERROR_CODE(dfo), + "Failed to clone IntlDateFormatter object", 0 TSRMLS_CC ); + zend_throw_exception(NULL, "Failed to clone IntlDateFormatter object", 0 TSRMLS_CC); + } + } else { + zend_throw_exception(NULL, "Cannot clone unconstructed IntlDateFormatter", 0 TSRMLS_CC); } return new_obj_val; } diff --git a/ext/intl/dateformat/dateformat_class.h b/ext/intl/dateformat/dateformat_class.h index 9ad83ee3d6..d58abe42f5 100755..100644 --- a/ext/intl/dateformat/dateformat_class.h +++ b/ext/intl/dateformat/dateformat_class.h @@ -38,7 +38,15 @@ extern zend_class_entry *IntlDateFormatter_ce_ptr; /* Auxiliary macros */ #define DATE_FORMAT_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlDateFormatter, dfo) -#define DATE_FORMAT_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(IntlDateFormatter, dfo) +#define DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(IntlDateFormatter, dfo) +#define DATE_FORMAT_METHOD_FETCH_OBJECT \ + DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (dfo->datef_data.udatf == NULL) \ + { \ + intl_errors_set(&dfo->datef_data.error, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlDateFormatter", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + #define DATE_FORMAT_OBJECT(dfo) (dfo)->datef_data.udatf #endif // #ifndef DATE_FORMAT_CLASS_H diff --git a/ext/intl/dateformat/dateformat_data.c b/ext/intl/dateformat/dateformat_data.c index 33451e1c51..33451e1c51 100755..100644 --- a/ext/intl/dateformat/dateformat_data.c +++ b/ext/intl/dateformat/dateformat_data.c diff --git a/ext/intl/dateformat/dateformat_data.h b/ext/intl/dateformat/dateformat_data.h index cde9e363c9..cde9e363c9 100755..100644 --- a/ext/intl/dateformat/dateformat_data.h +++ b/ext/intl/dateformat/dateformat_data.h diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c index 4d03d924c8..4d03d924c8 100755..100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.c diff --git a/ext/intl/dateformat/dateformat_format.h b/ext/intl/dateformat/dateformat_format.h index 49f34c6892..49f34c6892 100755..100644 --- a/ext/intl/dateformat/dateformat_format.h +++ b/ext/intl/dateformat/dateformat_format.h diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c index 4193e89017..4193e89017 100755..100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.c diff --git a/ext/intl/dateformat/dateformat_parse.h b/ext/intl/dateformat/dateformat_parse.h index c74a3d5f15..c74a3d5f15 100755..100644 --- a/ext/intl/dateformat/dateformat_parse.h +++ b/ext/intl/dateformat/dateformat_parse.h diff --git a/ext/intl/doc/Tutorial.txt b/ext/intl/doc/Tutorial.txt index 4a66dc1844..4a66dc1844 100755..100644 --- a/ext/intl/doc/Tutorial.txt +++ b/ext/intl/doc/Tutorial.txt diff --git a/ext/intl/doc/collator_api.php b/ext/intl/doc/collator_api.php index ef7250243b..ef7250243b 100755..100644 --- a/ext/intl/doc/collator_api.php +++ b/ext/intl/doc/collator_api.php diff --git a/ext/intl/doc/common_api.php b/ext/intl/doc/common_api.php index 993dab180b..993dab180b 100755..100644 --- a/ext/intl/doc/common_api.php +++ b/ext/intl/doc/common_api.php diff --git a/ext/intl/doc/datefmt_api.php b/ext/intl/doc/datefmt_api.php index 272abdb57c..272abdb57c 100755..100644 --- a/ext/intl/doc/datefmt_api.php +++ b/ext/intl/doc/datefmt_api.php diff --git a/ext/intl/doc/formatter_api.php b/ext/intl/doc/formatter_api.php index 14d98db66a..14d98db66a 100755..100644 --- a/ext/intl/doc/formatter_api.php +++ b/ext/intl/doc/formatter_api.php diff --git a/ext/intl/doc/grapheme_api.php b/ext/intl/doc/grapheme_api.php index 465453fd32..465453fd32 100755..100644 --- a/ext/intl/doc/grapheme_api.php +++ b/ext/intl/doc/grapheme_api.php diff --git a/ext/intl/doc/locale_api.php b/ext/intl/doc/locale_api.php index c6c41ede0a..c6c41ede0a 100755..100644 --- a/ext/intl/doc/locale_api.php +++ b/ext/intl/doc/locale_api.php diff --git a/ext/intl/doc/msgfmt_api.php b/ext/intl/doc/msgfmt_api.php index e4d047b979..e4d047b979 100755..100644 --- a/ext/intl/doc/msgfmt_api.php +++ b/ext/intl/doc/msgfmt_api.php diff --git a/ext/intl/doc/normalizer_api.php b/ext/intl/doc/normalizer_api.php index a9bb566e67..a9bb566e67 100755..100644 --- a/ext/intl/doc/normalizer_api.php +++ b/ext/intl/doc/normalizer_api.php diff --git a/ext/intl/formatter/formatter.c b/ext/intl/formatter/formatter.c index 1b7922ce03..1b7922ce03 100755..100644 --- a/ext/intl/formatter/formatter.c +++ b/ext/intl/formatter/formatter.c diff --git a/ext/intl/formatter/formatter.h b/ext/intl/formatter/formatter.h index 1f9ebead8e..1f9ebead8e 100755..100644 --- a/ext/intl/formatter/formatter.h +++ b/ext/intl/formatter/formatter.h diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c index 448a9db721..448a9db721 100755..100644 --- a/ext/intl/formatter/formatter_attr.c +++ b/ext/intl/formatter/formatter_attr.c diff --git a/ext/intl/formatter/formatter_attr.h b/ext/intl/formatter/formatter_attr.h index c4bc94ce5f..c4bc94ce5f 100755..100644 --- a/ext/intl/formatter/formatter_attr.h +++ b/ext/intl/formatter/formatter_attr.h diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index 28af14e5db..8f399a6773 100755..100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -24,6 +24,8 @@ #include "formatter_main.h" #include "formatter_attr.h" +#include <zend_exceptions.h> + zend_class_entry *NumberFormatter_ce_ptr = NULL; static zend_object_handlers NumberFormatter_handlers; @@ -83,18 +85,23 @@ zend_object_value NumberFormatter_object_clone(zval *object TSRMLS_DC) zend_object_handle handle = Z_OBJ_HANDLE_P(object); NumberFormatter_object *nfo, *new_nfo; - FORMATTER_METHOD_FETCH_OBJECT; + FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; new_obj_val = NumberFormatter_ce_ptr->create_object(NumberFormatter_ce_ptr TSRMLS_CC); new_nfo = (NumberFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_nfo->zo, new_obj_val, &nfo->zo, handle TSRMLS_CC); - /* clone formatter object */ - FORMATTER_OBJECT(new_nfo) = unum_clone(FORMATTER_OBJECT(nfo), &INTL_DATA_ERROR_CODE(new_nfo)); - if(U_FAILURE(INTL_DATA_ERROR_CODE(new_nfo))) { - /* set up error in case error handler is interested */ - intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_nfo), "Failed to clone NumberFormatter object", 0 TSRMLS_CC ); - NumberFormatter_object_dtor(new_nfo, new_obj_val.handle TSRMLS_CC); /* free new object */ - zend_error(E_ERROR, "Failed to clone NumberFormatter object"); + /* clone formatter object. It may fail, the destruction code must handle this case */ + if (FORMATTER_OBJECT(nfo) != NULL) { + FORMATTER_OBJECT(new_nfo) = unum_clone(FORMATTER_OBJECT(nfo), + &INTL_DATA_ERROR_CODE(nfo)); + if (U_FAILURE(INTL_DATA_ERROR_CODE(nfo))) { + /* set up error in case error handler is interested */ + intl_errors_set(INTL_DATA_ERROR_P(nfo), INTL_DATA_ERROR_CODE(nfo), + "Failed to clone NumberFormatter object", 0 TSRMLS_CC); + zend_throw_exception(NULL, "Failed to clone NumberFormatter object", 0 TSRMLS_CC); + } + } else { + zend_throw_exception(NULL, "Cannot clone unconstructed NumberFormatter", 0 TSRMLS_CC); } return new_obj_val; } diff --git a/ext/intl/formatter/formatter_class.h b/ext/intl/formatter/formatter_class.h index cf1cb060c6..9582866664 100755..100644 --- a/ext/intl/formatter/formatter_class.h +++ b/ext/intl/formatter/formatter_class.h @@ -34,8 +34,17 @@ extern zend_class_entry *NumberFormatter_ce_ptr; /* Auxiliary macros */ -#define FORMATTER_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(NumberFormatter, nfo) -#define FORMATTER_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(NumberFormatter, nfo) -#define FORMATTER_OBJECT(nfo) (nfo)->nf_data.unum +#define FORMATTER_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(NumberFormatter, nfo) +#define FORMATTER_OBJECT(nfo) (nfo)->nf_data.unum +#define FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(NumberFormatter, nfo) +#define FORMATTER_METHOD_FETCH_OBJECT \ + FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (FORMATTER_OBJECT(nfo) == NULL) \ + { \ + intl_errors_set(&nfo->nf_data.error, U_ILLEGAL_ARGUMENT_ERROR, \ + "Found unconstructed NumberFormatter", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + #endif // #ifndef FORMATTER_CLASS_H diff --git a/ext/intl/formatter/formatter_data.c b/ext/intl/formatter/formatter_data.c index 88f122f7c9..88f122f7c9 100755..100644 --- a/ext/intl/formatter/formatter_data.c +++ b/ext/intl/formatter/formatter_data.c diff --git a/ext/intl/formatter/formatter_data.h b/ext/intl/formatter/formatter_data.h index adc4818afc..adc4818afc 100755..100644 --- a/ext/intl/formatter/formatter_data.h +++ b/ext/intl/formatter/formatter_data.h diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index ce1c941e19..ce1c941e19 100755..100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c diff --git a/ext/intl/formatter/formatter_format.h b/ext/intl/formatter/formatter_format.h index 35fafd1ede..35fafd1ede 100755..100644 --- a/ext/intl/formatter/formatter_format.h +++ b/ext/intl/formatter/formatter_format.h diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 8fa17560b8..5cb6483326 100755..100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c @@ -47,7 +47,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); object = return_value; - FORMATTER_METHOD_FETCH_OBJECT; + FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { diff --git a/ext/intl/formatter/formatter_main.h b/ext/intl/formatter/formatter_main.h index 7669e684ae..7669e684ae 100755..100644 --- a/ext/intl/formatter/formatter_main.h +++ b/ext/intl/formatter/formatter_main.h diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index 6f3a3a12b5..6f3a3a12b5 100755..100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c diff --git a/ext/intl/formatter/formatter_parse.h b/ext/intl/formatter/formatter_parse.h index cb96c72b5d..cb96c72b5d 100755..100644 --- a/ext/intl/formatter/formatter_parse.h +++ b/ext/intl/formatter/formatter_parse.h diff --git a/ext/intl/grapheme/grapheme.h b/ext/intl/grapheme/grapheme.h index c0e697ac1e..c0e697ac1e 100755..100644 --- a/ext/intl/grapheme/grapheme.h +++ b/ext/intl/grapheme/grapheme.h diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index 475bbe4184..475bbe4184 100755..100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c index 92008554d4..92008554d4 100755..100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.c diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h index c91aeaff7d..c91aeaff7d 100755..100644 --- a/ext/intl/grapheme/grapheme_util.h +++ b/ext/intl/grapheme/grapheme_util.h diff --git a/ext/intl/intl_common.h b/ext/intl/intl_common.h index 9424571d02..9424571d02 100755..100644 --- a/ext/intl/intl_common.h +++ b/ext/intl/intl_common.h diff --git a/ext/intl/intl_convert.c b/ext/intl/intl_convert.c index 92cdc4cef4..92cdc4cef4 100755..100644 --- a/ext/intl/intl_convert.c +++ b/ext/intl/intl_convert.c diff --git a/ext/intl/intl_convert.h b/ext/intl/intl_convert.h index 3fc03f4bb7..3fc03f4bb7 100755..100644 --- a/ext/intl/intl_convert.h +++ b/ext/intl/intl_convert.h diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h index 66ca27ae79..66ca27ae79 100755..100644 --- a/ext/intl/intl_data.h +++ b/ext/intl/intl_data.h diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 9c2e13dfd5..9c2e13dfd5 100755..100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 3adae85474..3adae85474 100755..100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h diff --git a/ext/intl/locale/locale.c b/ext/intl/locale/locale.c index ffc463f399..ffc463f399 100755..100644 --- a/ext/intl/locale/locale.c +++ b/ext/intl/locale/locale.c diff --git a/ext/intl/locale/locale.h b/ext/intl/locale/locale.h index f3859c7a2a..f3859c7a2a 100755..100644 --- a/ext/intl/locale/locale.h +++ b/ext/intl/locale/locale.h diff --git a/ext/intl/locale/locale_class.c b/ext/intl/locale/locale_class.c index 432cfb28fc..432cfb28fc 100755..100644 --- a/ext/intl/locale/locale_class.c +++ b/ext/intl/locale/locale_class.c diff --git a/ext/intl/locale/locale_class.h b/ext/intl/locale/locale_class.h index cbddccbe17..cbddccbe17 100755..100644 --- a/ext/intl/locale/locale_class.h +++ b/ext/intl/locale/locale_class.h diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 1707c69f93..1707c69f93 100755..100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c diff --git a/ext/intl/locale/locale_methods.h b/ext/intl/locale/locale_methods.h index e88fac64b7..e88fac64b7 100755..100644 --- a/ext/intl/locale/locale_methods.h +++ b/ext/intl/locale/locale_methods.h diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index 0a01204fae..e3fb9425a9 100755..100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -49,7 +49,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) } INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); - MSG_FORMAT_METHOD_FETCH_OBJECT; + MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { diff --git a/ext/intl/msgformat/msgformat.h b/ext/intl/msgformat/msgformat.h index 205c7066fd..205c7066fd 100755..100644 --- a/ext/intl/msgformat/msgformat.h +++ b/ext/intl/msgformat/msgformat.h diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index ed2dae27d1..ed2dae27d1 100755..100644 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c diff --git a/ext/intl/msgformat/msgformat_attr.h b/ext/intl/msgformat/msgformat_attr.h index 898c4451e1..898c4451e1 100755..100644 --- a/ext/intl/msgformat/msgformat_attr.h +++ b/ext/intl/msgformat/msgformat_attr.h diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index 8145a46f17..da1e1e595a 100755..100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -24,6 +24,8 @@ #include "msgformat.h" #include "msgformat_attr.h" +#include <zend_exceptions.h> + zend_class_entry *MessageFormatter_ce_ptr = NULL; static zend_object_handlers MessageFormatter_handlers; @@ -81,18 +83,24 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC) zend_object_handle handle = Z_OBJ_HANDLE_P(object); MessageFormatter_object *mfo, *new_mfo; - MSG_FORMAT_METHOD_FETCH_OBJECT; + MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC); new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC); + /* clone formatter object */ - MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &INTL_DATA_ERROR_CODE(new_mfo)); - if(U_FAILURE(INTL_DATA_ERROR_CODE(new_mfo))) { - /* set up error in case error handler is interested */ - intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC ); - MessageFormatter_object_dtor(new_mfo, new_obj_val.handle TSRMLS_CC); /* free new object */ - zend_error(E_ERROR, "Failed to clone MessageFormatter object"); + if (MSG_FORMAT_OBJECT(mfo) != NULL) { + MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), + &INTL_DATA_ERROR_CODE(mfo)); + + if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) { + intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo), + "Failed to clone MessageFormatter object", 0 TSRMLS_CC); + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to clone MessageFormatter object"); + } + } else { + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Cannot clone unconstructed MessageFormatter"); } return new_obj_val; } diff --git a/ext/intl/msgformat/msgformat_class.h b/ext/intl/msgformat/msgformat_class.h index b6b8e33226..337e04e647 100755..100644 --- a/ext/intl/msgformat/msgformat_class.h +++ b/ext/intl/msgformat/msgformat_class.h @@ -37,7 +37,15 @@ extern zend_class_entry *MessageFormatter_ce_ptr; /* Auxiliary macros */ #define MSG_FORMAT_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(MessageFormatter, mfo) -#define MSG_FORMAT_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo) +#define MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo) +#define MSG_FORMAT_METHOD_FETCH_OBJECT \ + MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (MSG_FORMAT_OBJECT(mfo) == NULL) { \ + intl_errors_set(&mfo->mf_data.error, U_ILLEGAL_ARGUMENT_ERROR, \ + "Found unconstructed MessageFormatter", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + #define MSG_FORMAT_OBJECT(mfo) (mfo)->mf_data.umsgf #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM < 48 diff --git a/ext/intl/msgformat/msgformat_data.c b/ext/intl/msgformat/msgformat_data.c index 527c1d4d17..527c1d4d17 100755..100644 --- a/ext/intl/msgformat/msgformat_data.c +++ b/ext/intl/msgformat/msgformat_data.c diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h index 6479888f8f..6479888f8f 100755..100644 --- a/ext/intl/msgformat/msgformat_data.h +++ b/ext/intl/msgformat/msgformat_data.h diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index 9a18ac0a70..9a18ac0a70 100755..100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c diff --git a/ext/intl/msgformat/msgformat_format.h b/ext/intl/msgformat/msgformat_format.h index b74deab8ff..b74deab8ff 100755..100644 --- a/ext/intl/msgformat/msgformat_format.h +++ b/ext/intl/msgformat/msgformat_format.h diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index 1895de2c86..1895de2c86 100755..100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp diff --git a/ext/intl/msgformat/msgformat_helpers.h b/ext/intl/msgformat/msgformat_helpers.h index 30c7e3930f..30c7e3930f 100755..100644 --- a/ext/intl/msgformat/msgformat_helpers.h +++ b/ext/intl/msgformat/msgformat_helpers.h diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index f540b1d0c4..f540b1d0c4 100755..100644 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c diff --git a/ext/intl/msgformat/msgformat_parse.h b/ext/intl/msgformat/msgformat_parse.h index a937235839..a937235839 100755..100644 --- a/ext/intl/msgformat/msgformat_parse.h +++ b/ext/intl/msgformat/msgformat_parse.h diff --git a/ext/intl/normalizer/normalizer.c b/ext/intl/normalizer/normalizer.c index 033b05cd32..033b05cd32 100755..100644 --- a/ext/intl/normalizer/normalizer.c +++ b/ext/intl/normalizer/normalizer.c diff --git a/ext/intl/normalizer/normalizer.h b/ext/intl/normalizer/normalizer.h index eca9abe05a..eca9abe05a 100755..100644 --- a/ext/intl/normalizer/normalizer.h +++ b/ext/intl/normalizer/normalizer.h diff --git a/ext/intl/normalizer/normalizer_class.c b/ext/intl/normalizer/normalizer_class.c index 154d877e3f..154d877e3f 100755..100644 --- a/ext/intl/normalizer/normalizer_class.c +++ b/ext/intl/normalizer/normalizer_class.c diff --git a/ext/intl/normalizer/normalizer_class.h b/ext/intl/normalizer/normalizer_class.h index 4d3f7d2341..4d3f7d2341 100755..100644 --- a/ext/intl/normalizer/normalizer_class.h +++ b/ext/intl/normalizer/normalizer_class.h diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index f46285e9d9..f46285e9d9 100755..100644 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c diff --git a/ext/intl/normalizer/normalizer_normalize.h b/ext/intl/normalizer/normalizer_normalize.h index 41c31f7949..41c31f7949 100755..100644 --- a/ext/intl/normalizer/normalizer_normalize.h +++ b/ext/intl/normalizer/normalizer_normalize.h diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index efe0ddd242..efe0ddd242 100755..100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h index 4ede069e2a..4ede069e2a 100755..100644 --- a/ext/intl/php_intl.h +++ b/ext/intl/php_intl.h diff --git a/ext/intl/resourcebundle/TODO b/ext/intl/resourcebundle/TODO index ace4ceb253..ace4ceb253 100755..100644 --- a/ext/intl/resourcebundle/TODO +++ b/ext/intl/resourcebundle/TODO diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 23e9449a38..a6a73f5f04 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -261,7 +261,14 @@ PHP_FUNCTION( resourcebundle_get ) /* {{{ resourcebundle_array_count */ int resourcebundle_array_count(zval *object, long *count TSRMLS_DC) { - ResourceBundle_object *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC); + ResourceBundle_object *rb; + RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK; + + if (rb->me == NULL) { + intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR, + "Found unconstructed ResourceBundle", 0 TSRMLS_CC); + return 0; + } *count = ures_getSize( rb->me ); diff --git a/ext/intl/resourcebundle/resourcebundle_class.h b/ext/intl/resourcebundle/resourcebundle_class.h index 4755d723b8..8da3ed9d47 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.h +++ b/ext/intl/resourcebundle/resourcebundle_class.h @@ -33,7 +33,16 @@ typedef struct { } ResourceBundle_object; #define RESOURCEBUNDLE_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(ResourceBundle, rb) -#define RESOURCEBUNDLE_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(ResourceBundle, rb) +#define RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(ResourceBundle, rb) +#define RESOURCEBUNDLE_METHOD_FETCH_OBJECT \ + INTL_METHOD_FETCH_OBJECT(ResourceBundle, rb); \ + if (RESOURCEBUNDLE_OBJECT(rb) == NULL) { \ + intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR, \ + "Found unconstructed ResourceBundle", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + + #define RESOURCEBUNDLE_OBJECT(rb) (rb)->me void resourcebundle_register_class( TSRMLS_D ); diff --git a/ext/intl/spoofchecker/spoofchecker.c b/ext/intl/spoofchecker/spoofchecker.c index 42a014a90e..42a014a90e 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker.c +++ b/ext/intl/spoofchecker/spoofchecker.c diff --git a/ext/intl/spoofchecker/spoofchecker.h b/ext/intl/spoofchecker/spoofchecker.h index f976d639ac..f976d639ac 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker.h +++ b/ext/intl/spoofchecker/spoofchecker.h diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index 507a2ca98e..507a2ca98e 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c diff --git a/ext/intl/spoofchecker/spoofchecker_class.h b/ext/intl/spoofchecker/spoofchecker_class.h index 8db64680ef..ec043d9dc8 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_class.h +++ b/ext/intl/spoofchecker/spoofchecker_class.h @@ -22,6 +22,7 @@ #include "intl_common.h" #include "spoofchecker_create.h" #include "intl_error.h" +#include "intl_data.h" #include <unicode/uspoof.h> @@ -55,9 +56,14 @@ extern zend_class_entry *Spoofchecker_ce_ptr; Spoofchecker_object* co = NULL; \ intl_error_reset(NULL TSRMLS_CC); \ -#define SPOOFCHECKER_METHOD_FETCH_OBJECT \ - co = (Spoofchecker_object *) zend_object_store_get_object(object TSRMLS_CC); \ - intl_error_reset(SPOOFCHECKER_ERROR_P(co) TSRMLS_CC); \ +#define SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(Spoofchecker, co) +#define SPOOFCHECKER_METHOD_FETCH_OBJECT \ + SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (co->uspoof == NULL) { \ + intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, \ + "Found unconstructed Spoofchecker", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } // Macro to check return value of a ucol_* function call. #define SPOOFCHECKER_CHECK_STATUS(co, msg) \ diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.c index 3659551ede..cf0173f997 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_create.c +++ b/ext/intl/spoofchecker/spoofchecker_create.c @@ -35,7 +35,7 @@ PHP_METHOD(Spoofchecker, __construct) return; } - SPOOFCHECKER_METHOD_FETCH_OBJECT; + SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK; co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co)); INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker"); diff --git a/ext/intl/spoofchecker/spoofchecker_create.h b/ext/intl/spoofchecker/spoofchecker_create.h index 313faab8a3..313faab8a3 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_create.h +++ b/ext/intl/spoofchecker/spoofchecker_create.h diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c index c37b9186a2..c37b9186a2 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_main.c +++ b/ext/intl/spoofchecker/spoofchecker_main.c diff --git a/ext/intl/spoofchecker/spoofchecker_main.h b/ext/intl/spoofchecker/spoofchecker_main.h index fb920d7841..fb920d7841 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_main.h +++ b/ext/intl/spoofchecker/spoofchecker_main.h diff --git a/ext/intl/tests/_files/es-bundle.txt b/ext/intl/tests/_files/es-bundle.txt index 46399a7717..46399a7717 100755..100644 --- a/ext/intl/tests/_files/es-bundle.txt +++ b/ext/intl/tests/_files/es-bundle.txt diff --git a/ext/intl/tests/_files/res_index.txt b/ext/intl/tests/_files/res_index.txt index a39bea58e5..a39bea58e5 100755..100644 --- a/ext/intl/tests/_files/res_index.txt +++ b/ext/intl/tests/_files/res_index.txt diff --git a/ext/intl/tests/_files/resourcebundle.txt b/ext/intl/tests/_files/resourcebundle.txt index 5b081da6cc..5b081da6cc 100755..100644 --- a/ext/intl/tests/_files/resourcebundle.txt +++ b/ext/intl/tests/_files/resourcebundle.txt diff --git a/ext/intl/tests/_files/resourcebundle/es.res b/ext/intl/tests/_files/resourcebundle/es.res Binary files differindex f9d891d6ba..f9d891d6ba 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/es.res +++ b/ext/intl/tests/_files/resourcebundle/es.res diff --git a/ext/intl/tests/_files/resourcebundle/res_index.res b/ext/intl/tests/_files/resourcebundle/res_index.res Binary files differindex 9dd3df2de3..9dd3df2de3 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/res_index.res +++ b/ext/intl/tests/_files/resourcebundle/res_index.res diff --git a/ext/intl/tests/_files/resourcebundle/root.res b/ext/intl/tests/_files/resourcebundle/root.res Binary files differindex 62cb48c457..62cb48c457 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/root.res +++ b/ext/intl/tests/_files/resourcebundle/root.res diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt index 9232bbf0c1..9232bbf0c1 100755..100644 --- a/ext/intl/tests/badargs.phpt +++ b/ext/intl/tests/badargs.phpt diff --git a/ext/intl/tests/bug12887.phpt b/ext/intl/tests/bug12887.phpt index e2fc194944..e2fc194944 100755..100644 --- a/ext/intl/tests/bug12887.phpt +++ b/ext/intl/tests/bug12887.phpt diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt index 3256268405..3256268405 100755..100644 --- a/ext/intl/tests/bug14562.phpt +++ b/ext/intl/tests/bug14562.phpt diff --git a/ext/intl/tests/bug59597_64.phpt b/ext/intl/tests/bug59597_64.phpt index f96c72da54..eb70995a25 100644 --- a/ext/intl/tests/bug59597_64.phpt +++ b/ext/intl/tests/bug59597_64.phpt @@ -18,4 +18,3 @@ var_dump($value); --EXPECT-- int(2147483647) int(2147483650) - diff --git a/ext/intl/tests/bug62070.phpt b/ext/intl/tests/bug62070.phpt index a466b05c24..3ab0078d70 100644 --- a/ext/intl/tests/bug62070.phpt +++ b/ext/intl/tests/bug62070.phpt @@ -4,6 +4,8 @@ Bug #62070: Collator::getSortKey() returns garbage <?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip ICU >= 49 only'); --FILE-- <?php $s1 = 'Hello'; diff --git a/ext/intl/tests/collation_customization.phpt b/ext/intl/tests/collation_customization.phpt index e380380639..e380380639 100755..100644 --- a/ext/intl/tests/collation_customization.phpt +++ b/ext/intl/tests/collation_customization.phpt diff --git a/ext/intl/tests/collator_asort.phpt b/ext/intl/tests/collator_asort.phpt index a614ddc3f8..a614ddc3f8 100755..100644 --- a/ext/intl/tests/collator_asort.phpt +++ b/ext/intl/tests/collator_asort.phpt diff --git a/ext/intl/tests/collator_compare.phpt b/ext/intl/tests/collator_compare.phpt index f10b5708f4..f10b5708f4 100755..100644 --- a/ext/intl/tests/collator_compare.phpt +++ b/ext/intl/tests/collator_compare.phpt diff --git a/ext/intl/tests/collator_create.phpt b/ext/intl/tests/collator_create.phpt index eed8cf1b23..eed8cf1b23 100755..100644 --- a/ext/intl/tests/collator_create.phpt +++ b/ext/intl/tests/collator_create.phpt diff --git a/ext/intl/tests/collator_get_error_code.phpt b/ext/intl/tests/collator_get_error_code.phpt index 45a8e710f4..45a8e710f4 100755..100644 --- a/ext/intl/tests/collator_get_error_code.phpt +++ b/ext/intl/tests/collator_get_error_code.phpt diff --git a/ext/intl/tests/collator_get_error_message.phpt b/ext/intl/tests/collator_get_error_message.phpt index af4b9c3821..af4b9c3821 100755..100644 --- a/ext/intl/tests/collator_get_error_message.phpt +++ b/ext/intl/tests/collator_get_error_message.phpt diff --git a/ext/intl/tests/collator_get_locale.phpt b/ext/intl/tests/collator_get_locale.phpt index 68440f3ee7..68440f3ee7 100755..100644 --- a/ext/intl/tests/collator_get_locale.phpt +++ b/ext/intl/tests/collator_get_locale.phpt diff --git a/ext/intl/tests/collator_get_set_attribute.phpt b/ext/intl/tests/collator_get_set_attribute.phpt index b234790f81..b234790f81 100755..100644 --- a/ext/intl/tests/collator_get_set_attribute.phpt +++ b/ext/intl/tests/collator_get_set_attribute.phpt diff --git a/ext/intl/tests/collator_get_set_strength.phpt b/ext/intl/tests/collator_get_set_strength.phpt index 1f779441fa..1f779441fa 100755..100644 --- a/ext/intl/tests/collator_get_set_strength.phpt +++ b/ext/intl/tests/collator_get_set_strength.phpt diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt index a9c4d71348..a9c4d71348 100755..100644 --- a/ext/intl/tests/collator_get_sort_key.phpt +++ b/ext/intl/tests/collator_get_sort_key.phpt diff --git a/ext/intl/tests/collator_sort.phpt b/ext/intl/tests/collator_sort.phpt index 5cefe2fd7c..5cefe2fd7c 100755..100644 --- a/ext/intl/tests/collator_sort.phpt +++ b/ext/intl/tests/collator_sort.phpt diff --git a/ext/intl/tests/collator_sort_with_sort_keys.phpt b/ext/intl/tests/collator_sort_with_sort_keys.phpt index 2f489d745c..2f489d745c 100755..100644 --- a/ext/intl/tests/collator_sort_with_sort_keys.phpt +++ b/ext/intl/tests/collator_sort_with_sort_keys.phpt diff --git a/ext/intl/tests/dateformat_clone_bad_obj.phpt b/ext/intl/tests/dateformat_clone_bad_obj.phpt new file mode 100644 index 0000000000..5e12b96ae8 --- /dev/null +++ b/ext/intl/tests/dateformat_clone_bad_obj.phpt @@ -0,0 +1,20 @@ +--TEST-- +Cloning unconstructed IntlDateFormatter +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +class A extends IntlDateFormatter { + function __construct() {} +} + +$a = new A; +try { + $b = clone $a; +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +--EXPECTF-- +string(%s) "Cannot clone unconstructed IntlDateFormatter" diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index e5548196d1..e5548196d1 100755..100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt index bd41d715b9..bd41d715b9 100755..100644 --- a/ext/intl/tests/dateformat_format_parse.phpt +++ b/ext/intl/tests/dateformat_format_parse.phpt diff --git a/ext/intl/tests/dateformat_get_datetype.phpt b/ext/intl/tests/dateformat_get_datetype.phpt index 24d03898ea..24d03898ea 100755..100644 --- a/ext/intl/tests/dateformat_get_datetype.phpt +++ b/ext/intl/tests/dateformat_get_datetype.phpt diff --git a/ext/intl/tests/dateformat_get_locale.phpt b/ext/intl/tests/dateformat_get_locale.phpt index 17fcca3551..17fcca3551 100755..100644 --- a/ext/intl/tests/dateformat_get_locale.phpt +++ b/ext/intl/tests/dateformat_get_locale.phpt diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt index bfd4e578e1..bfd4e578e1 100755..100644 --- a/ext/intl/tests/dateformat_get_set_calendar.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar.phpt diff --git a/ext/intl/tests/dateformat_get_set_pattern.phpt b/ext/intl/tests/dateformat_get_set_pattern.phpt index bd541c1c93..bd541c1c93 100755..100644 --- a/ext/intl/tests/dateformat_get_set_pattern.phpt +++ b/ext/intl/tests/dateformat_get_set_pattern.phpt diff --git a/ext/intl/tests/dateformat_get_timetype.phpt b/ext/intl/tests/dateformat_get_timetype.phpt index 2ddc1172b1..2ddc1172b1 100755..100644 --- a/ext/intl/tests/dateformat_get_timetype.phpt +++ b/ext/intl/tests/dateformat_get_timetype.phpt diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index 80cbdbbf0f..80cbdbbf0f 100755..100644 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt diff --git a/ext/intl/tests/dateformat_is_set_lenient.phpt b/ext/intl/tests/dateformat_is_set_lenient.phpt index 8492a2e2a8..8492a2e2a8 100755..100644 --- a/ext/intl/tests/dateformat_is_set_lenient.phpt +++ b/ext/intl/tests/dateformat_is_set_lenient.phpt diff --git a/ext/intl/tests/dateformat_localtime.phpt b/ext/intl/tests/dateformat_localtime.phpt index 79f297db74..79f297db74 100755..100644 --- a/ext/intl/tests/dateformat_localtime.phpt +++ b/ext/intl/tests/dateformat_localtime.phpt diff --git a/ext/intl/tests/dateformat_parse.phpt b/ext/intl/tests/dateformat_parse.phpt index ff59773488..ff59773488 100755..100644 --- a/ext/intl/tests/dateformat_parse.phpt +++ b/ext/intl/tests/dateformat_parse.phpt diff --git a/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt index 03f99f1d92..03f99f1d92 100755..100644 --- a/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt +++ b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt diff --git a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt index 0f26643163..0f26643163 100755..100644 --- a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt +++ b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt diff --git a/ext/intl/tests/dateformat_set_timezone_id.phpt b/ext/intl/tests/dateformat_set_timezone_id.phpt index 72a9230bdf..72a9230bdf 100755..100644 --- a/ext/intl/tests/dateformat_set_timezone_id.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id.phpt diff --git a/ext/intl/tests/formatter_clone_bad_obj.phpt b/ext/intl/tests/formatter_clone_bad_obj.phpt new file mode 100644 index 0000000000..ef7b28a546 --- /dev/null +++ b/ext/intl/tests/formatter_clone_bad_obj.phpt @@ -0,0 +1,20 @@ +--TEST-- +Cloning unconstructed numfmt +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +class A extends NumberFormatter { + function __construct() {} +} + +$a = new A; +try { + $b = clone $a; +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +--EXPECTF-- +string(42) "Cannot clone unconstructed NumberFormatter" diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 295f011008..295f011008 100755..100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt index 334ef49567..334ef49567 100755..100644 --- a/ext/intl/tests/formatter_format.phpt +++ b/ext/intl/tests/formatter_format.phpt diff --git a/ext/intl/tests/formatter_format_conv.phpt b/ext/intl/tests/formatter_format_conv.phpt index e1d25ef3d9..e1d25ef3d9 100755..100644 --- a/ext/intl/tests/formatter_format_conv.phpt +++ b/ext/intl/tests/formatter_format_conv.phpt diff --git a/ext/intl/tests/formatter_format_currency.phpt b/ext/intl/tests/formatter_format_currency.phpt index be219a5baa..be219a5baa 100755..100644 --- a/ext/intl/tests/formatter_format_currency.phpt +++ b/ext/intl/tests/formatter_format_currency.phpt diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt index acb683e894..acb683e894 100755..100644 --- a/ext/intl/tests/formatter_get_error.phpt +++ b/ext/intl/tests/formatter_get_error.phpt diff --git a/ext/intl/tests/formatter_get_locale.phpt b/ext/intl/tests/formatter_get_locale.phpt index 3d4fb2ae4e..3d4fb2ae4e 100755..100644 --- a/ext/intl/tests/formatter_get_locale.phpt +++ b/ext/intl/tests/formatter_get_locale.phpt diff --git a/ext/intl/tests/formatter_get_set_attribute.phpt b/ext/intl/tests/formatter_get_set_attribute.phpt index 51c7d3658a..51c7d3658a 100755..100644 --- a/ext/intl/tests/formatter_get_set_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_attribute.phpt diff --git a/ext/intl/tests/formatter_get_set_pattern.phpt b/ext/intl/tests/formatter_get_set_pattern.phpt index 0ae5b308b2..0ae5b308b2 100755..100644 --- a/ext/intl/tests/formatter_get_set_pattern.phpt +++ b/ext/intl/tests/formatter_get_set_pattern.phpt diff --git a/ext/intl/tests/formatter_get_set_symbol.phpt b/ext/intl/tests/formatter_get_set_symbol.phpt index 050e8cf9e1..050e8cf9e1 100755..100644 --- a/ext/intl/tests/formatter_get_set_symbol.phpt +++ b/ext/intl/tests/formatter_get_set_symbol.phpt diff --git a/ext/intl/tests/formatter_get_set_text_attribute.phpt b/ext/intl/tests/formatter_get_set_text_attribute.phpt index 539ff52322..539ff52322 100755..100644 --- a/ext/intl/tests/formatter_get_set_text_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_text_attribute.phpt diff --git a/ext/intl/tests/formatter_parse.phpt b/ext/intl/tests/formatter_parse.phpt index 2ab9cce3b6..2ab9cce3b6 100755..100644 --- a/ext/intl/tests/formatter_parse.phpt +++ b/ext/intl/tests/formatter_parse.phpt diff --git a/ext/intl/tests/formatter_parse_currency.phpt b/ext/intl/tests/formatter_parse_currency.phpt index 4ebd1a4174..4ebd1a4174 100755..100644 --- a/ext/intl/tests/formatter_parse_currency.phpt +++ b/ext/intl/tests/formatter_parse_currency.phpt diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index def9110d0d..def9110d0d 100755..100644 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt diff --git a/ext/intl/tests/idn.phpt b/ext/intl/tests/idn.phpt index fde822a560..fde822a560 100755..100644 --- a/ext/intl/tests/idn.phpt +++ b/ext/intl/tests/idn.phpt diff --git a/ext/intl/tests/intl_error_name.phpt b/ext/intl/tests/intl_error_name.phpt index 8f5b2dc198..8f5b2dc198 100755..100644 --- a/ext/intl/tests/intl_error_name.phpt +++ b/ext/intl/tests/intl_error_name.phpt diff --git a/ext/intl/tests/intl_get_error_code.phpt b/ext/intl/tests/intl_get_error_code.phpt index 6cd361ba71..6cd361ba71 100755..100644 --- a/ext/intl/tests/intl_get_error_code.phpt +++ b/ext/intl/tests/intl_get_error_code.phpt diff --git a/ext/intl/tests/intl_get_error_message.phpt b/ext/intl/tests/intl_get_error_message.phpt index f81b5c03d5..f81b5c03d5 100755..100644 --- a/ext/intl/tests/intl_get_error_message.phpt +++ b/ext/intl/tests/intl_get_error_message.phpt diff --git a/ext/intl/tests/intl_is_failure.phpt b/ext/intl/tests/intl_is_failure.phpt index e07df8f2c9..e07df8f2c9 100755..100644 --- a/ext/intl/tests/intl_is_failure.phpt +++ b/ext/intl/tests/intl_is_failure.phpt diff --git a/ext/intl/tests/locale_accept.phpt b/ext/intl/tests/locale_accept.phpt index cf1dc6e675..cf1dc6e675 100755..100644 --- a/ext/intl/tests/locale_accept.phpt +++ b/ext/intl/tests/locale_accept.phpt diff --git a/ext/intl/tests/locale_compose_locale.phpt b/ext/intl/tests/locale_compose_locale.phpt index 2d0ca54e74..2d0ca54e74 100755..100644 --- a/ext/intl/tests/locale_compose_locale.phpt +++ b/ext/intl/tests/locale_compose_locale.phpt diff --git a/ext/intl/tests/locale_filter_matches.phpt b/ext/intl/tests/locale_filter_matches.phpt index cada499b9a..cada499b9a 100755..100644 --- a/ext/intl/tests/locale_filter_matches.phpt +++ b/ext/intl/tests/locale_filter_matches.phpt diff --git a/ext/intl/tests/locale_get_all_variants.phpt b/ext/intl/tests/locale_get_all_variants.phpt index 864b8a2e1a..864b8a2e1a 100755..100644 --- a/ext/intl/tests/locale_get_all_variants.phpt +++ b/ext/intl/tests/locale_get_all_variants.phpt diff --git a/ext/intl/tests/locale_get_default.phpt b/ext/intl/tests/locale_get_default.phpt index 57c46ccd2b..57c46ccd2b 100755..100644 --- a/ext/intl/tests/locale_get_default.phpt +++ b/ext/intl/tests/locale_get_default.phpt diff --git a/ext/intl/tests/locale_get_display_language.phpt b/ext/intl/tests/locale_get_display_language.phpt index 2e00056284..2e00056284 100755..100644 --- a/ext/intl/tests/locale_get_display_language.phpt +++ b/ext/intl/tests/locale_get_display_language.phpt diff --git a/ext/intl/tests/locale_get_display_name.phpt b/ext/intl/tests/locale_get_display_name.phpt index b128734277..b128734277 100755..100644 --- a/ext/intl/tests/locale_get_display_name.phpt +++ b/ext/intl/tests/locale_get_display_name.phpt diff --git a/ext/intl/tests/locale_get_display_region.phpt b/ext/intl/tests/locale_get_display_region.phpt index 9a6e75d94a..9a6e75d94a 100755..100644 --- a/ext/intl/tests/locale_get_display_region.phpt +++ b/ext/intl/tests/locale_get_display_region.phpt diff --git a/ext/intl/tests/locale_get_display_script.phpt b/ext/intl/tests/locale_get_display_script.phpt index 0440dfb204..0440dfb204 100755..100644 --- a/ext/intl/tests/locale_get_display_script.phpt +++ b/ext/intl/tests/locale_get_display_script.phpt diff --git a/ext/intl/tests/locale_get_display_script2.phpt b/ext/intl/tests/locale_get_display_script2.phpt index 92652bde90..2b9e037b78 100644 --- a/ext/intl/tests/locale_get_display_script2.phpt +++ b/ext/intl/tests/locale_get_display_script2.phpt @@ -1,8 +1,8 @@ --TEST-- -locale_get_display_script() icu >= 4.8 +locale_get_display_script() icu = 4.8 --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> -<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '49') >= 0) print 'skip'; ?> --FILE-- <?php diff --git a/ext/intl/tests/locale_get_display_script3.phpt b/ext/intl/tests/locale_get_display_script3.phpt new file mode 100644 index 0000000000..447766e6bd --- /dev/null +++ b/ext/intl/tests/locale_get_display_script3.phpt @@ -0,0 +1,275 @@ +--TEST-- +locale_get_display_script() icu >= 49 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '49') < 0) print 'skip'; ?> +--FILE-- +<?php + +/* + * Try getting the display_script for different locales + * with Procedural and Object methods. + */ + +function ut_main() +{ + $res_str = ''; + + $disp_locales=array('en','fr','de'); + + $locales = array( + 'uk-ua_CALIFORNIA@currency=;currency=GRN', + 'root', + 'uk@currency=EURO', + 'Hindi', +//Simple language subtag + 'de', + 'fr', + 'ja', + 'i-enochian', //(example of a grandfathered tag) +//Language subtag plus Script subtag: + 'zh-Hant', + 'zh-Hans', + 'sr-Cyrl', + 'sr-Latn', +//Language-Script-Region + 'zh-Hans-CN', + 'sr-Latn-CS', +//Language-Variant + 'sl-rozaj', + 'sl-nedis', +//Language-Region-Variant + 'de-CH-1901', + 'sl-IT-nedis', +//Language-Script-Region-Variant + 'sl-Latn-IT-nedis', +//Language-Region: + 'de-DE', + 'en-US', + 'es-419', +//Private use subtags: + 'de-CH-x-phonebk', + 'az-Arab-x-AZE-derbend', +//Extended language subtags + 'zh-min', + 'zh-min-nan-Hant-CN', +//Private use registry values + 'x-whatever', + 'qaa-Qaaa-QM-x-southern', + 'sr-Latn-QM', + 'sr-Qaaa-CS', +/*Tags that use extensions (examples ONLY: extensions MUST be defined + by revision or update to this document or by RFC): */ + 'en-US-u-islamCal', + 'zh-CN-a-myExt-x-private', + 'en-a-myExt-b-another', +//Some Invalid Tags: + 'de-419-DE', + 'a-DE', + 'ar-a-aaa-b-bbb-a-ccc' + ); + + + $res_str = ''; + + foreach( $locales as $locale ) + { + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_script( $locale ,$disp_locale ); + $res_str .= "disp_locale=$disp_locale : display_script=$scr"; + $res_str .= "\n"; + } + $res_str .= "-----------------\n"; + } + + return $res_str; + +} + +include_once( 'ut_common.inc' ); +ut_run(); + +?> +--EXPECT-- +locale='uk-ua_CALIFORNIA@currency=;currency=GRN' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='root' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='uk@currency=EURO' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='Hindi' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='fr' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='ja' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='i-enochian' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-Hant' +disp_locale=en : display_script=Traditional Han +disp_locale=fr : display_script=chinois traditionnel +disp_locale=de : display_script=Traditionelles Chinesisch +----------------- +locale='zh-Hans' +disp_locale=en : display_script=Simplified Han +disp_locale=fr : display_script=chinois simplifié +disp_locale=de : display_script=Vereinfachtes Chinesisch +----------------- +locale='sr-Cyrl' +disp_locale=en : display_script=Cyrillic +disp_locale=fr : display_script=cyrillique +disp_locale=de : display_script=Kyrillisch +----------------- +locale='sr-Latn' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='zh-Hans-CN' +disp_locale=en : display_script=Simplified Han +disp_locale=fr : display_script=chinois simplifié +disp_locale=de : display_script=Vereinfachtes Chinesisch +----------------- +locale='sr-Latn-CS' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='sl-rozaj' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-nedis' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-CH-1901' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-IT-nedis' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-Latn-IT-nedis' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='de-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='en-US' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='es-419' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-CH-x-phonebk' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='az-Arab-x-AZE-derbend' +disp_locale=en : display_script=Arabic +disp_locale=fr : display_script=arabe +disp_locale=de : display_script=Arabisch +----------------- +locale='zh-min' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-min-nan-Hant-CN' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='x-whatever' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='qaa-Qaaa-QM-x-southern' +disp_locale=en : display_script=Qaaa +disp_locale=fr : display_script=Qaaa +disp_locale=de : display_script=Qaaa +----------------- +locale='sr-Latn-QM' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='sr-Qaaa-CS' +disp_locale=en : display_script=Qaaa +disp_locale=fr : display_script=Qaaa +disp_locale=de : display_script=Qaaa +----------------- +locale='en-US-u-islamCal' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-CN-a-myExt-x-private' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='en-a-myExt-b-another' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-419-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='a-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='ar-a-aaa-b-bbb-a-ccc' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- diff --git a/ext/intl/tests/locale_get_display_variant.phpt b/ext/intl/tests/locale_get_display_variant.phpt index 9f72ee0498..9f72ee0498 100755..100644 --- a/ext/intl/tests/locale_get_display_variant.phpt +++ b/ext/intl/tests/locale_get_display_variant.phpt diff --git a/ext/intl/tests/locale_get_keywords.phpt b/ext/intl/tests/locale_get_keywords.phpt index 4a09f54d36..4a09f54d36 100755..100644 --- a/ext/intl/tests/locale_get_keywords.phpt +++ b/ext/intl/tests/locale_get_keywords.phpt diff --git a/ext/intl/tests/locale_get_primary_language.phpt b/ext/intl/tests/locale_get_primary_language.phpt index bc92e9266c..bc92e9266c 100755..100644 --- a/ext/intl/tests/locale_get_primary_language.phpt +++ b/ext/intl/tests/locale_get_primary_language.phpt diff --git a/ext/intl/tests/locale_get_region.phpt b/ext/intl/tests/locale_get_region.phpt index 0baae49932..0baae49932 100755..100644 --- a/ext/intl/tests/locale_get_region.phpt +++ b/ext/intl/tests/locale_get_region.phpt diff --git a/ext/intl/tests/locale_get_script.phpt b/ext/intl/tests/locale_get_script.phpt index 6a794fdb12..6a794fdb12 100755..100644 --- a/ext/intl/tests/locale_get_script.phpt +++ b/ext/intl/tests/locale_get_script.phpt diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt index f0affafa6f..f0affafa6f 100755..100644 --- a/ext/intl/tests/locale_lookup.phpt +++ b/ext/intl/tests/locale_lookup.phpt diff --git a/ext/intl/tests/locale_parse_locale.phpt b/ext/intl/tests/locale_parse_locale.phpt index c8aa2f4123..c8aa2f4123 100755..100644 --- a/ext/intl/tests/locale_parse_locale.phpt +++ b/ext/intl/tests/locale_parse_locale.phpt diff --git a/ext/intl/tests/locale_set_default.phpt b/ext/intl/tests/locale_set_default.phpt index 7debf4d3de..7debf4d3de 100755..100644 --- a/ext/intl/tests/locale_set_default.phpt +++ b/ext/intl/tests/locale_set_default.phpt diff --git a/ext/intl/tests/msgfmt_clone_bad_obj.phpt b/ext/intl/tests/msgfmt_clone_bad_obj.phpt new file mode 100644 index 0000000000..48321094d1 --- /dev/null +++ b/ext/intl/tests/msgfmt_clone_bad_obj.phpt @@ -0,0 +1,20 @@ +--TEST-- +Cloning unconstructed MessageFormatter +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +class A extends MessageFormatter { + function __construct() {} +} + +$a = new A; +try { + $b = clone $a; +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +--EXPECTF-- +string(%d) "Cannot clone unconstructed MessageFormatter" diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt index bffb71c56d..bffb71c56d 100755..100644 --- a/ext/intl/tests/msgfmt_fail.phpt +++ b/ext/intl/tests/msgfmt_fail.phpt diff --git a/ext/intl/tests/msgfmt_format.phpt b/ext/intl/tests/msgfmt_format.phpt index c1bf5e9db6..c1bf5e9db6 100755..100644 --- a/ext/intl/tests/msgfmt_format.phpt +++ b/ext/intl/tests/msgfmt_format.phpt diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt index 015c50d465..015c50d465 100755..100644 --- a/ext/intl/tests/msgfmt_get_error.phpt +++ b/ext/intl/tests/msgfmt_get_error.phpt diff --git a/ext/intl/tests/msgfmt_get_locale.phpt b/ext/intl/tests/msgfmt_get_locale.phpt index 4c2651fe2b..4c2651fe2b 100755..100644 --- a/ext/intl/tests/msgfmt_get_locale.phpt +++ b/ext/intl/tests/msgfmt_get_locale.phpt diff --git a/ext/intl/tests/msgfmt_get_set_pattern.phpt b/ext/intl/tests/msgfmt_get_set_pattern.phpt index 67b1aca459..67b1aca459 100755..100644 --- a/ext/intl/tests/msgfmt_get_set_pattern.phpt +++ b/ext/intl/tests/msgfmt_get_set_pattern.phpt diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt index b9ec36374b..b9ec36374b 100755..100644 --- a/ext/intl/tests/msgfmt_parse.phpt +++ b/ext/intl/tests/msgfmt_parse.phpt diff --git a/ext/intl/tests/normalizer_normalize.phpt b/ext/intl/tests/normalizer_normalize.phpt index 238b7423cf..238b7423cf 100755..100644 --- a/ext/intl/tests/normalizer_normalize.phpt +++ b/ext/intl/tests/normalizer_normalize.phpt diff --git a/ext/intl/tests/regression_sort_and_cow.phpt b/ext/intl/tests/regression_sort_and_cow.phpt index d7ff797705..d7ff797705 100755..100644 --- a/ext/intl/tests/regression_sort_and_cow.phpt +++ b/ext/intl/tests/regression_sort_and_cow.phpt diff --git a/ext/intl/tests/regression_sort_eq.phpt b/ext/intl/tests/regression_sort_eq.phpt index 8676c5c931..8676c5c931 100755..100644 --- a/ext/intl/tests/regression_sort_eq.phpt +++ b/ext/intl/tests/regression_sort_eq.phpt diff --git a/ext/intl/tests/regression_sortwsk_and_cow.phpt b/ext/intl/tests/regression_sortwsk_and_cow.phpt index a4953232ef..a4953232ef 100755..100644 --- a/ext/intl/tests/regression_sortwsk_and_cow.phpt +++ b/ext/intl/tests/regression_sortwsk_and_cow.phpt diff --git a/ext/intl/tests/regression_sortwsk_eq.phpt b/ext/intl/tests/regression_sortwsk_eq.phpt index 945bac300a..945bac300a 100755..100644 --- a/ext/intl/tests/regression_sortwsk_eq.phpt +++ b/ext/intl/tests/regression_sortwsk_eq.phpt diff --git a/ext/intl/tests/resourcebundle.build b/ext/intl/tests/resourcebundle.build index 6a7eeae5eb..6a7eeae5eb 100755..100644 --- a/ext/intl/tests/resourcebundle.build +++ b/ext/intl/tests/resourcebundle.build diff --git a/ext/intl/tests/resourcebundle_locales.phpt b/ext/intl/tests/resourcebundle_locales.phpt index e14a7e5aa1..e14a7e5aa1 100755..100644 --- a/ext/intl/tests/resourcebundle_locales.phpt +++ b/ext/intl/tests/resourcebundle_locales.phpt diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt index 8fde61bd21..17fab6d630 100644 --- a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt +++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt @@ -1,11 +1,13 @@ --TEST-- -IntlCalendar::setTime() basic test +ResourceBundle constructor bundle accepts NULL for first two arguments --INI-- date.timezone=Atlantic/Azores --SKIPIF-- <?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip ICU >= 4.8 only'); --FILE-- <?php ini_set("intl.error_level", E_WARNING); diff --git a/ext/intl/tests/spoofchecker_001.phpt b/ext/intl/tests/spoofchecker_001.phpt index 7904b3a4c0..7904b3a4c0 100755..100644 --- a/ext/intl/tests/spoofchecker_001.phpt +++ b/ext/intl/tests/spoofchecker_001.phpt diff --git a/ext/intl/tests/spoofchecker_002.phpt b/ext/intl/tests/spoofchecker_002.phpt index d570917350..d570917350 100755..100644 --- a/ext/intl/tests/spoofchecker_002.phpt +++ b/ext/intl/tests/spoofchecker_002.phpt diff --git a/ext/intl/tests/spoofchecker_003.phpt b/ext/intl/tests/spoofchecker_003.phpt index 0be9bfa409..0be9bfa409 100755..100644 --- a/ext/intl/tests/spoofchecker_003.phpt +++ b/ext/intl/tests/spoofchecker_003.phpt diff --git a/ext/intl/tests/spoofchecker_004.phpt b/ext/intl/tests/spoofchecker_004.phpt index b38c61d717..b38c61d717 100755..100644 --- a/ext/intl/tests/spoofchecker_004.phpt +++ b/ext/intl/tests/spoofchecker_004.phpt diff --git a/ext/intl/tests/symfony_format_type_double_intl1.phpt b/ext/intl/tests/symfony_format_type_double_intl1.phpt new file mode 100644 index 0000000000..13a7ad761f --- /dev/null +++ b/ext/intl/tests/symfony_format_type_double_intl1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #1 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeDoubleIntl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(1) "1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_double_intl2.phpt b/ext/intl/tests/symfony_format_type_double_intl2.phpt new file mode 100644 index 0000000000..6bff7cc355 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_double_intl2.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #2 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:3:"1.1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeDoubleIntl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(3) "1.1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_double_intl3.phpt b/ext/intl/tests/symfony_format_type_double_intl3.phpt new file mode 100644 index 0000000000..3b0d576df7 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_double_intl3.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #3 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeDoubleIntl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(7) "SFD1.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_double_intl4.phpt b/ext/intl/tests/symfony_format_type_double_intl4.phpt new file mode 100644 index 0000000000..3476e10892 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_double_intl4.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #4 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeDoubleIntl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.10";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeDoubleIntl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(7) "SFD1.10" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl1.phpt b/ext/intl/tests/symfony_format_type_int32_intl1.phpt new file mode 100644 index 0000000000..2867b35690 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #1 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +// port of Symfony's Symfony\Component\Locale\Tests\Stub\StubNumberFormatterTest#testFormatTypeInt32Intl + + +// Crashes on Windows +// Windows note: the popup '...program has stopped working'(AEDebug Popup) +// doesn't always show if you're rapidly running this test repeatedly. +// regardless of that, the test always crashes every time. +// (it will show up the first time, or if you wait a while before running it again.) +// (the popup may also be disabled, which can be done with a registry setting.) +// you can confirm it crashed by checking the exit code OR +// the message this test prints at the very end (expected output for pass). +// +// Get Exit Code +// Linux: echo $? +// Windows: echo %ErrorLevel% + + + + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(1) "1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl2.phpt b/ext/intl/tests/symfony_format_type_int32_intl2.phpt new file mode 100644 index 0000000000..6a65a0a809 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #2 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +// StubNumberFormatterTest#testFormatTypeInt32Intl is tested many times, each with different args. +// there are 7 sets of args that crash PHP (and other args that don't), each of those 7 is now a separate PHPT test +// to ensure that each of the 7 args are always tested. + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:1:"1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(1) "1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl3.phpt b/ext/intl/tests/symfony_format_type_int32_intl3.phpt new file mode 100644 index 0000000000..5e657db419 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl3.phpt @@ -0,0 +1,32 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #3 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:14:"-2,147,483,648";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(4) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(2147483648) + [2]=> + string(14) "-2,147,483,648" + [3]=> + string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl4.phpt b/ext/intl/tests/symfony_format_type_int32_intl4.phpt new file mode 100644 index 0000000000..54043d92e9 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl4.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #4 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(7) "SFD1.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl5.phpt b/ext/intl/tests/symfony_format_type_int32_intl5.phpt new file mode 100644 index 0000000000..d5f78d7119 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl5.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #5 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(7) "SFD1.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl6.phpt b/ext/intl/tests/symfony_format_type_int32_intl6.phpt new file mode 100644 index 0000000000..fa708799d1 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl6.phpt @@ -0,0 +1,32 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #6 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:21:"(SFD2,147,483,648.00)";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(4) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(2147483648) + [2]=> + string(21) "(SFD2,147,483,648.00)" + [3]=> + string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int32_intl7.phpt b/ext/intl/tests/symfony_format_type_int32_intl7.phpt new file mode 100644 index 0000000000..5bbe426677 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int32_intl7.phpt @@ -0,0 +1,32 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #7 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl +$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:19:"SFD2,147,483,647.00";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt32Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(4) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(-2147483649) + [2]=> + string(19) "SFD2,147,483,647.00" + [3]=> + string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl1.phpt b/ext/intl/tests/symfony_format_type_int64_intl1.phpt new file mode 100644 index 0000000000..01f5820911 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #1 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +//$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(1) "1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl2.phpt b/ext/intl/tests/symfony_format_type_int64_intl2.phpt new file mode 100644 index 0000000000..13d1cdaee7 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl2.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #2 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:1:"1";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(1) "1" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl3.phpt b/ext/intl/tests/symfony_format_type_int64_intl3.phpt new file mode 100644 index 0000000000..a7c80b34c3 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl3.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #3 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:13:"2,147,483,648";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(2147483648) + [2]=> + string(13) "2,147,483,648" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl4.phpt b/ext/intl/tests/symfony_format_type_int64_intl4.phpt new file mode 100644 index 0000000000..f1a0801edf --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl4.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #4 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:14:"-2,147,483,649";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(-2147483649) + [2]=> + string(14) "-2,147,483,649" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl5.phpt b/ext/intl/tests/symfony_format_type_int64_intl5.phpt new file mode 100644 index 0000000000..dad8735b89 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl5.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #5 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + int(1) + [2]=> + string(7) "SFD1.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl6.phpt b/ext/intl/tests/symfony_format_type_int64_intl6.phpt new file mode 100644 index 0000000000..f038cbd0c3 --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl6.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #6 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(1.1) + [2]=> + string(7) "SFD1.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl7.phpt b/ext/intl/tests/symfony_format_type_int64_intl7.phpt new file mode 100644 index 0000000000..9c8853cafc --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl7.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #7 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:19:"SFD2,147,483,648.00";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(2147483648) + [2]=> + string(19) "SFD2,147,483,648.00" +} +== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl8.phpt b/ext/intl/tests/symfony_format_type_int64_intl8.phpt new file mode 100644 index 0000000000..50524976ab --- /dev/null +++ b/ext/intl/tests/symfony_format_type_int64_intl8.phpt @@ -0,0 +1,30 @@ +--TEST-- +Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #8 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + + +// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt64Intl +$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:21:"(SFD2,147,483,649.00)";}'); + +var_dump($unit_test_args); + +// execute the code from #testFormatTypeInt64Intl +$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64); + +echo "== didn't crash ==".PHP_EOL; + +?> +--EXPECT-- +array(3) { + [0]=> + object(NumberFormatter)#1 (0) { + } + [1]=> + float(-2147483649) + [2]=> + string(21) "(SFD2,147,483,649.00)" +} +== didn't crash == diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc index 09be22bf5a..09be22bf5a 100755..100644 --- a/ext/intl/tests/ut_common.inc +++ b/ext/intl/tests/ut_common.inc diff --git a/ext/mcrypt/tests/mcrypt_cbf.phpt b/ext/mcrypt/tests/mcrypt_cfb.phpt index 8ec3cd7d3e..54919c8589 100644 --- a/ext/mcrypt/tests/mcrypt_cbf.phpt +++ b/ext/mcrypt/tests/mcrypt_cfb.phpt @@ -1,5 +1,5 @@ --TEST-- -mcrypt_cbf +mcrypt_cfb --SKIPIF-- <?php if (!extension_loaded("mcrypt")) print "skip"; ?> --FILE-- @@ -8,7 +8,7 @@ $key = "FooBar"; $secret = "PHP Testfest 2008"; $cipher = MCRYPT_RIJNDAEL_128; -$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_ECB), MCRYPT_RAND); +$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CFB), MCRYPT_RAND); $enc_data = mcrypt_cfb($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv); // we have to trim as AES rounds the blocks and decrypt doesnt detect that @@ -20,4 +20,4 @@ mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT); --EXPECTF-- PHP Testfest 2008 -Warning: mcrypt_cfb(): Attempt to use an empty IV, which is NOT recommend in %s on line %d
\ No newline at end of file +Warning: mcrypt_cfb(): Attempt to use an empty IV, which is NOT recommend in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_create_iv.phpt b/ext/mcrypt/tests/mcrypt_create_iv.phpt index cf6456fef7..1aa48868b0 100644 --- a/ext/mcrypt/tests/mcrypt_create_iv.phpt +++ b/ext/mcrypt/tests/mcrypt_create_iv.phpt @@ -5,13 +5,13 @@ mcrypt_create_iv --FILE-- <?php $iv1 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND); -$iv2 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_192, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM); -$iv3 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM); +$iv2 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM); +$iv3 = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM); echo strlen($iv1) . "\n"; echo strlen($iv2) . "\n"; echo strlen($iv3) . "\n"; --EXPECT-- 16 -24 -32 +16 +16 diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt index 339d36c934..aa15f5ca12 100644 --- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt +++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt @@ -2,7 +2,6 @@ LOAD DATA INFILE - open_basedir --SKIPIF-- <?php -@include_once("connect.inc"); include_once('skipif.inc'); include_once('skipifconnectfailure.inc'); diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 0cc1240208..7e1b9355d0 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -781,6 +781,11 @@ PHP_FUNCTION(mysqli_poll) RETURN_FALSE; } + if (!r_array && !e_array) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No stream arrays were passed"); + RETURN_FALSE; + } + if (r_array != NULL) { mysqlnd_zval_array_to_mysqlnd_array(r_array, &new_r_array TSRMLS_CC); } diff --git a/ext/mysqli/tests/bug62885.phpt b/ext/mysqli/tests/bug62885.phpt new file mode 100644 index 0000000000..9fb0aa0f03 --- /dev/null +++ b/ext/mysqli/tests/bug62885.phpt @@ -0,0 +1,26 @@ +--TEST--
+Bug #62885 (mysqli_poll - Segmentation fault)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once("connect.inc");
+if (!$IS_MYSQLND) {
+ die("skip mysqlnd only test");
+}
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+$tablica = array();
+$test1 = mysqli_poll($test2, $test3, $tablica, null);
+
+$test2 = array();
+$test2 = array();
+$test1 = mysqli_poll($test2, $test3, $tablica, null);
+echo "okey";
+?>
+--EXPECTF--
+Warning: mysqli_poll(): No stream arrays were passed in %sbug62885.php on line %d
+
+Warning: mysqli_poll(): No stream arrays were passed in %sbug62885.php on line %d
+okey
diff --git a/ext/oci8/tests/bind_char_2_11gR1.phpt b/ext/oci8/tests/bind_char_2_11gR1.phpt index 8bb28733fe..edb2a12ff0 100644 --- a/ext/oci8/tests/bind_char_2_11gR1.phpt +++ b/ext/oci8/tests/bind_char_2_11gR1.phpt @@ -5,7 +5,7 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', $sv, $matches) !== 1) { +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } diff --git a/ext/oci8/tests/bind_char_3_11gR1.phpt b/ext/oci8/tests/bind_char_3_11gR1.phpt index 4c6241ccfd..fea77754d1 100644 --- a/ext/oci8/tests/bind_char_3_11gR1.phpt +++ b/ext/oci8/tests/bind_char_3_11gR1.phpt @@ -5,7 +5,7 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', $sv, $matches) !== 1) { +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } diff --git a/ext/oci8/tests/bind_char_4_11gR1.phpt b/ext/oci8/tests/bind_char_4_11gR1.phpt index 14d5878856..2bc2f14246 100644 --- a/ext/oci8/tests/bind_char_4_11gR1.phpt +++ b/ext/oci8/tests/bind_char_4_11gR1.phpt @@ -5,7 +5,7 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', $sv, $matches) !== 1) { +if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc index 0f03c3a65f..9a86c46868 100644 --- a/ext/oci8/tests/details.inc +++ b/ext/oci8/tests/details.inc @@ -45,31 +45,34 @@ if (file_exists(dirname(__FILE__)."/details_local.inc")) { * Used for creating/dropping schema objects used by a test */ -function oci8_test_sql_execute($c, $stmtarray) -{ - foreach ($stmtarray as $stmt) { - $s = oci_parse($c, $stmt); - if (!$s) { - $m = oci_error($c); - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; - } - else { - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - if (!in_array($m['code'], array( // ignore expected errors - 942 // table or view does not exist - , 1918 // user does not exist - , 2024 // database link not found - , 2289 // sequence does not exist - , 4080 // trigger does not exist - , 38802 // edition does not exist - ))) { - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; - } - } - } - } +if (!function_exists('oci8_test_sql_execute')) { + function oci8_test_sql_execute($c, $stmtarray) + { + foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + if (!$s) { + $m = oci_error($c); + echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + } + else { + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + if (!in_array($m['code'], array( // ignore expected errors + 942 // table or view does not exist + , 1918 // user does not exist + , 2024 // database link not found + , 2289 // sequence does not exist + , 4080 // trigger does not exist + , 38802 // edition does not exist + ))) { + echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + } + } + } + } + } + } ?> diff --git a/ext/oci8/tests/pecl_bug10194.phpt b/ext/oci8/tests/pecl_bug10194.phpt index 9947e15dbc..3c1c7887c2 100644 --- a/ext/oci8/tests/pecl_bug10194.phpt +++ b/ext/oci8/tests/pecl_bug10194.phpt @@ -5,6 +5,9 @@ PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs require(dirname(__FILE__).'/skipif.inc'); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --INI-- memory_limit=10M diff --git a/ext/oci8/tests/pecl_bug10194_blob.phpt b/ext/oci8/tests/pecl_bug10194_blob.phpt index faf87ab3c1..96f94bcf4c 100644 --- a/ext/oci8/tests/pecl_bug10194_blob.phpt +++ b/ext/oci8/tests/pecl_bug10194_blob.phpt @@ -6,6 +6,9 @@ $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on t require(dirname(__FILE__).'/skipif.inc'); if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only"); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --INI-- memory_limit=3M diff --git a/ext/oci8/tests/pecl_bug10194_blob_64.phpt b/ext/oci8/tests/pecl_bug10194_blob_64.phpt index 45788a41b4..e1a4cc034e 100644 --- a/ext/oci8/tests/pecl_bug10194_blob_64.phpt +++ b/ext/oci8/tests/pecl_bug10194_blob_64.phpt @@ -6,6 +6,9 @@ $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on t require(dirname(__FILE__).'/skipif.inc'); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --INI-- memory_limit=6M diff --git a/ext/oci8/tests/xmltype_01.phpt b/ext/oci8/tests/xmltype_01.phpt index 21aca6cc12..ebbbb31fac 100644 --- a/ext/oci8/tests/xmltype_01.phpt +++ b/ext/oci8/tests/xmltype_01.phpt @@ -5,6 +5,7 @@ Basic XMLType test if (!extension_loaded("simplexml")) die("skip no simplexml extension"); $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs require(dirname(__FILE__).'/skipif.inc'); +?> --FILE-- <?php diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index b4f383c94f..acdc0dd90d 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -700,7 +700,7 @@ static PHP_METHOD(PDO, inTransaction) RETURN_BOOL(dbh->in_txn); } - RETURN_LONG(dbh->methods->in_transaction(dbh TSRMLS_CC)); + RETURN_BOOL(dbh->methods->in_transaction(dbh TSRMLS_CC)); } /* }}} */ diff --git a/ext/pdo/tests/bug_43130.phpt b/ext/pdo/tests/bug_43130.phpt index a35138a07f..70f8887111 100644 --- a/ext/pdo/tests/bug_43130.phpt +++ b/ext/pdo/tests/bug_43130.phpt @@ -8,6 +8,7 @@ if (false == $dir) die('skip no driver'); if (!strncasecmp(getenv('PDOTEST_DSN'), 'sqlite', strlen('sqlite'))) die('skip not relevant for sqlite driver'); if (!strncasecmp(getenv('PDOTEST_DSN'), 'pgsql', strlen('pgsql'))) die('skip not relevant for pgsql driver'); if (!strncasecmp(getenv('PDOTEST_DSN'), 'oci', strlen('oci'))) die('skip not relevant for oci driver - Hyphen is not legal for bind names in Oracle DB'); +if (!strncasecmp(getenv('PDOTEST_DSN'), 'firebird', strlen('firebird'))) die('skip not relevant for firebird driver'); require_once $dir . 'pdo_test.inc'; PDOTest::skip(); ?> diff --git a/ext/pdo_firebird/tests/bug_47415.phpt b/ext/pdo_firebird/tests/bug_47415.phpt index cedc2c45b2..12cd782f26 100644 --- a/ext/pdo_firebird/tests/bug_47415.phpt +++ b/ext/pdo_firebird/tests/bug_47415.phpt @@ -2,6 +2,7 @@ Bug #47415 PDO_Firebird segfaults when passing lowercased column name to bindColumn() --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/bug_48877.phpt b/ext/pdo_firebird/tests/bug_48877.phpt index 290cd7a3a0..cbab84b372 100644 --- a/ext/pdo_firebird/tests/bug_48877.phpt +++ b/ext/pdo_firebird/tests/bug_48877.phpt @@ -2,6 +2,7 @@ PDO_Firebird: bug 48877 The "bindValue" and "bindParam" do not work for PDO Firebird if we use named parameters (:parameter). --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/bug_53280.phpt b/ext/pdo_firebird/tests/bug_53280.phpt index 1be4e8a826..3139867af1 100644 --- a/ext/pdo_firebird/tests/bug_53280.phpt +++ b/ext/pdo_firebird/tests/bug_53280.phpt @@ -2,6 +2,7 @@ PDO_Firebird: bug 53280 segfaults if query column count is less than param count --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/connect.phpt b/ext/pdo_firebird/tests/connect.phpt index e4bb8ef54e..cbe76e6865 100644 --- a/ext/pdo_firebird/tests/connect.phpt +++ b/ext/pdo_firebird/tests/connect.phpt @@ -2,6 +2,7 @@ PDO_Firebird: connect/disconnect --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/pdo_firebird/tests/ddl.phpt b/ext/pdo_firebird/tests/ddl.phpt index 9a3ddd1002..9d2a0953ec 100644 --- a/ext/pdo_firebird/tests/ddl.phpt +++ b/ext/pdo_firebird/tests/ddl.phpt @@ -2,6 +2,7 @@ PDO_Firebird: DDL/transactions --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/pdo_firebird/tests/execute.phpt b/ext/pdo_firebird/tests/execute.phpt index 3a759fc51b..896347e935 100644 --- a/ext/pdo_firebird/tests/execute.phpt +++ b/ext/pdo_firebird/tests/execute.phpt @@ -2,6 +2,7 @@ PDO_Firebird: prepare/execute/binding --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --INI-- ibase.timestampformat=%Y-%m-%d %H:%M:%S --FILE-- diff --git a/ext/pdo_firebird/tests/rowCount.phpt b/ext/pdo_firebird/tests/rowCount.phpt index 3d7f71c83b..1a009508e0 100644 --- a/ext/pdo_firebird/tests/rowCount.phpt +++ b/ext/pdo_firebird/tests/rowCount.phpt @@ -2,6 +2,7 @@ PDO_Firebird: rowCount --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 2a47d3d035..cc7eac717d 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2647,11 +2647,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, len = -len; } user_stub = 0; -#if PHP_MAJOR_VERSION >= 6 - if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) { -#else + if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) { -#endif if (closeoldfile) { php_stream_close(oldfile); } diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index 9e968694c3..cb343675b5 100755 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -91,7 +91,7 @@ class PharCommand extends CLICommand 'h' => array( 'typ' => 'select', 'val' => NULL, - 'inf' => '<method> Selects the hash algorithmn.', + 'inf' => '<method> Selects the hash algorithm.', 'select' => array('md5' => 'MD5','sha1' => 'SHA1') ), 'i' => array( @@ -107,7 +107,7 @@ class PharCommand extends CLICommand 'l' => array( 'typ' => 'int', 'val' => 0, - 'inf' => '<level> Number of preceeding subdirectories to strip from file entries', + 'inf' => '<level> Number of preceding subdirectories to strip from file entries', ), 'm' => array( 'typ' => 'any', @@ -461,7 +461,7 @@ class PharCommand extends CLICommand 'typ' => 'any', 'val' => NULL, 'required' => 1, - 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching thegiven regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', + 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', ); return $args; @@ -981,7 +981,7 @@ class PharCommand extends CLICommand 'type' => 'any', 'val' => NULL, 'required' => 1, - 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching thegiven regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', + 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', ); return $args; } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index de9fffc115..561ba7bf24 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -58,9 +58,6 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */ { -#if PHP_MAJOR_VERSION >= 6 - int is_unicode = 0; -#endif HashTable *_SERVER; zval **stuff; char *path_info; @@ -76,18 +73,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char _SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]); /* PATH_INFO and PATH_TRANSLATED should always be munged */ -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); @@ -96,38 +82,19 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL); } } -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry); MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL); } @@ -136,18 +103,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char } if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) { -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); @@ -156,29 +112,14 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL); } } } if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) { -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); @@ -187,68 +128,34 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL); } } } if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) { -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); ZVAL_STRINGL(*stuff, entry, entry_len, 1); MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL); } } if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) { -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff TSRMLS_CC)) { - if (Z_TYPE_PP(stuff) == IS_UNICODE) { - is_unicode = 1; - zval_unicode_to_string(*stuff TSRMLS_CC); - } else { - is_unicode = 0; - } -#else if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) { -#endif - path_info = Z_STRVAL_PP(stuff); code = Z_STRLEN_PP(stuff); Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry); MAKE_STD_ZVAL(temp); ZVAL_STRINGL(temp, path_info, code, 0); -#if PHP_MAJOR_VERSION >= 6 - if (is_unicode) { - zval_string_to_unicode(*stuff TSRMLS_CC); - } -#endif + zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL); } } @@ -942,11 +849,7 @@ PHP_METHOD(Phar, webPhar) if (ext) { ++ext; -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val TSRMLS_CC)) { -#else if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) { -#endif switch (Z_TYPE_PP(val)) { case IS_LONG: if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) { @@ -960,11 +863,6 @@ PHP_METHOD(Phar, webPhar) RETURN_FALSE; } break; -#if PHP_MAJOR_VERSION >= 6 - case IS_UNICODE: - zval_unicode_to_string(*(val) TSRMLS_CC); - /* break intentionally omitted */ -#endif case IS_STRING: mime_type = Z_STRVAL_PP(val); code = PHAR_MIME_OTHER; @@ -1015,26 +913,12 @@ PHP_METHOD(Phar, mungServer) for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) { zval **data = NULL; -#if PHP_MAJOR_VERSION >= 6 - zval *unicopy = NULL; -#endif if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()"); return; } -#if PHP_MAJOR_VERSION >= 6 - if (Z_TYPE_PP(data) == IS_UNICODE) { - MAKE_STD_ZVAL(unicopy); - *unicopy = **data; - zval_copy_ctor(unicopy); - INIT_PZVAL(unicopy); - zval_unicode_to_string(unicopy TSRMLS_CC); - data = &unicopy; - } -#endif - if (Z_TYPE_PP(data) != IS_STRING) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; @@ -1056,11 +940,6 @@ PHP_METHOD(Phar, mungServer) if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) { PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME; } -#if PHP_MAJOR_VERSION >= 6 - if (unicopy) { - zval_ptr_dtor(&unicopy); - } -#endif } } /* }}} */ @@ -5037,11 +4916,7 @@ PHP_METHOD(PharFileInfo, getContent) phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC); Z_TYPE_P(return_value) = IS_STRING; -#if PHP_MAJOR_VERSION >= 6 - Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0); -#else Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0); -#endif if (!Z_STRVAL_P(return_value)) { Z_STRVAL_P(return_value) = estrndup("", 0); diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 2f72551262..bf0913d683 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -207,30 +207,19 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *pat fpf = php_stream_alloc(&phar_ops, idata, NULL, mode); php_url_free(resource); efree(internal_file); -#if PHP_MAJOR_VERSION >= 6 - if (context && context->options && phar_find_key(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption TSRMLS_CC)) { -#else + if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) { -#endif pharcontext = HASH_OF(*pzoption); if (idata->internal_file->uncompressed_filesize == 0 && idata->internal_file->compressed_filesize == 0 -#if PHP_MAJOR_VERSION >= 6 - && phar_find_key(pharcontext, "compress", sizeof("compress"), (void**)&pzoption TSRMLS_CC) -#else && zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS -#endif && Z_TYPE_PP(pzoption) == IS_LONG && (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0 ) { idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK; idata->internal_file->flags |= Z_LVAL_PP(pzoption); } -#if PHP_MAJOR_VERSION >= 6 - if (phar_find_key(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption TSRMLS_CC)) { -#else if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) { -#endif if (idata->internal_file->metadata) { zval_ptr_dtor(&idata->internal_file->metadata); idata->internal_file->metadata = NULL; diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 917734c992..43d1ede238 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -986,11 +986,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau len = -len; } user_stub = 0; -#if PHP_MAJOR_VERSION >= 6 - if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) { -#else + if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) { -#endif if (error) { spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname); } diff --git a/ext/phar/util.c b/ext/phar/util.c index d5b6a5dd13..5fcb2b6573 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -210,8 +210,6 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, return FAILURE; } #endif - - filename_len = strlen(entry.tmp); filename = entry.tmp; /* only check openbasedir for files, not for phar streams */ diff --git a/ext/phar/zip.c b/ext/phar/zip.c index ced975cb38..3372622552 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -603,11 +603,7 @@ foundit: php_stream_filter_append(&fp->readfilters, filter); -#if PHP_MAJOR_VERSION >= 6 - if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#else if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#endif pefree(entry.filename, entry.is_persistent); #if PHP_VERSION_ID < 50207 PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); @@ -628,11 +624,7 @@ foundit: php_stream_filter_append(&fp->readfilters, filter); -#if PHP_MAJOR_VERSION >= 6 - if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#else if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#endif pefree(entry.filename, entry.is_persistent); #if PHP_VERSION_ID < 50207 PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); @@ -643,11 +635,7 @@ foundit: php_stream_filter_flush(filter, 1); php_stream_filter_remove(filter, 1 TSRMLS_CC); } else { -#if PHP_MAJOR_VERSION >= 6 - if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#else if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { -#endif pefree(entry.filename, entry.is_persistent); PHAR_ZIP_FAIL("unable to read in alias, truncated"); } @@ -1252,11 +1240,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau user_stub = 0; -#if PHP_MAJOR_VERSION >= 6 - if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) { -#else if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) { -#endif if (error) { spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname); } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index bcdcdaeea3..7c9981924d 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1477,11 +1477,6 @@ static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTIO return NULL; } - if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); - return NULL; - } - return param; } /* }}} */ @@ -1497,7 +1492,7 @@ static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error: Failed to retrieve the default value"); return NULL; } @@ -2568,9 +2563,7 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable) { RETURN_FALSE; } - if (param->offset < param->required) { - RETURN_FALSE; - } + precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { RETURN_FALSE; @@ -4471,8 +4464,10 @@ ZEND_METHOD(reflection_class, getTraitAliases) int method_name_len; zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method; - method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_name, cur_ref->method_name); - add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0); + if (ce->trait_aliases[i]->alias) { + method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_name, cur_ref->method_name); + add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0); + } i++; } } diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt index 984b06efe2..a2c2d24582 100644 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt @@ -18,8 +18,6 @@ foreach($reflect->getParameters() as $param) { } } ?> -==DONE== --EXPECT-- -Parameter is not optional +Internal error: Failed to retrieve the default value CONST_TEST_1 -==DONE== diff --git a/ext/reflection/tests/bug62715.phpt b/ext/reflection/tests/bug62715.phpt new file mode 100644 index 0000000000..feb67f614b --- /dev/null +++ b/ext/reflection/tests/bug62715.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result) +--FILE-- +<?php + +function test(PDO $a = null, $b = 0, array $c) {} +$r = new ReflectionFunction('test'); + +foreach ($r->getParameters() as $p) { + var_dump($p->isDefaultValueAvailable()); +} + +foreach ($r->getParameters() as $p) { + if ($p->isDefaultValueAvailable()) { + var_dump($p->getDefaultValue()); + } +} +?> +--EXPECT-- +bool(true) +bool(true) +bool(false) +NULL +int(0) diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 2ff5302f78..84a28d3427 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -63,7 +63,7 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) } #define STDVARS \ - zval *retval; \ + zval *retval = NULL; \ int ret = FAILURE #define PSF(a) PS(mod_user_names).name.ps_##a @@ -99,6 +99,7 @@ PS_OPEN_FUNC(user) PS_CLOSE_FUNC(user) { + zend_bool bailout = 0; STDVARS; if (!PS(mod_user_implemented)) { @@ -106,9 +107,21 @@ PS_CLOSE_FUNC(user) return SUCCESS; } - retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + zend_try { + retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + } zend_catch { + bailout = 1; + } zend_end_try(); + PS(mod_user_implemented) = 0; + if (bailout) { + if (retval) { + zval_ptr_dtor(&retval); + } + zend_bailout(); + } + FINISH; } diff --git a/ext/session/tests/bug60634_error_5.phpt b/ext/session/tests/bug60634_error_5.phpt index 376b65f20b..8081ab988a 100644 --- a/ext/session/tests/bug60634_error_5.phpt +++ b/ext/session/tests/bug60634_error_5.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in close during exec ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 7236b8a1b3..5514f0fc89 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1417,7 +1417,11 @@ SXE_METHOD(asXML) xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); xmlOutputBufferFlush(outbuf); +#ifdef LIBXML2_NEW_BUFFER + RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), xmlOutputBufferGetSize(outbuf), 1); +#else RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); +#endif xmlOutputBufferClose(outbuf); } } else { diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index e2ea17a3fe..1e4577a3f9 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -58,6 +58,10 @@ PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator; #define SPL_ARRAY_INT_MASK 0xFFFF0000 #define SPL_ARRAY_CLONE_MASK 0x0300FFFF +#define SPL_ARRAY_METHOD_NO_ARG 0 +#define SPL_ARRAY_METHOD_USE_ARG 1 +#define SPL_ARRAY_METHOD_MAY_USER_ARG 2 + typedef struct _spl_array_object { zend_object std; zval *array; @@ -1426,26 +1430,36 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC); HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); - zval *tmp, *arg; + zval *tmp, *arg = NULL; zval *retval_ptr = NULL; MAKE_STD_ZVAL(tmp); Z_TYPE_P(tmp) = IS_ARRAY; Z_ARRVAL_P(tmp) = aht; - if (use_arg) { - if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { + if (!use_arg) { + aht->nApplyCount++; + zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, tmp, NULL TSRMLS_CC); + aht->nApplyCount--; + } else if (use_arg == SPL_ARRAY_METHOD_MAY_USER_ARG) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) { Z_TYPE_P(tmp) = IS_NULL; zval_ptr_dtor(&tmp); - zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC); + zend_throw_exception(spl_ce_BadMethodCallException, "Function expects one argument at most", 0 TSRMLS_CC); return; } aht->nApplyCount++; - zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, tmp, arg TSRMLS_CC); + zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, arg? 2 : 1, tmp, arg TSRMLS_CC); aht->nApplyCount--; } else { + if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { + Z_TYPE_P(tmp) = IS_NULL; + zval_ptr_dtor(&tmp); + zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC); + return; + } aht->nApplyCount++; - zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, tmp, NULL TSRMLS_CC); + zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, tmp, arg TSRMLS_CC); aht->nApplyCount--; } Z_TYPE_P(tmp) = IS_NULL; /* we want to destroy the zval, not the hashtable */ @@ -1461,35 +1475,35 @@ SPL_METHOD(cname, fname) \ spl_array_method(INTERNAL_FUNCTION_PARAM_PASSTHRU, #fname, sizeof(#fname)-1, use_arg); \ } -/* {{{ proto int ArrayObject::asort() - proto int ArrayIterator::asort() +/* {{{ proto int ArrayObject::asort([int $sort_flags = SORT_REGULAR ]) + proto int ArrayIterator::asort([int $sort_flags = SORT_REGULAR ]) Sort the entries by values. */ -SPL_ARRAY_METHOD(Array, asort, 0) /* }}} */ +SPL_ARRAY_METHOD(Array, asort, SPL_ARRAY_METHOD_MAY_USER_ARG) /* }}} */ -/* {{{ proto int ArrayObject::ksort() - proto int ArrayIterator::ksort() +/* {{{ proto int ArrayObject::ksort([int $sort_flags = SORT_REGULAR ]) + proto int ArrayIterator::ksort([int $sort_flags = SORT_REGULAR ]) Sort the entries by key. */ -SPL_ARRAY_METHOD(Array, ksort, 0) /* }}} */ +SPL_ARRAY_METHOD(Array, ksort, SPL_ARRAY_METHOD_MAY_USER_ARG) /* }}} */ /* {{{ proto int ArrayObject::uasort(callback cmp_function) proto int ArrayIterator::uasort(callback cmp_function) Sort the entries by values user defined function. */ -SPL_ARRAY_METHOD(Array, uasort, 1) /* }}} */ +SPL_ARRAY_METHOD(Array, uasort, SPL_ARRAY_METHOD_USE_ARG) /* }}} */ /* {{{ proto int ArrayObject::uksort(callback cmp_function) proto int ArrayIterator::uksort(callback cmp_function) Sort the entries by key using user defined function. */ -SPL_ARRAY_METHOD(Array, uksort, 1) /* }}} */ +SPL_ARRAY_METHOD(Array, uksort, SPL_ARRAY_METHOD_USE_ARG) /* }}} */ /* {{{ proto int ArrayObject::natsort() proto int ArrayIterator::natsort() Sort the entries by values using "natural order" algorithm. */ -SPL_ARRAY_METHOD(Array, natsort, 0) /* }}} */ +SPL_ARRAY_METHOD(Array, natsort, SPL_ARRAY_METHOD_NO_ARG) /* }}} */ /* {{{ proto int ArrayObject::natcasesort() proto int ArrayIterator::natcasesort() Sort the entries by key using case insensitive "natural order" algorithm. */ -SPL_ARRAY_METHOD(Array, natcasesort, 0) /* }}} */ +SPL_ARRAY_METHOD(Array, natcasesort, SPL_ARRAY_METHOD_NO_ARG) /* }}} */ /* {{{ proto mixed|NULL ArrayIterator::current() Return current array entry */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 0fcbd317e3..b86e68659d 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -433,7 +433,6 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_ if (file_path && !use_copy) { efree(file_path); } - use_copy = 1; file_path_len = 1; file_path = "/"; #endif diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 1124285545..244bd3e0df 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -223,10 +223,14 @@ static zend_object_value spl_fixedarray_object_new_ex(zend_class_entry *class_ty if (orig && clone_orig) { spl_fixedarray_object *other = (spl_fixedarray_object*)zend_object_store_get_object(orig TSRMLS_CC); intern->ce_get_iterator = other->ce_get_iterator; - - intern->array = emalloc(sizeof(spl_fixedarray)); - spl_fixedarray_init(intern->array, other->array->size TSRMLS_CC); - spl_fixedarray_copy(intern->array, other->array TSRMLS_CC); + if (!other->array) { + /* leave a empty object, will be dtor later by CLONE handler */ + zend_throw_exception(spl_ce_RuntimeException, "The instance wasn't initialized properly", 0 TSRMLS_CC); + } else { + intern->array = emalloc(sizeof(spl_fixedarray)); + spl_fixedarray_init(intern->array, other->array->size TSRMLS_CC); + spl_fixedarray_copy(intern->array, other->array TSRMLS_CC); + } } while (parent) { diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 19a68f6372..e5dc030730 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1289,6 +1289,8 @@ static union _zend_function *spl_dual_it_get_method(zval **object_ptr, char *met *object_ptr = intern->inner.zobject; function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len, key TSRMLS_CC); } + } else { + *object_ptr = intern->inner.zobject; } } return function_handler; diff --git a/ext/spl/tests/arrayObject_asort_basic1.phpt b/ext/spl/tests/arrayObject_asort_basic1.phpt index ec69049a32..53df1d502b 100644 --- a/ext/spl/tests/arrayObject_asort_basic1.phpt +++ b/ext/spl/tests/arrayObject_asort_basic1.phpt @@ -17,12 +17,14 @@ var_dump($ao1->asort()); var_dump($ao1); var_dump($ao2->asort('blah')); var_dump($ao2); +var_dump($ao2->asort(SORT_NUMERIC)); +var_dump($ao2); ?> ===DONE=== --EXPECTF-- *** Testing ArrayObject::asort() : basic functionality *** bool(true) -object(ArrayObject)#1 (1) { +object(ArrayObject)#%d (1) { ["storage":"ArrayObject":private]=> array(3) { [1]=> @@ -33,8 +35,22 @@ object(ArrayObject)#1 (1) { int(4) } } + +Warning: asort() expects parameter 2 to be long, string given in %sarrayObject_asort_basic1.php on line %d +bool(false) +object(ArrayObject)#%d (1) { + ["storage":"ArrayObject":private]=> + array(3) { + ["a"]=> + int(4) + ["b"]=> + int(2) + ["c"]=> + int(3) + } +} bool(true) -object(ArrayObject)#2 (1) { +object(ArrayObject)#%d (1) { ["storage":"ArrayObject":private]=> array(3) { ["b"]=> diff --git a/ext/spl/tests/arrayObject_ksort_basic1.phpt b/ext/spl/tests/arrayObject_ksort_basic1.phpt index 9c8d1e7345..8f37938126 100644 --- a/ext/spl/tests/arrayObject_ksort_basic1.phpt +++ b/ext/spl/tests/arrayObject_ksort_basic1.phpt @@ -16,12 +16,14 @@ var_dump($ao1->ksort()); var_dump($ao1); var_dump($ao2->ksort('blah')); var_dump($ao2); +var_dump($ao2->ksort(SORT_STRING)); +var_dump($ao2); ?> ===DONE=== --EXPECTF-- *** Testing ArrayObject::ksort() : basic functionality *** bool(true) -object(ArrayObject)#1 (1) { +object(ArrayObject)#%d (1) { ["storage":"ArrayObject":private]=> array(3) { [0]=> @@ -32,18 +34,34 @@ object(ArrayObject)#1 (1) { int(3) } } -bool(true) + +Warning: ksort() expects parameter 2 to be long, string given in %sarrayObject_ksort_basic1.php on line %d +bool(false) object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(4) { - ["a"]=> - int(2) ["b"]=> int(4) + ["a"]=> + int(2) ["q"]=> int(3) [99]=> string(1) "x" } } +bool(true) +object(ArrayObject)#%d (1) { + ["storage":"ArrayObject":private]=> + array(4) { + [99]=> + string(1) "x" + ["a"]=> + int(2) + ["b"]=> + int(4) + ["q"]=> + int(3) + } +} ===DONE=== diff --git a/ext/spl/tests/bug62328.phpt b/ext/spl/tests/bug62328.phpt new file mode 100644 index 0000000000..33a8aeee95 --- /dev/null +++ b/ext/spl/tests/bug62328.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #62328 (cast_object takes precedence over __toString) +--CREDITS-- +leight at gmail dot com +--FILE-- +<?php + +class SplFileInfo62328 extends SplFileInfo +{ + public function __toString() + { + return '__toString'; + } +} + +$fi = new SplFileInfo62328(__FILE__); + +echo (string)$fi . PHP_EOL; +echo (string)$fi->__toString() . PHP_EOL; + +?> +--EXPECT-- +__toString +__toString diff --git a/ext/spl/tests/bug62616.phpt b/ext/spl/tests/bug62616.phpt new file mode 100644 index 0000000000..4e4be94491 --- /dev/null +++ b/ext/spl/tests/bug62616.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault) +--FILE-- +<?php +$ai = new ArrayIterator(array(0,1)); + +var_dump($ai->count()); + +$ii = new IteratorIterator($ai); + +var_dump($ii->count()); +?> +--EXPECTF-- +int(2) +int(2) diff --git a/ext/spl/tests/bug62904.phpt b/ext/spl/tests/bug62904.phpt new file mode 100644 index 0000000000..7e392da9ab --- /dev/null +++ b/ext/spl/tests/bug62904.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #62904 (Crash when cloning an object which inherits SplFixedArray) +--FILE-- +<?php + +class foo extends SplFixedArray { + public function __construct($size) { + } +} + +$x = new foo(2); + +try { + $z = clone $x; +} catch (Exception $e) { + var_dump($e->getMessage()); +} +--EXPECTF-- +string(40) "The instance wasn't initialized properly" diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e6de34e5fd..72f1dc3c76 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5043,8 +5043,11 @@ void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ zend_hash_destroy(BG(user_shutdown_function_names)); FREE_HASHTABLE(BG(user_shutdown_function_names)); BG(user_shutdown_function_names) = NULL; - } - zend_end_try(); + } zend_catch { + /* maybe shutdown method call exit, we just ignore it */ + FREE_HASHTABLE(BG(user_shutdown_function_names)); + BG(user_shutdown_function_names) = NULL; + } zend_end_try(); } /* }}} */ diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 36568c508e..364f7fc399 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -39,6 +39,7 @@ #endif #endif +#include "php_syslog.h" #include "php_mail.h" #include "php_ini.h" #include "php_string.h" @@ -189,6 +190,37 @@ PHP_FUNCTION(mail) } /* }}} */ + +void php_mail_log_crlf_to_spaces(char *message) { + /* Find all instances of carriage returns or line feeds and + * replace them with spaces. Thus, a log line is always one line + * long + */ + char *p = message; + while ((p = strpbrk(p, "\r\n"))) { + *p = ' '; + } +} + +void php_mail_log_to_syslog(char *message) { + /* Write 'message' to syslog. */ +#ifdef HAVE_SYSLOG_H + php_syslog(LOG_NOTICE, "%s", message); +#endif +} + + +void php_mail_log_to_file(char *filename, char *message, size_t message_size TSRMLS_DC) { + /* Write 'message' to the given file. */ + uint flags = IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR; + php_stream *stream = php_stream_open_wrapper(filename, "a", flags, NULL); + if (stream) { + php_stream_write(stream, message, message_size); + php_stream_close(stream); + } +} + + /* {{{ php_mail */ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC) @@ -216,19 +248,22 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char if (mail_log && *mail_log) { char *tmp; int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); - php_stream *stream = php_stream_open_wrapper(mail_log, "a", IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR, NULL); - if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ - char *p = tmp; - while ((p = strpbrk(p, "\r\n"))) { - *p = ' '; - } - tmp[l - 1] = '\n'; + if (hdr) { + php_mail_log_crlf_to_spaces(tmp); } - if (stream) { - php_stream_write(stream, tmp, l); - php_stream_close(stream); + + if (!strcmp(mail_log, "syslog")) { + /* Drop the final space when logging to syslog. */ + tmp[l - 1] = 0; + php_mail_log_to_syslog(tmp); + } + else { + /* Convert the final space to a newline when logging to file. */ + tmp[l - 1] = '\n'; + php_mail_log_to_file(mail_log, tmp, l TSRMLS_CC); } + efree(tmp); } if (PG(mail_x_header)) { diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 1ce7eff052..4eb69d7ef2 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -162,7 +162,10 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t len lp = 0; } else { if (iscntrl (c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == ' ') && (*str == '\015'))) { - if ((lp += 3) > PHP_QPRINT_MAXL) { + if ((((lp+= 3) > PHP_QPRINT_MAXL) && (c <= 0x7f)) + || ((c > 0x7f) && (c <= 0xdf) && ((lp + 3) > PHP_QPRINT_MAXL)) + || ((c > 0xdf) && (c <= 0xef) && ((lp + 6) > PHP_QPRINT_MAXL)) + || ((c > 0xef) && (c <= 0xf4) && ((lp + 9) > PHP_QPRINT_MAXL))) { *d++ = '='; *d++ = '\015'; *d++ = '\012'; @@ -283,4 +286,4 @@ PHP_FUNCTION(quoted_printable_encode) * End: * vim600: sw=4 ts=4 fdm=marker * vim<600: sw=4 ts=4 - */ + */
\ No newline at end of file diff --git a/ext/standard/string.c b/ext/standard/string.c index 9a64376c27..9154b3296c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3930,7 +3930,6 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines) new_char_count--; } if (new_char_count > 0) { - char_count=new_char_count; begin=new_begin; } } diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt index 2dac21ec4b..0eb9dc519a 100644 --- a/ext/standard/tests/file/realpath_cache.phpt +++ b/ext/standard/tests/file/realpath_cache.phpt @@ -19,7 +19,7 @@ echo "Done\n"; int(%d) array(4) { ["key"]=> - %s(%s) + %s(%f) ["is_dir"]=> bool(true) ["realpath"]=> diff --git a/ext/standard/tests/general_functions/var_export_error2.phpt b/ext/standard/tests/general_functions/var_export_error2.phpt index 2b306696a6..a6403e610d 100644 --- a/ext/standard/tests/general_functions/var_export_error2.phpt +++ b/ext/standard/tests/general_functions/var_export_error2.phpt @@ -15,4 +15,5 @@ var_export($obj, true); ===DONE=== --EXPECTF-- -Fatal error: Nesting level too deep - recursive dependency? in %s on line 9
\ No newline at end of file +Warning: var_export does not handle circular references in %s on line 9 +===DONE=== diff --git a/ext/standard/tests/general_functions/var_export_error3.phpt b/ext/standard/tests/general_functions/var_export_error3.phpt index 03ed496aca..c862691e91 100644 --- a/ext/standard/tests/general_functions/var_export_error3.phpt +++ b/ext/standard/tests/general_functions/var_export_error3.phpt @@ -15,4 +15,5 @@ var_export($a, true); ===DONE=== --EXPECTF-- -Fatal error: Nesting level too deep - recursive dependency? in %s on line 9
\ No newline at end of file +Warning: var_export does not handle circular references in %s on line 9 +===DONE=== diff --git a/ext/standard/tests/serialize/bug62836_1.phpt b/ext/standard/tests/serialize/bug62836_1.phpt new file mode 100644 index 0000000000..7291046410 --- /dev/null +++ b/ext/standard/tests/serialize/bug62836_1.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #62836 (Seg fault or broken object references on unserialize()) +--FILE-- +<?php +$serialized_object='O:1:"A":4:{s:1:"b";O:1:"B":0:{}s:2:"b1";r:2;s:1:"c";O:1:"B":0:{}s:2:"c1";r:4;}'; +function __autoload($name) { + unserialize("i:4;"); + eval("class $name {} "); +} + +print_r(unserialize($serialized_object)); +echo "okey"; +?> +--EXPECT-- +A Object +( + [b] => B Object + ( + ) + + [b1] => B Object + ( + ) + + [c] => B Object + ( + ) + + [c1] => B Object + ( + ) + +) +okey diff --git a/ext/standard/tests/serialize/bug62836_2.phpt b/ext/standard/tests/serialize/bug62836_2.phpt new file mode 100644 index 0000000000..0634b1dac1 --- /dev/null +++ b/ext/standard/tests/serialize/bug62836_2.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #62836 (Seg fault or broken object references on unserialize()) +--FILE-- +<?php +$serialized_object='O:1:"A":4:{s:1:"b";O:1:"B":0:{}s:2:"b1";r:2;s:1:"c";O:1:"B":0:{}s:2:"c1";r:4;}'; + +ini_set('unserialize_callback_func','mycallback'); + +function mycallback($classname) { + unserialize("i:4;"); + eval ("class $classname {} "); +} + +print_r(unserialize($serialized_object)); +echo "okey"; +?> +--EXPECT-- +A Object +( + [b] => B Object + ( + ) + + [b1] => B Object + ( + ) + + [c] => B Object + ( + ) + + [c1] => B Object + ( + ) + +) +okey diff --git a/ext/standard/tests/streams/bug40459.phpt b/ext/standard/tests/streams/bug40459.phpt new file mode 100644 index 0000000000..8ee4363ed9 --- /dev/null +++ b/ext/standard/tests/streams/bug40459.phpt @@ -0,0 +1,103 @@ +--TEST-- +bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called +--FILE-- +<?php +// Test whether the constructor of the user-space stream wrapper is called when stream functions are called +class testwrapper { + private $constructorCalled = false; + function __construct() { + $this->constructorCalled = true; + } + + function stream_open($path, $mode, $options, &$opened_path) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return true; + } + + function url_stat($url, $flags) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return array(); + } + + function unlink($url) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function rename($from, $to) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function mkdir($dir, $mode, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function rmdir($dir, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function dir_opendir($url, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return TRUE; + } + function stream_metadata() + { + echo $this->constructorCalled ? 'yes' : 'no'; + return TRUE; + } +} + +stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL); + +echo 'stream_open: '; +fopen('test://test', 'r'); +echo "\n"; + +echo 'url_stat: '; +stat('test://test'); +echo "\n"; + +echo 'dir_opendir: '; +opendir('test://test'); +echo "\n"; + +echo 'rmdir: '; +rmdir('test://test'); +echo "\n"; + +echo 'mkdir: '; +mkdir('test://test'); +echo "\n"; + +echo 'rename: '; +rename('test://test', 'test://test2'); +echo "\n"; + +echo 'unlink: '; +unlink('test://test'); +echo "\n"; + +echo 'touch: '; +touch('test://test', time()); +echo "\n"; + + + +?> +==DONE== +--EXPECT-- +stream_open: yes +url_stat: yes +dir_opendir: yes +rmdir: yes +mkdir: yes +rename: yes +unlink: yes +touch: yes +==DONE== diff --git a/ext/standard/tests/streams/bug61115-1.phpt b/ext/standard/tests/streams/bug61115-1.phpt index 89374e7353..99e2f7929c 100644 --- a/ext/standard/tests/streams/bug61115-1.phpt +++ b/ext/standard/tests/streams/bug61115-1.phpt @@ -1,5 +1,11 @@ --TEST-- Bug #61115: Stream related segfault on fatal error in php_stream_context_del_link - variation 1 +--SKIPIF-- +<?php +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} +?> --FILE-- <?php diff --git a/ext/standard/tests/strings/bug62462.phpt b/ext/standard/tests/strings/bug62462.phpt new file mode 100644 index 0000000000..c6eb41a543 --- /dev/null +++ b/ext/standard/tests/strings/bug62462.phpt @@ -0,0 +1,17 @@ +--TEST-- +Multibyte characters shouldn't be split by soft line break added by quoted_printable_encode - 4 byte character test +--FILE-- +<?php +echo quoted_printable_encode(str_repeat("\xc4\x85", 77)); +?> + +==DONE== +--EXPECT-- +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85= +=C4=85=C4=85=C4=85=C4=85=C4=85 +==DONE== diff --git a/ext/standard/tests/strings/quoted_printable_encode_002.phpt b/ext/standard/tests/strings/quoted_printable_encode_002.phpt Binary files differindex 5380eb0bff..aaf5608f33 100644 --- a/ext/standard/tests/strings/quoted_printable_encode_002.phpt +++ b/ext/standard/tests/strings/quoted_printable_encode_002.phpt diff --git a/ext/standard/tests/strings/str_pad_variation5.phpt b/ext/standard/tests/strings/str_pad_variation5.phpt index 4b300c4717..cd979a1c8b 100644 --- a/ext/standard/tests/strings/str_pad_variation5.phpt +++ b/ext/standard/tests/strings/str_pad_variation5.phpt @@ -5,6 +5,9 @@ memory_limit=128M --SKIPIF-- <?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --FILE-- <?php diff --git a/ext/standard/tests/url/parse_url_relative_scheme.phpt b/ext/standard/tests/url/parse_url_relative_scheme.phpt new file mode 100644 index 0000000000..7c8952db71 --- /dev/null +++ b/ext/standard/tests/url/parse_url_relative_scheme.phpt @@ -0,0 +1,11 @@ +--TEST-- +Test parse_url() function: Checks relative URL schemes (e.g. "//example.com") +--FILE-- +<?php +var_dump(parse_url('//example.org')); +--EXPECT-- +array(1) { + ["host"]=> + string(11) "example.org" +} + diff --git a/ext/standard/url.c b/ext/standard/url.c index 8489f42091..44a568032b 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -204,6 +204,8 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) } else { goto just_path; } + } else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */ + s += 2; } else { just_path: ue = s + length; @@ -220,14 +222,14 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) if (query && fragment) { if (query > fragment) { - p = e = fragment; + e = fragment; } else { - p = e = query; + e = query; } } else if (query) { - p = e = query; + e = query; } else if (fragment) { - p = e = fragment; + e = fragment; } } else { e = p; diff --git a/ext/standard/var.c b/ext/standard/var.c index 735d0a7cbb..494fb583c7 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -453,6 +453,11 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC) break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); + if(myht && myht->nApplyCount > 0){ + smart_str_appendl(buf, "NULL", 4); + zend_error(E_WARNING, "var_export does not handle circular references"); + return; + } if (level > 1) { smart_str_appendc(buf, '\n'); buffer_append_spaces(buf, level - 1); @@ -469,6 +474,11 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC) case IS_OBJECT: myht = Z_OBJPROP_PP(struc); + if(myht && myht->nApplyCount > 0){ + smart_str_appendl(buf, "NULL", 4); + zend_error(E_WARNING, "var_export does not handle circular references"); + return; + } if (level > 1) { smart_str_appendc(buf, '\n'); buffer_append_spaces(buf, level - 1); diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index e1ac636d04..2537c5213b 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -620,10 +620,13 @@ yy20: do { /* Try to find class directly */ + BG(serialize_lock) = 1; if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { + BG(serialize_lock) = 0; ce = *pce; break; } + BG(serialize_lock) = 0; /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { @@ -638,7 +641,9 @@ yy20: args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); + BG(serialize_lock) = 1; if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { + BG(serialize_lock) = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; @@ -646,6 +651,7 @@ yy20: zval_ptr_dtor(&arg_func_name); break; } + BG(serialize_lock) = 0; if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } diff --git a/ext/xml/tests/bug62328.phpt b/ext/xml/tests/bug62328.phpt new file mode 100644 index 0000000000..e4c3c59d37 --- /dev/null +++ b/ext/xml/tests/bug62328.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #62328 (implementing __toString and a cast to string fails) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php +class UberSimpleXML extends SimpleXMLElement { + public function __toString() { + return 'stringification'; + } +} + +$xml = new UberSimpleXML('<xml/>'); + +var_dump((string) $xml); +var_dump($xml->__toString()); +--EXPECT-- +string(15) "stringification" +string(15) "stringification" diff --git a/ext/xmlrpc/tests/bug61264.phpt b/ext/xmlrpc/tests/bug61264.phpt index b1da27f252..24e4b2749c 100644 --- a/ext/xmlrpc/tests/bug61264.phpt +++ b/ext/xmlrpc/tests/bug61264.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #61264: xmlrpc_parse_method_descriptions leaks temporary variable +--SKIPIF-- +<?php if (!extension_loaded("xmlrpc")) print "skip"; ?> --FILE-- <?php $xml = <<<XML diff --git a/ext/zip/tests/bug51353.phpt b/ext/zip/tests/bug51353.phpt new file mode 100644 index 0000000000..560945f9dd --- /dev/null +++ b/ext/zip/tests/bug51353.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #51353 ZIP64 problem, archive with 100000 items +--SKIPIF-- +<?php +if(!extension_loaded('zip')) die('skip'); +die('skip the test might get very long, activate it manually'); +--FILE-- +<?php +/* This test might get very long depending on the mashine it's running on. Therefore +adding an explicit skip, remove it to run this test. */ +set_time_limit(0); + +$base_path = dirname(__FILE__); + +/* Either we ship a file with 100000 entries which would be >12M big, + or create it dynamically. */ +$zip = new ZipArchive; +$r = $zip->open("$base_path/51353.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); +if ($r) { + for ($i = 0; $i < 100000; $i++) { + $zip->addFromString("$i.txt", '1'); + } + $zip->close(); +} else { + die("failed"); +} + +$zip = new ZipArchive; +$r = $zip->open("$base_path/51353.zip"); +if ($r) { + $zip->extractTo("$base_path/51353_unpack"); + $zip->close(); + + $a = glob("$base_path/51353_unpack/*.txt"); + echo count($a) . "\n"; +} else { + die("failed"); +} + +echo "OK"; +--CLEAN-- +<?php +$base_path = dirname(__FILE__); + +unlink("$base_path/51353.zip"); + +$a = glob("$base_path/51353_unpack/*.txt"); +foreach($a as $f) { + unlink($f); +} +rmdir("$base_path/51353_unpack"); +--EXPECT-- +100000 +OK diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 3d8c90cbf5..e895e0e482 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -54,6 +54,8 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) long output_compression_level; char *output_handler; php_zlib_context *ob_gzhandler; + long output_compression_default; + zend_bool handler_registered; ZEND_END_MODULE_GLOBALS(zlib); php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt Binary files differnew file mode 100644 index 0000000000..ca4214a46f --- /dev/null +++ b/ext/zlib/tests/bug55544.phpt diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index c6e2e0cf8b..7ff2b30c4c 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -263,6 +263,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name ZLIBG(output_compression) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE; } + ZLIBG(handler_registered) = 1; + if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { php_output_handler_set_context(h, php_zlib_output_handler_context_init(TSRMLS_C), php_zlib_output_handler_context_dtor TSRMLS_CC); } @@ -690,6 +692,7 @@ PHP_ZLIB_ENCODE_FUNC(zlib_encode, 0); /* {{{ proto binary zlib_decode(binary data[, int max_decoded_len]) Uncompress any raw/gzip/zlib encoded data */ PHP_ZLIB_DECODE_FUNC(zlib_decode, PHP_ZLIB_ENCODING_ANY); +/* }}} */ /* NOTE: The naming of these userland functions was quite unlucky */ /* {{{ proto binary gzdeflate(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_RAW]) @@ -701,18 +704,22 @@ PHP_ZLIB_ENCODE_FUNC(gzdeflate, PHP_ZLIB_ENCODING_RAW); Encode data with the gzip encoding */ PHP_ZLIB_ENCODE_FUNC(gzencode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ + /* {{{ proto binary gzcompress(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_DEFLATE]) Encode data with the zlib encoding */ PHP_ZLIB_ENCODE_FUNC(gzcompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ + /* {{{ proto binary gzinflate(binary data[, int max_decoded_len]) Decode raw deflate encoded data */ PHP_ZLIB_DECODE_FUNC(gzinflate, PHP_ZLIB_ENCODING_RAW); /* }}} */ + /* {{{ proto binary gzdecode(binary data[, int max_decoded_len]) Decode gzip encoded data */ PHP_ZLIB_DECODE_FUNC(gzdecode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ + /* {{{ proto binary gzuncompress(binary data[, int max_decoded_len]) Decode zlib encoded data */ PHP_ZLIB_DECODE_FUNC(gzuncompress, PHP_ZLIB_ENCODING_DEFLATE); @@ -890,6 +897,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) status = OnUpdateLong(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + ZLIBG(output_compression) = ZLIBG(output_compression_default); if (stage == PHP_INI_STAGE_RUNTIME && int_value) { if (!php_output_handler_started(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME) TSRMLS_CC)) { php_zlib_output_compression_start(TSRMLS_C); @@ -914,7 +922,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_handler) /* {{{ INI */ PHP_INI_BEGIN() - STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL, OnUpdate_zlib_output_compression, output_compression, zend_zlib_globals, zlib_globals) + STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL, OnUpdate_zlib_output_compression, output_compression_default, zend_zlib_globals, zlib_globals) STD_PHP_INI_ENTRY("zlib.output_compression_level", "-1", PHP_INI_ALL, OnUpdateLong, output_compression_level, zend_zlib_globals, zlib_globals) STD_PHP_INI_ENTRY("zlib.output_handler", "", PHP_INI_ALL, OnUpdate_zlib_output_handler, output_handler, zend_zlib_globals, zlib_globals) PHP_INI_END() @@ -958,19 +966,24 @@ static PHP_MSHUTDOWN_FUNCTION(zlib) static PHP_RINIT_FUNCTION(zlib) { ZLIBG(compression_coding) = 0; - - php_zlib_output_compression_start(TSRMLS_C); + if (!ZLIBG(handler_registered)) { + ZLIBG(output_compression) = ZLIBG(output_compression_default); + php_zlib_output_compression_start(TSRMLS_C); + } return SUCCESS; } /* }}} */ +/* {{{ PHP_RSHUTDOWN_FUNCTION */ static PHP_RSHUTDOWN_FUNCTION(zlib) { php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C); + ZLIBG(handler_registered) = 0; return SUCCESS; } +/* }}} */ /* {{{ PHP_MINFO_FUNCTION */ static PHP_MINFO_FUNCTION(zlib) @@ -991,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib) static ZEND_MODULE_GLOBALS_CTOR_D(zlib) { zlib_globals->ob_gzhandler = NULL; + zlib_globals->handler_registered = 0; } /* }}} */ |
