diff options
64 files changed, 481 insertions, 366 deletions
@@ -1,10 +1,26 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 2012, PHP 5.4.6 + +- CURL: + . Fixed bug #62499 (curl_setopt($ch, CURLOPT_COOKIEFILE, "") returns false). + (r.hampartsumyan@gmail.com, Laruence) + +- DateTime: + . Fixed Bug #62500 (Segfault in DateInterval class when extended). (Laruence) + +- SimpleXML: + . Implemented FR #55218 Get namespaces from current node. (Lonny) + ?? ??? 2012, PHP 5.4.5 - Core: . Fixed bug #62443 (Crypt SHA256/512 Segfaults With Malformed Salt). (Anthony Ferrara) + . Fixed bug #62432 (ReflectionMethod random corrupt memory on high + concurrent). (Johannes) + . Fixed bug #62373 (serialize() generates wrong reference to the object). + (Moriyoshi) . Fixed bug #62357 (compile failure: (S) Arguments missing for built-in function __memcmp). (Laruence) . Fixed bug #61998 (Using traits with method aliases appears to result in @@ -46,11 +62,18 @@ PHP NEWS . Fixed bug #62070 (Collator::getSortKey() returns garbage). (Gustavo) . Fixed bug #62017 (datefmt_create with incorrectly encoded timezone leaks pattern). (Gustavo) + . Fixed bug #60785 (memory leak in IntlDateFormatter constructor). (Gustavo) + +- JSON: + . Fixed bug #61359 (json_encode() calls too many reallocs). (Stas) - libxml: . Fixed bug #62266 (Custom extension segfaults during xmlParseFile with FPM SAPI). (Gustavo) +- Phar: + . Fixed bug #62227 (Invalid phar stream path causes crash). (Felipe) + - Readline: . Fixed bug #62186 (readline fails to compile - void function should not return a value). (Johannes) @@ -64,6 +87,12 @@ PHP NEWS - Sockets: . Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe) +- SPL: + . Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to + dot files). (Laruence) + . Fixed bug #62262 (RecursiveArrayIterator does not implement Countable). + (Nikita Popov) + - XML Writer: . Fixed bug #62064 (memory leak in the XML Writer module). (jean-pierre dot lozi at lip6 dot fr) @@ -85,10 +114,6 @@ PHP NEWS . Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi). (Laruence, reeze.xia@gmail.com) -- CURL: - . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction). - (Laruence) - - Core: . Fixed missing bound check in iptcparse(). (chris at chiappa.net) . Fixed CVE-2012-2143. (Solar Designer) @@ -103,12 +128,15 @@ PHP NEWS . Fixed bug #61827 (incorrect \e processing on Windows) (Anatoliy) . Fixed bug #61782 (__clone/__destruct do not match other methods when checking access controls). (Stas) + . Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo) . Fixed bug #61761 ('Overriding' a private static method with a different signature causes crash). (Laruence) . Fixed bug #61730 (Segfault from array_walk modifying an array passed by reference). (Laruence) . Fixed bug #61728 (PHP crash when calling ob_start in request_shutdown phase). (Laruence) + . Fixed bug #61713 (Logic error in charset detection for htmlentities). + (Anatoliy) . Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov) . Fixed bug #61650 (ini parser crashes when using ${xxxx} ini variables (without apache2)). (Laruence) @@ -118,15 +146,9 @@ PHP NEWS set to null). (Anatoliy) . Changed php://fd to be available only for CLI. -- PDO: - . Fixed bug #61755 (A parsing bug in the prepared statements can lead to - access violations). (Johannes) - -- Phar: - . Fix bug #61065 (Secunia SA44335, CVE-2012-2386). (Rasmus) - -- Pgsql: - . Added pg_escape_identifier/pg_escape_literal. (Yasuo Ohgaki) +- CURL: + . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction). + (Laruence) - Fileinfo . Fixed bug #61812 (Uninitialised value used in libmagic). @@ -144,6 +166,20 @@ PHP NEWS . Fixed bug #61617 (Libxml tests failed(ht is already destroyed)). (Laruence) +- PDO: + . Fixed bug #61755 (A parsing bug in the prepared statements can lead to + access violations). (Johannes) + +- Phar: + . Fixed bug #61065 (Secunia SA44335, CVE-2012-2386). (Rasmus) + +- Pgsql: + . Added pg_escape_identifier/pg_escape_literal. (Yasuo Ohgaki) + +- Streams: + . Fixed bug #61961 (file_get_contents leaks when access empty file with + maxlen set). (Reeze) + - Zlib: . Fixed bug #61820 (using ob_gzhandler will complain about headers already sent when no compression). (Mike) @@ -232,23 +268,6 @@ PHP NEWS . Fixed bug #60948 (mysqlnd FTBFS when -Wformat-security is enabled). (Johannes) -- Readline: - . Fixed bug #61088 (Memory leak in readline_callback_handler_install). - (Nikic, Laruence) - -- Session - . Fixed bug #60634 (Segmentation fault when trying to die() in - SessionHandler::write()). (Ilia) - -- SOAP - . Fixed bug #61423 (gzip compression fails). (Ilia) - . Fixed bug #60887 (SoapClient ignores user_agent option and sends no - User-Agent header). (carloschilazo at gmail dot com) - . Fixed bug #60842, #51775 (Chunked response parsing error when - chunksize length line is > 10 bytes). (Ilia) - . Fixed bug #49853 (Soap Client stream context header option ignored). - (Dmitry) - - PDO . Fixed bug #61292 (Segfault while calling a method on an overloaded PDO object). (Laruence) @@ -266,12 +285,29 @@ PHP NEWS . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL bytes). (Nikita Popov) +- Readline: + . Fixed bug #61088 (Memory leak in readline_callback_handler_install). + (Nikic, Laruence) + - Reflection: . Implemented FR #61602 (Allow access to the name of constant used as function/method parameter's default value). (reeze.xia@gmail.com) . Fixed bug #60968 (Late static binding doesn't work with ReflectionMethod::invokeArgs()). (Laruence) +- Session + . Fixed bug #60634 (Segmentation fault when trying to die() in + SessionHandler::write()). (Ilia) + +- SOAP + . Fixed bug #61423 (gzip compression fails). (Ilia) + . Fixed bug #60887 (SoapClient ignores user_agent option and sends no + User-Agent header). (carloschilazo at gmail dot com) + . Fixed bug #60842, #51775 (Chunked response parsing error when + chunksize length line is > 10 bytes). (Ilia) + . Fixed bug #49853 (Soap Client stream context header option ignored). + (Dmitry) + - SPL: . Fixed bug #61453 (SplObjectStorage does not identify objects correctly). (Gustavo) @@ -728,6 +764,65 @@ PHP NEWS . Fixed bug #55544 (ob_gzhandler always conflicts with zlib.output_compression). (Mike) +14 Jun 2012, PHP 5.3.14 + +- CLI SAPI: + . Fixed bug #61546 (functions related to current script failed when chdir() + in cli sapi). (Laruence, reeze.xia@gmail.com) + +- CURL: + . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction). + (Laruence) + +- COM: + . Fixed bug #62146 com_dotnet cannot be built shared. (Johannes) + +- Core: + . Fixed CVE-2012-2143. (Solar Designer) + . Fixed missing bound check in iptcparse(). (chris at chiappa.net) + . Fixed bug #62373 (serialize() generates wrong reference to the object). + (Moriyoshi) + . Fixed bug #62005 (unexpected behavior when incrementally assigning to a + member of a null object). (Laruence) + . Fixed bug #61991 (long overflow in realpath_cache_get()). (Anatoliy) + . Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo) + . Fixed bug #61730 (Segfault from array_walk modifying an array passed by + reference). (Laruence) + . Fixed bug #61713 (Logic error in charset detection for htmlentities). + (Anatoliy) + . Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename + set to null). (Anatoliy) + . Changed php://fd to be available only for CLI. + +- Fileinfo: + . Fixed bug #61812 (Uninitialised value used in libmagic). + (Laruence, Gustavo) + +- Iconv extension: + . Fixed a bug that iconv extension fails to link to the correct library + when another extension makes use of a library that links to the iconv + library. See https://bugs.gentoo.org/show_bug.cgi?id=364139 for detail. + (Moriyoshi) + +- Intl: + . Fixed bug #62082 (Memory corruption in internal function + get_icu_disp_value_src_php()). (Gustavo) + +- JSON + . Fixed bug #61537 (json_encode() incorrectly truncates/discards + information). (Adam) + +- PDO: + . Fixed bug #61755 (A parsing bug in the prepared statements can lead to + access violations). (Johannes) + +- Phar: + . Fix bug #61065 (Secunia SA44335). (Rasmus) + +- Streams: + . Fixed bug #61961 (file_get_contents leaks when access empty file with + maxlen set). (Reeze) + 08 May 2012, PHP 5.3.13 - CGI . Improve fix for PHP-CGI query string parameter vulnerability, CVE-2012-2311. @@ -343,6 +343,10 @@ PHP 5.4 UPGRADE NOTES - Since 5.4.5, resourcebundle_create() accepts null for the first two arguments. +- Since 5.4.6, SimpleXMLElement::getDocNamespaces() has and extra parameter which + allows for toggling if the list of namespaces starts from the document root + or from the node you call the method on + ============================== 5. Changes to existing classes ============================== diff --git a/Zend/tests/bug39018.phpt b/Zend/tests/bug39018.phpt index e1968ad041..32566ba864 100644 --- a/Zend/tests/bug39018.phpt +++ b/Zend/tests/bug39018.phpt @@ -62,17 +62,17 @@ print "\nDone\n"; ?> --EXPECTF-- -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d Notice: Uninitialized string offset: 0 in %s on line %d Notice: Uninitialized string offset: 0 in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d Notice: Uninitialized string offset: %i in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d Notice: Uninitialized string offset: %i in %s on line %d @@ -88,16 +88,16 @@ Notice: Uninitialized string offset: 4 in %s on line %d Notice: Uninitialized string offset: 4 in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d Notice: Uninitialized string offset: 12 in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d Notice: Uninitialized string offset: 12 in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d b Done diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 34604d6347..f7cb81bb20 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -30,10 +30,10 @@ echo "Done\n"; --EXPECTF-- string(1) "i" -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d string(1) "S" -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d string(1) "S" Warning: Illegal string offset 'run away' in %s on line %d @@ -46,10 +46,10 @@ string(1) "o" Notice: A non well formed numeric value encountered in %s on line %d string(1) "r" -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d string(1) "i" -Notice: String offset cast occured in %s on line %d +Notice: String offset cast occurred in %s on line %d string(1) "S" Warning: Illegal offset type in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cca7c1976e..841e1b9316 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3712,7 +3712,7 @@ static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args } else { /* Add it to result function table */ if (zend_hash_quick_add(resulting_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_COMPILE_ERROR, "Trait method %s has not been applied, because failure occured during updating resulting trait method table", fn->common.function_name); + zend_error(E_COMPILE_ERROR, "Trait method %s has not been applied, because failure occurred during updating resulting trait method table", fn->common.function_name); } } @@ -3829,7 +3829,7 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int function_add_ref(&fn_copy); if (zend_hash_quick_update(&ce->function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, &fn_copy, sizeof(zend_function), (void**)&fn_copy_p)==FAILURE) { - zend_error(E_COMPILE_ERROR, "Trait method %s has not been applied, because failure occured during updating class method table", hash_key->arKey); + zend_error(E_COMPILE_ERROR, "Trait method %s has not been applied, because failure occurred during updating class method table", hash_key->arKey); } zend_add_magic_methods(ce, hash_key->arKey, hash_key->nKeyLength, fn_copy_p TSRMLS_CC); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 205531fd28..fbc73258c7 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1161,7 +1161,7 @@ convert_to_array: case IS_DOUBLE: case IS_NULL: case IS_BOOL: - zend_error(E_NOTICE, "String offset cast occured"); + zend_error(E_NOTICE, "String offset cast occurred"); break; default: zend_error(E_WARNING, "Illegal offset type"); @@ -1284,7 +1284,7 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont case IS_NULL: case IS_BOOL: if (type != BP_VAR_IS) { - zend_error(E_NOTICE, "String offset cast occured"); + zend_error(E_NOTICE, "String offset cast occurred"); } break; default: diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 84ca1de345..1bd64394ac 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -330,7 +330,7 @@ END_EXTERN_C() if (idx-1 > LONG_MAX) { /* overflow */ \ break; \ } \ - idx = (ulong)(-(long)idx); \ + idx = 0 - idx; \ } else if (idx > LONG_MAX) { /* overflow */ \ break; \ } \ diff --git a/ext/curl/interface.c b/ext/curl/interface.c index b03f346b59..d7d5c51c4d 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2177,7 +2177,7 @@ string_copy: convert_to_string_ex(zvalue); - if (!Z_STRLEN_PP(zvalue) || php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { + if (Z_STRLEN_PP(zvalue) && php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { RETVAL_FALSE; return 1; } diff --git a/ext/curl/tests/bug61948.phpt b/ext/curl/tests/bug61948.phpt index 23bbda7d5f..00df07d73e 100644 --- a/ext/curl/tests/bug61948.phpt +++ b/ext/curl/tests/bug61948.phpt @@ -16,7 +16,7 @@ open_basedir="/tmp" curl_close($ch); ?> --EXPECTF-- -bool(false) +bool(true) bool(true) Warning: curl_setopt(): open_basedir restriction in effect. File(/xxx/bar) is not within the allowed path(s): (/tmp) in %sbug61948.php on line %d diff --git a/ext/date/php_date.c b/ext/date/php_date.c index cd48de2731..13e7b753d3 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3430,10 +3430,19 @@ zval *date_interval_read_property(zval *object, zval *member, int type, const ze zval_copy_ctor(&tmp_member); convert_to_string(&tmp_member); member = &tmp_member; + key = NULL; } obj = (php_interval_obj *)zend_objects_get_address(object TSRMLS_CC); + if (!obj->initialized) { + retval = (zend_get_std_object_handlers())->read_property(object, member, type, key TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; + } + #define GET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ value = obj->diff->n; \ @@ -3482,9 +3491,19 @@ void date_interval_write_property(zval *object, zval *member, zval *value, const zval_copy_ctor(&tmp_member); convert_to_string(&tmp_member); member = &tmp_member; + key = NULL; } + obj = (php_interval_obj *)zend_objects_get_address(object TSRMLS_CC); + if (!obj->initialized) { + (zend_get_std_object_handlers())->write_property(object, member, value, key TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + return; + } + #define SET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ if (value->type != IS_LONG) { \ diff --git a/ext/date/tests/bug62500.phpt b/ext/date/tests/bug62500.phpt new file mode 100644 index 0000000000..6952332014 --- /dev/null +++ b/ext/date/tests/bug62500.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #62500 (Segfault in DateInterval class when extended) +--INI-- +date.timezone=GMT +--FILE-- +<?php +class Crasher extends DateInterval { + public $foo; + public function __construct($time_spec) { + var_dump($this->foo); + $this->foo = 3; + var_dump($this->foo); + var_dump($this->{2}); + parent::__construct($time_spec); + } +} +try { + $c = new Crasher('blah'); +} catch (Exception $e) { + var_dump($e->getMessage()); +} +--EXPECTF-- +NULL +int(3) + +Notice: Undefined property: Crasher::$2 in %sbug62500.php on line %d +NULL +string(%s) "DateInterval::__construct(): Unknown or bad format (blah)" diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index dd98511e9c..70e7aff690 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -216,7 +216,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, if (Z_TYPE(handler) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler)); } - /* retval is == NULL, when an exception occured, don't report anything, because PHP itself will handle that */ + /* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */ } else if (retval == NULL) { } else { if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) { diff --git a/ext/imap/tests/imap_errors_basic.phpt b/ext/imap/tests/imap_errors_basic.phpt index 9d2ca30ece..91be3286aa 100644 --- a/ext/imap/tests/imap_errors_basic.phpt +++ b/ext/imap/tests/imap_errors_basic.phpt @@ -7,7 +7,7 @@ require_once(dirname(__FILE__).'/skipif.inc'); --FILE-- <?php /* Prototype : array imap_errors ( void ) - * Description: Returns all of the IMAP errors that have occured. + * Description: Returns all of the IMAP errors that have occurred. * Source code: ext/imap/php_imap.c */ diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.c index 24ded0c9fb..a0ee7c145f 100755 --- a/ext/intl/common/common_error.c +++ b/ext/intl/common/common_error.c @@ -24,7 +24,7 @@ #include "common_error.h" /* {{{ proto int intl_get_error_code() - * Get code of the last occured error. + * Get code of the last occurred error. */ PHP_FUNCTION( intl_get_error_code ) { @@ -33,7 +33,7 @@ PHP_FUNCTION( intl_get_error_code ) /* }}} */ /* {{{ proto string intl_get_error_message() - * Get text description of the last occured error. + * Get text description of the last occurred error. */ PHP_FUNCTION( intl_get_error_message ) { diff --git a/ext/intl/doc/collator_api.php b/ext/intl/doc/collator_api.php index 5428783750..ef7250243b 100755 --- a/ext/intl/doc/collator_api.php +++ b/ext/intl/doc/collator_api.php @@ -116,7 +116,7 @@ class Collator { /** * Return error text for the last ICU operation. * - * @return string Description of an error occured in the last + * @return string Description of an error occurred in the last * Collator method call. */ public function getErrorMessage() {} @@ -236,7 +236,7 @@ class Collator { * * @return string Real locale name from which the * collation data comes. If the collator - * was instantiated from rules or an error occured, + * was instantiated from rules or an error occurred, * returns false. */ public function getLocale( $type ) {} @@ -331,7 +331,7 @@ function collator_sort_with_sort_keys( $coll, $arr ) {} * * @return string Real locale name from which the * collation data comes. If the collator - * was instantiated from rules or an error occured, + * was instantiated from rules or an error occurred, * returns false. */ function collator_get_locale( $coll, $type ) {} @@ -391,7 +391,7 @@ function collator_get_error_code( $coll ) {} * * @param Collator $coll Collator object. * - * @return string Description of an error occured in the last + * @return string Description of an error occurred in the last * Collator API function call. */ function collator_get_error_message( $coll ) {} diff --git a/ext/intl/doc/common_api.php b/ext/intl/doc/common_api.php index ce2329fe3b..993dab180b 100755 --- a/ext/intl/doc/common_api.php +++ b/ext/intl/doc/common_api.php @@ -1,7 +1,7 @@ <?php /** - * Handling of errors occured in static methods + * Handling of errors occurred in static methods * when there's no object to get error code/message from. * * Example #1: @@ -29,7 +29,7 @@ function intl_get_error_code() {} /** * Get description of the last error. * - * @return string Description of an error occured in the last + * @return string Description of an error occurred in the last * API function call. */ function intl_get_error_message() {} diff --git a/ext/intl/doc/datefmt_api.php b/ext/intl/doc/datefmt_api.php index 0c5002e281..272abdb57c 100755 --- a/ext/intl/doc/datefmt_api.php +++ b/ext/intl/doc/datefmt_api.php @@ -215,7 +215,7 @@ class DateFormatter { /** * Sets the pattern to use * @param string $pattern new pattern string to use - * @return boolean 'true' if successful, 'false' if an error occured. Bad format + * @return boolean 'true' if successful, 'false' if an error occurred. Bad format * strings are usually the cause of the latter. */ public function setPattern($pattern) {} @@ -410,7 +410,7 @@ class DateFormatter { * Sets the pattern to use * @param DateFormatter $fmt The date formatter resource * @param string $pattern new pattern string to use - * @return boolean 'true' if successful, 'false' if an error occured. Bad format + * @return boolean 'true' if successful, 'false' if an error occurred. Bad format * strings are usually the cause of the latter. */ function datefmt_set_pattern($fmt , $pattern) {} diff --git a/ext/intl/doc/formatter_api.php b/ext/intl/doc/formatter_api.php index 754b16c62f..14d98db66a 100755 --- a/ext/intl/doc/formatter_api.php +++ b/ext/intl/doc/formatter_api.php @@ -317,7 +317,7 @@ class NumberFormatter { /** * Get the error text from the last operation. * - * @return string Description of the last occured error. + * @return string Description of the last occurred error. */ public public function getErrorMessage() {} @@ -495,6 +495,6 @@ function numfmt_get_error_code($formatter) {} * Get the error text from the last operation. * * @param NumberFormatter $formatter The formatter resource - * @return string Description of the last occured error. + * @return string Description of the last occurred error. */ function numfmt_get_error_message($formatter) {} diff --git a/ext/intl/doc/msgfmt_api.php b/ext/intl/doc/msgfmt_api.php index 5d178f1273..e4d047b979 100755 --- a/ext/intl/doc/msgfmt_api.php +++ b/ext/intl/doc/msgfmt_api.php @@ -54,7 +54,7 @@ class MessageFormatter { * @param string $locale the locale to use when formatting numbers and dates and suchlike * @param string $pattern the pattern string to insert things into * @param array $args the array of values to insert into $pattern - * @return string the formatted pattern string or false if an error occured + * @return string the formatted pattern string or false if an error occurred */ public static function formatMessage($locale, $pattern, $args) {} @@ -148,7 +148,7 @@ class MessageFormatter { * @param string $locale the locale to use when formatting numbers and dates and suchlike * @param string $pattern the pattern string to insert things into * @param array $args the array of values to insert into $pattern - * @return string the formatted pattern string or false if an error occured + * @return string the formatted pattern string or false if an error occurred */ function msgfmt_format_message($locale, $pattern, $args) {} diff --git a/ext/intl/intl_convert.c b/ext/intl/intl_convert.c index 33f1730625..92cdc4cef4 100755 --- a/ext/intl/intl_convert.c +++ b/ext/intl/intl_convert.c @@ -67,7 +67,7 @@ void intl_convert_utf8_to_utf16( return; } - /* Bail out if an unexpected error occured. + /* Bail out if an unexpected error occurred. * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough). * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty). */ @@ -119,7 +119,7 @@ void intl_convert_utf16_to_utf8( *status = U_ZERO_ERROR; u_strToUTF8( NULL, 0, &dst_len, src, src_len, status ); - /* Bail out if an unexpected error occured. + /* Bail out if an unexpected error occurred. * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough). * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty). */ diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index 466ab97e12..f46285e9d9 100755 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c @@ -110,7 +110,7 @@ PHP_FUNCTION( normalizer_normalize ) /* normalize */ size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status); - /* Bail out if an unexpected error occured. + /* Bail out if an unexpected error occurred. * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough). * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty). */ @@ -133,7 +133,7 @@ PHP_FUNCTION( normalizer_normalize ) /* try normalize again */ size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status); - /* Bail out if an unexpected error occured. */ + /* Bail out if an unexpected error occurred. */ if( U_FAILURE(status) ) { /* Set error messages. */ intl_error_set_custom_msg( NULL,"Error normalizing string", 0 TSRMLS_CC ); @@ -234,7 +234,7 @@ PHP_FUNCTION( normalizer_is_normalized ) efree( uinput ); - /* Bail out if an unexpected error occured. */ + /* Bail out if an unexpected error occurred. */ if( U_FAILURE(status) ) { /* Set error messages. */ intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 0 TSRMLS_CC ); diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt index c7b3972709..acb683e894 100755 --- a/ext/intl/tests/formatter_get_error.phpt +++ b/ext/intl/tests/formatter_get_error.phpt @@ -19,7 +19,7 @@ function ut_main() if( $num === false ) return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n"; else - return "Ooops, an error should have occured."; + return "Ooops, an error should have occurred."; } include_once( 'ut_common.inc' ); diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 8671765b4d..541664b8c6 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -25,10 +25,7 @@ enum error_codes { PHP_JSON_ERROR_STATE_MISMATCH, PHP_JSON_ERROR_CTRL_CHAR, PHP_JSON_ERROR_SYNTAX, - PHP_JSON_ERROR_UTF8, - PHP_JSON_ERROR_RECURSION, - PHP_JSON_ERROR_INF_OR_NAN, - PHP_JSON_ERROR_UNSUPPORTED_TYPE + PHP_JSON_ERROR_UTF8 }; extern JSON_parser new_JSON_parser(int depth); diff --git a/ext/json/json.c b/ext/json/json.c index b467079610..786b21ac91 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -35,7 +35,6 @@ static PHP_MINFO_FUNCTION(json); static PHP_FUNCTION(json_encode); static PHP_FUNCTION(json_decode); static PHP_FUNCTION(json_last_error); -static PHP_FUNCTION(json_last_error_msg); static const char digits[] = "0123456789abcdef"; @@ -58,9 +57,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_json_last_error, 0) ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_json_last_error_msg, 0) -ZEND_END_ARG_INFO() /* }}} */ /* {{{ json_functions[] */ @@ -68,7 +64,6 @@ static const zend_function_entry json_functions[] = { PHP_FE(json_encode, arginfo_json_encode) PHP_FE(json_decode, arginfo_json_decode) PHP_FE(json_last_error, arginfo_json_last_error) - PHP_FE(json_last_error_msg, arginfo_json_last_error_msg) PHP_FE_END }; /* }}} */ @@ -101,7 +96,6 @@ static PHP_MINIT_FUNCTION(json) REGISTER_LONG_CONSTANT("JSON_UNESCAPED_SLASHES", PHP_JSON_UNESCAPED_SLASHES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_PRETTY_PRINT", PHP_JSON_PRETTY_PRINT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_NONE", PHP_JSON_ERROR_NONE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_DEPTH", PHP_JSON_ERROR_DEPTH, CONST_CS | CONST_PERSISTENT); @@ -109,9 +103,6 @@ static PHP_MINIT_FUNCTION(json) REGISTER_LONG_CONSTANT("JSON_ERROR_CTRL_CHAR", PHP_JSON_ERROR_CTRL_CHAR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_SYNTAX", PHP_JSON_ERROR_SYNTAX, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_UTF8", PHP_JSON_ERROR_UTF8, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("JSON_ERROR_RECURSION", PHP_JSON_ERROR_RECURSION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("JSON_ERROR_INF_OR_NAN", PHP_JSON_ERROR_INF_OR_NAN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("JSON_ERROR_UNSUPPORTED_TYPE", PHP_JSON_ERROR_UNSUPPORTED_TYPE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_BIGINT_AS_STRING", PHP_JSON_BIGINT_AS_STRING, CONST_CS | CONST_PERSISTENT); @@ -240,7 +231,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) } if (myht && myht->nApplyCount > 1) { - JSON_G(error_code) = PHP_JSON_ERROR_RECURSION; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); smart_str_appendl(buf, "null", 4); return; } @@ -311,7 +302,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) smart_str_appendc(buf, ':'); json_pretty_print_char(buf, options, ' ' TSRMLS_CC); - + php_json_encode(buf, *data, options TSRMLS_CC); } else { if (need_comma) { @@ -329,7 +320,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) smart_str_appendc(buf, ':'); json_pretty_print_char(buf, options, ' ' TSRMLS_CC); - + php_json_encode(buf, *data, options TSRMLS_CC); } } @@ -340,7 +331,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) } } } - + --JSON_G(encoder_depth); json_pretty_print_char(buf, options, '\n' TSRMLS_CC); json_pretty_print_indent(buf, options TSRMLS_CC); @@ -360,6 +351,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR int pos = 0, ulen = 0; unsigned short us; unsigned short *utf16; + size_t newlen; if (len == 0) { smart_str_appendl(buf, "\"\"", 2); @@ -381,15 +373,15 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR smart_str_appendl(buf, tmp, l); efree(tmp); } else { - JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "double %.9g does not conform to the JSON spec, encoded as 0", d); smart_str_appendc(buf, '0'); } } return; } - + } - + utf16 = (options & PHP_JSON_UNESCAPED_UNICODE) ? NULL : (unsigned short *) safe_emalloc(len, sizeof(unsigned short), 0); ulen = utf8_to_utf16(utf16, s, len); if (ulen <= 0) { @@ -398,6 +390,9 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR } if (ulen < 0) { JSON_G(error_code) = PHP_JSON_ERROR_UTF8; + if (!PG(display_errors)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); + } smart_str_appendl(buf, "null", 4); } else { smart_str_appendl(buf, "\"\"", 2); @@ -408,6 +403,8 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR len = ulen; } + /* pre-allocate for string length plus 2 quotes */ + smart_str_alloc(buf, len+2, 0); smart_str_appendc(buf, '"'); while (pos < len) @@ -520,15 +517,15 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio zend_class_entry *ce = Z_OBJCE_P(val); zval *retval = NULL, fname; HashTable* myht; - + if (Z_TYPE_P(val) == IS_ARRAY) { myht = HASH_OF(val); } else { myht = Z_OBJPROP_P(val); - } - + } + if (myht && myht->nApplyCount > 1) { - JSON_G(error_code) = PHP_JSON_ERROR_RECURSION; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); smart_str_appendl(buf, "null", 4); return; } @@ -539,7 +536,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed calling %s::jsonSerialize()", ce->name); smart_str_appendl(buf, "null", sizeof("null") - 1); return; - } + } if (EG(exception)) { /* Error already raised */ @@ -592,7 +589,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ smart_str_appendl(buf, d, len); efree(d); } else { - JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "double %.9g does not conform to the JSON spec, encoded as 0", dbl); smart_str_appendc(buf, '0'); } } @@ -613,7 +610,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ break; default: - JSON_G(error_code) = PHP_JSON_ERROR_UNSUPPORTED_TYPE; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "type is unsupported, encoded as null"); smart_str_appendl(buf, "null", 4); break; } @@ -708,11 +705,7 @@ static PHP_FUNCTION(json_encode) php_json_encode(&buf, parameter, options TSRMLS_CC); - if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) { - ZVAL_FALSE(return_value); - } else { - ZVAL_STRINGL(return_value, buf.c, buf.len, 1); - } + ZVAL_STRINGL(return_value, buf.c, buf.len, 1); smart_str_free(&buf); } @@ -750,7 +743,7 @@ static PHP_FUNCTION(json_decode) /* }}} */ /* {{{ proto int json_last_error() - Returns the error code of the last json_encode() or json_decode() call. */ + Returns the error code of the last json_decode(). */ static PHP_FUNCTION(json_last_error) { if (zend_parse_parameters_none() == FAILURE) { @@ -761,40 +754,6 @@ static PHP_FUNCTION(json_last_error) } /* }}} */ -/* {{{ proto string json_last_error_msg() - Returns the error string of the last json_encode() or json_decode() call. */ -static PHP_FUNCTION(json_last_error_msg) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - switch(JSON_G(error_code)) { - case PHP_JSON_ERROR_NONE: - RETURN_STRING("No error", 1); - case PHP_JSON_ERROR_DEPTH: - RETURN_STRING("Maximum stack depth exceeded", 1); - case PHP_JSON_ERROR_STATE_MISMATCH: - RETURN_STRING("State mismatch (invalid or malformed JSON)", 1); - case PHP_JSON_ERROR_CTRL_CHAR: - RETURN_STRING("Control character error, possibly incorrectly encoded", 1); - case PHP_JSON_ERROR_SYNTAX: - RETURN_STRING("Syntax error", 1); - case PHP_JSON_ERROR_UTF8: - RETURN_STRING("Malformed UTF-8 characters, possibly incorrectly encoded", 1); - case PHP_JSON_ERROR_RECURSION: - RETURN_STRING("Recursion detected", 1); - case PHP_JSON_ERROR_INF_OR_NAN: - RETURN_STRING("Inf and NaN cannot be JSON encoded", 1); - case PHP_JSON_ERROR_UNSUPPORTED_TYPE: - RETURN_STRING("Type is not supported", 1); - default: - RETURN_STRING("Unknown error", 1); - } - -} -/* }}} */ - /* * Local variables: * tab-width: 4 diff --git a/ext/json/php_json.h b/ext/json/php_json.h index afeff3f6cc..ef3e4b5a79 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -63,7 +63,6 @@ extern zend_class_entry *php_json_serializable_ce; #define PHP_JSON_UNESCAPED_SLASHES (1<<6) #define PHP_JSON_PRETTY_PRINT (1<<7) #define PHP_JSON_UNESCAPED_UNICODE (1<<8) -#define PHP_JSON_PARTIAL_OUTPUT_ON_ERROR (1<<9) /* Internal flags */ #define PHP_JSON_OUTPUT_ARRAY 0 diff --git a/ext/json/tests/003.phpt b/ext/json/tests/003.phpt index 4ce5b0fde9..3b52fb0884 100644 --- a/ext/json/tests/003.phpt +++ b/ext/json/tests/003.phpt @@ -9,16 +9,10 @@ $a = array(); $a[] = &$a; var_dump($a); - -echo "\n"; - var_dump(json_encode($a)); -var_dump(json_last_error(), json_last_error_msg()); -echo "\n"; - -var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); +/* Break circular data structure to prevent memory leaks */ +unset($a[0]); echo "Done\n"; ?> @@ -31,11 +25,6 @@ array(1) { } } -bool(false) -int(6) -string(%d) "Recursion detected" - +Warning: json_encode(): recursion detected in %s on line %d string(8) "[[null]]" -int(6) -string(%d) "Recursion detected" Done diff --git a/ext/json/tests/004.phpt b/ext/json/tests/004.phpt index 70ef3ffd1b..1d282f9a96 100644 --- a/ext/json/tests/004.phpt +++ b/ext/json/tests/004.phpt @@ -9,16 +9,7 @@ $a = new stdclass; $a->prop = $a; var_dump($a); - -echo "\n"; - var_dump(json_encode($a)); -var_dump(json_last_error(), json_last_error_msg()); - -echo "\n"; - -var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); echo "Done\n"; ?> @@ -28,11 +19,6 @@ object(stdClass)#%d (1) { *RECURSION* } -bool(false) -int(6) -string(%d) "Recursion detected" - +Warning: json_encode(): recursion detected in %s on line %d string(22) "{"prop":{"prop":null}}" -int(6) -string(%d) "Recursion detected" Done diff --git a/ext/json/tests/007.phpt b/ext/json/tests/007.phpt index 7557ac9ed7..9ee190a24c 100644 --- a/ext/json/tests/007.phpt +++ b/ext/json/tests/007.phpt @@ -5,15 +5,15 @@ json_last_error() tests --FILE-- <?php var_dump(json_decode("[1]")); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); var_dump(json_decode("[[1]]", false, 2)); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); var_dump(json_decode("[1}")); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); var_dump(json_decode('["' . chr(0) . 'abcd"]')); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); var_dump(json_decode("[1")); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); echo "Done\n"; @@ -24,17 +24,13 @@ array(1) { int(1) } int(0) -string(8) "No error" NULL int(1) -string(28) "Maximum stack depth exceeded" NULL int(2) -string(42) "State mismatch (invalid or malformed JSON)" NULL int(3) -string(53) "Control character error, possibly incorrectly encoded" NULL int(4) -string(12) "Syntax error" Done + diff --git a/ext/json/tests/bug43941.phpt b/ext/json/tests/bug43941.phpt index 48bd7ad524..0f86d1dfad 100644 --- a/ext/json/tests/bug43941.phpt +++ b/ext/json/tests/bug43941.phpt @@ -7,14 +7,15 @@ Bug #43941 (json_encode() invalid UTF-8) var_dump(json_encode("abc")); var_dump(json_encode("ab\xE0")); -var_dump(json_encode("ab\xE0", JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_encode(array("ab\xE0", "ab\xE0c", "abc"), JSON_PARTIAL_OUTPUT_ON_ERROR)); +var_dump(json_encode("ab\xE0c")); +var_dump(json_encode(array("ab\xE0", "ab\xE0c", "abc"))); echo "Done\n"; ?> --EXPECTF-- string(5) ""abc"" -bool(false) +string(4) "null" string(4) "null" string(17) "[null,null,"abc"]" Done + diff --git a/ext/json/tests/bug53946.phpt b/ext/json/tests/bug53946.phpt index 111438ddc4..abbb81238b 100644 --- a/ext/json/tests/bug53946.phpt +++ b/ext/json/tests/bug53946.phpt @@ -9,8 +9,8 @@ var_dump(json_encode("latin 1234 -/ russian мама мыла раму speci var_dump(json_encode("ab\xE0")); var_dump(json_encode("ab\xE0", JSON_UNESCAPED_UNICODE)); ?> ---EXPECTF-- +--EXPECT-- string(156) ""latin 1234 -\/ russian \u043c\u0430\u043c\u0430 \u043c\u044b\u043b\u0430 \u0440\u0430\u043c\u0443 specialchars \u0002 \b \n U+1D11E >\ud834\udd1e<"" string(100) ""latin 1234 -\/ russian мама мыла раму specialchars \u0002 \b \n U+1D11E >𝄞<"" -bool(false) -bool(false) +string(4) "null" +string(4) "null" diff --git a/ext/json/tests/bug54058.phpt b/ext/json/tests/bug54058.phpt index df1b3130f8..3b1136bdd9 100644 --- a/ext/json/tests/bug54058.phpt +++ b/ext/json/tests/bug54058.phpt @@ -8,33 +8,28 @@ Bug #54058 (json_last_error() invalid UTF-8 produces wrong error) $bad_utf8 = quoted_printable_decode('=B0'); json_encode($bad_utf8); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); $a = new stdclass; $a->foo = quoted_printable_decode('=B0'); json_encode($a); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); $b = new stdclass; $b->foo = $bad_utf8; $b->bar = 1; json_encode($b); -var_dump(json_last_error(), json_last_error_msg()); +var_dump(json_last_error()); $c = array( 'foo' => $bad_utf8, 'bar' => 1 ); json_encode($c); -var_dump(json_last_error(), json_last_error_msg()); - +var_dump(json_last_error()); ?> --EXPECTF-- int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" diff --git a/ext/json/tests/bug61537.phpt b/ext/json/tests/bug61537.phpt deleted file mode 100644 index 80ed051c9a..0000000000 --- a/ext/json/tests/bug61537.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Bug #61537 (json_encode() incorrectly truncates/discards information) ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php -$invalid_utf8 = "\x9f"; - -var_dump(json_encode($invalid_utf8)); -var_dump(json_last_error(), json_last_error_msg()); - -var_dump(json_encode($invalid_utf8, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); - -echo "\n"; - -$invalid_utf8 = "an invalid sequen\xce in the middle of a string"; - -var_dump(json_encode($invalid_utf8)); -var_dump(json_last_error(), json_last_error_msg()); - -var_dump(json_encode($invalid_utf8, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); - -?> ---EXPECTF-- -bool(false) -int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" -string(4) "null" -int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" - -bool(false) -int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" -string(4) "null" -int(5) -string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt index c34b03f8f7..2c732979ef 100644 --- a/ext/json/tests/bug61978.phpt +++ b/ext/json/tests/bug61978.phpt @@ -29,15 +29,19 @@ class JsonTest2 implements JsonSerializable { $obj1 = new JsonTest1(); -var_dump(json_encode($obj1, JSON_PARTIAL_OUTPUT_ON_ERROR)); +var_dump(json_encode($obj1)); -echo "==\n"; +echo "\n==\n"; $obj2 = new JsonTest2(); -var_dump(json_encode($obj2, JSON_PARTIAL_OUTPUT_ON_ERROR)); +var_dump(json_encode($obj2)); ?> --EXPECTF-- +Warning: json_encode(): recursion detected in %s on line %d string(44) "{"test":"123","me":{"test":"123","me":null}}" + == + +Warning: json_encode(): recursion detected in %s on line %d string(44) "{"test":"123","me":{"test":"123","me":null}}" diff --git a/ext/json/tests/inf_nan_error.phpt b/ext/json/tests/inf_nan_error.phpt deleted file mode 100644 index f9deecc469..0000000000 --- a/ext/json/tests/inf_nan_error.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -An error is thrown when INF or NaN are encoded ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -$inf = INF; - -var_dump($inf); - -var_dump(json_encode($inf)); -var_dump(json_last_error(), json_last_error_msg()); - -var_dump(json_encode($inf, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); - -echo "\n"; - -$nan = NAN; - -var_dump($nan); - -var_dump(json_encode($nan)); -var_dump(json_last_error(), json_last_error_msg()); - -var_dump(json_encode($nan, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); -?> ---EXPECTF-- -float(INF) -bool(false) -int(7) -string(34) "Inf and NaN cannot be JSON encoded" -string(1) "0" -int(7) -string(34) "Inf and NaN cannot be JSON encoded" - -float(NAN) -bool(false) -int(7) -string(34) "Inf and NaN cannot be JSON encoded" -string(1) "0" -int(7) -string(34) "Inf and NaN cannot be JSON encoded" diff --git a/ext/json/tests/json_encode_basic.phpt b/ext/json/tests/json_encode_basic.phpt index fc348eed81..152e24444c 100644 --- a/ext/json/tests/json_encode_basic.phpt +++ b/ext/json/tests/json_encode_basic.phpt @@ -150,7 +150,9 @@ string(4) "null" -- Iteration 25 -- string(4) "null" -- Iteration 26 -- -bool(false) + +Warning: json_encode(): type is unsupported, encoded as null in %s on line %d +string(4) "null" -- Iteration 27 -- string(82) "{"MyInt":99,"MyFloat":123.45,"MyBool":true,"MyNull":null,"MyString":"Hello World"}" -===Done=== +===Done===
\ No newline at end of file diff --git a/ext/json/tests/pass001.1.phpt b/ext/json/tests/pass001.1.phpt index a51f885780..7e15a7622a 100644 --- a/ext/json/tests/pass001.1.phpt +++ b/ext/json/tests/pass001.1.phpt @@ -90,10 +90,10 @@ $arr = json_decode($test, true); var_dump($arr); echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR); +$obj_enc = json_encode($obj); echo $obj_enc . "\n"; echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR); +$arr_enc = json_encode($arr); echo $arr_enc . "\n"; echo "DECODE AGAIN: AS OBJECT\n"; diff --git a/ext/json/tests/pass001.phpt b/ext/json/tests/pass001.phpt index 1fd05fcdd8..43be11e2b0 100644 --- a/ext/json/tests/pass001.phpt +++ b/ext/json/tests/pass001.phpt @@ -79,10 +79,10 @@ $arr = json_decode($test, true); var_dump($arr); echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR); +$obj_enc = json_encode($obj); echo $obj_enc . "\n"; echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR); +$arr_enc = json_encode($arr); echo $arr_enc . "\n"; echo "DECODE AGAIN: AS OBJECT\n"; diff --git a/ext/json/tests/unsupported_type_error.phpt b/ext/json/tests/unsupported_type_error.phpt deleted file mode 100644 index 45a167a5ac..0000000000 --- a/ext/json/tests/unsupported_type_error.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -An error is thrown when an unsupported type is encoded ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -$resource = fopen(__FILE__, "r"); - -var_dump($resource); - -var_dump(json_encode($resource)); -var_dump(json_last_error(), json_last_error_msg()); - -var_dump(json_encode($resource, JSON_PARTIAL_OUTPUT_ON_ERROR)); -var_dump(json_last_error(), json_last_error_msg()); - -?> ---EXPECTF-- -resource(5) of type (stream) -bool(false) -int(8) -string(21) "Type is not supported" -string(4) "null" -int(8) -string(21) "Type is not supported" diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index f18a503b5e..6d283aa9ca 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -162,7 +162,7 @@ void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC) { if (stmt->stmt) { if (mysqli_stmt_close(stmt->stmt, TRUE)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error occured while closing statement"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error occurred while closing statement"); return; } } diff --git a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt index b8dd11a699..7fc32f7e61 100644 --- a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt @@ -63,7 +63,7 @@ require_once('skipifconnectfailure.inc'); // NOTE: the error message varies with the MySQL Server version, dump only the error code! printf("[009] [%d] (error message varies with the MySQL Server version, check the error code)\n", mysqli_stmt_errno($stmt)); - /* an error occured: affected rows should return -1 */ + /* an error occurred: affected rows should return -1 */ if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index 8e8622e540..82ee63458e 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -188,7 +188,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zen char tmp_buf[sizeof(conn->error_info->error)]; int tmp_error_no; *is_warning = TRUE; - /* error occured */ + /* error occurred */ tmp_error_no = infile.local_infile_error(info, tmp_buf, sizeof(tmp_buf) TSRMLS_CC); SET_CLIENT_ERROR(*conn->error_info, tmp_error_no, UNKNOWN_SQLSTATE, tmp_buf); /* write empty packet to server */ @@ -211,7 +211,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zen goto infile_error; } - /* error during read occured */ + /* error during read occurred */ if (bufsize < 0) { char tmp_buf[sizeof(conn->error_info->error)]; int tmp_error_no; diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index e5910a5dca..8647e105ef 100755 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -816,7 +816,7 @@ PHP_FUNCTION(pcntl_exec) if (execve(path, argv, envp) == -1) { PCNTL_G(last_error) = errno; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occurred: (errno %d) %s", errno, strerror(errno)); } /* Cleanup */ @@ -826,7 +826,7 @@ PHP_FUNCTION(pcntl_exec) if (execv(path, argv) == -1) { PCNTL_G(last_error) = errno; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occurred: (errno %d) %s", errno, strerror(errno)); } } @@ -1127,7 +1127,7 @@ PHP_FUNCTION(pcntl_getpriority) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d: Invalid identifier flag", errno); break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error %d has occured", errno); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error %d has occurred", errno); break; } RETURN_FALSE; @@ -1167,7 +1167,7 @@ PHP_FUNCTION(pcntl_setpriority) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d: Only a super user may attempt to increase the process priority", errno); break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error %d has occured", errno); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error %d has occurred", errno); break; } RETURN_FALSE; diff --git a/ext/pcntl/tests/pcntl_exec_3.phpt b/ext/pcntl/tests/pcntl_exec_3.phpt index d27c1c9962..5349381d92 100644 --- a/ext/pcntl/tests/pcntl_exec_3.phpt +++ b/ext/pcntl/tests/pcntl_exec_3.phpt @@ -13,5 +13,5 @@ unlink($file); Warning: pcntl_exec() expects at least 1 parameter, 0 given %s NULL -Warning: pcntl_exec(): Error has occured: (errno %d) %s +Warning: pcntl_exec(): Error has occurred: (errno %d) %s bool(false) diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 0c2689f9d5..fc5ec5135b 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -134,7 +134,7 @@ static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ row_count = mysql_affected_rows(H->server); if (row_count == (my_ulonglong)-1) { - /* we either have a query that returned a result set or an error occured + /* we either have a query that returned a result set or an error occurred lets see if we have access to a result set */ if (!H->buffered) { S->result = mysql_use_result(H->server); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 455280fc74..7236b8a1b3 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1513,22 +1513,28 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, } /* }}} */ -/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive]) +/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive [, bool from_root]) Return all namespaces registered with document */ SXE_METHOD(getDocNamespaces) { - zend_bool recursive = 0; + zend_bool recursive = 0, from_root = 1; php_sxe_object *sxe; + xmlNodePtr node; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &recursive) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &recursive, &from_root) == FAILURE) { return; } array_init(return_value); sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); + if(from_root){ + node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr); + }else{ + GET_NODE(sxe, node); + } - sxe_add_registered_namespaces(sxe, xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr), recursive, return_value TSRMLS_CC); + sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } /* }}} */ @@ -2518,6 +2524,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getnamespaces, 0, 0, 0) ZEND_ARG_INFO(0, recursve) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getdocnamespaces, 0, 0, 0) + ZEND_ARG_INFO(0, recursve) + ZEND_ARG_INFO(0, from_root) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_children, 0, 0, 0) ZEND_ARG_INFO(0, ns) ZEND_ARG_INFO(0, is_prefix) @@ -2586,7 +2597,7 @@ static const zend_function_entry sxe_functions[] = { /* {{{ */ SXE_ME(attributes, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(children, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(getNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) - SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) + SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getdocnamespaces, ZEND_ACC_PUBLIC) SXE_ME(getName, arginfo_simplexmlelement__void, ZEND_ACC_PUBLIC) SXE_ME(addChild, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) SXE_ME(addAttribute, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) diff --git a/ext/simplexml/tests/bug48601.phpt b/ext/simplexml/tests/bug48601.phpt index 24bf2bf8a5..0b81facf49 100644 --- a/ext/simplexml/tests/bug48601.phpt +++ b/ext/simplexml/tests/bug48601.phpt @@ -10,7 +10,7 @@ $sxe = simplexml_load_string('<root><node1>1</node1></root>'); $nodes = $sxe->xpath("/root/node2/@test"); if (! is_array($nodes)) { - echo "An error occured\n"; + echo "An error occurred\n"; } else { echo "Result Count: " . count($nodes) . "\n"; } diff --git a/ext/simplexml/tests/feature55218.phpt b/ext/simplexml/tests/feature55218.phpt new file mode 100644 index 0000000000..25ea534376 --- /dev/null +++ b/ext/simplexml/tests/feature55218.phpt @@ -0,0 +1,117 @@ +--TEST-- +Bug #55218 getDocNamespaces from current element and not root +--SKIPIF-- +<?php +if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$x = new SimpleXMLElement( +'<?xml version="1.0" standalone="yes"?> +<people xmlns:p="http://example.org/p" > + <person id="1" xmlns:t="http://example.org/t" > + <t:name>John Doe</t:name> + </person> + <person id="2">Susie Q. Public</person> + <o> + <p:div>jdslkfjsldk jskdfjsmlkjfkldjkjflskj kljfslkjf sldk</p:div> + </o> +</people>'); + +echo "getDocNamespaces\n"; +echo "\nBackwards Compatibility:\n"; +echo "recursion:\n"; + +var_dump ( $x->getDocNamespaces(true) ) ; +var_dump( $x->person[0]->getDocNamespaces(true) ); +var_dump( $x->person[1]->getDocNamespaces(true) ); + +echo "\nnon recursive:\n"; + +var_dump( $x->getDocNamespaces(false) ); +var_dump( $x->person[0]->getDocNamespaces(false) ); +var_dump( $x->person[1]->getDocNamespaces(false) ); + +echo "\n\nUsing new 'from_root' bool set to false:\n"; +echo "recursion:\n"; + +var_dump ( $x->getDocNamespaces(true, false) ) ; +var_dump( $x->person[0]->getDocNamespaces(true, false) ); +var_dump( $x->person[1]->getDocNamespaces(true, false) ); + +echo "\nnon recursive:\n"; + +var_dump( $x->getDocNamespaces(false, false) ); +var_dump( $x->person[0]->getDocNamespaces(false, false) ); +var_dump( $x->person[1]->getDocNamespaces(false, false) ); + +?> +===DONE=== +--EXPECTF-- +getDocNamespaces + +Backwards Compatibility: +recursion: +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} + +non recursive: +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} + + +Using new 'from_root' bool set to false: +recursion: +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(1) { + ["t"]=> + string(20) "http://example.org/t" +} +array(0) { +} + +non recursive: +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["t"]=> + string(20) "http://example.org/t" +} +array(0) { +} +===DONE===
\ No newline at end of file diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt index 96cbf8f4db..bf95044d48 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt @@ -25,7 +25,7 @@ if (!extension_loaded('sockets')) { $len = strlen($msg); $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223); if ($bytes_sent == -1) { - die('An error occured while sending to the socket'); + die('An error occurred while sending to the socket'); } else if ($bytes_sent != $len) { die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected'); } @@ -36,7 +36,7 @@ if (!extension_loaded('sockets')) { socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port); if ($bytes_received == -1) { - die('An error occured while receiving from the socket'); + die('An error occurred while receiving from the socket'); } else if ($bytes_received != $len) { die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected'); } diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt index 1fa42fd5da..04f62eddd3 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt @@ -26,7 +26,7 @@ require 'ipv6_skipif.inc'; $len = strlen($msg); $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223); if ($bytes_sent == -1) { - die('An error occured while sending to the socket'); + die('An error occurred while sending to the socket'); } else if ($bytes_sent != $len) { die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected'); } @@ -37,7 +37,7 @@ require 'ipv6_skipif.inc'; socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port); if ($bytes_received == -1) { - die('An error occured while receiving from the socket'); + die('An error occurred while receiving from the socket'); } else if ($bytes_received != $len) { die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected'); } diff --git a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt index 4cfdebbcbe..55ad75c65e 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt @@ -30,7 +30,7 @@ if (!extension_loaded('sockets')) { $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address); if ($bytes_sent == -1) { @unlink($address); - die('An error occured while sending to the socket'); + die('An error occurred while sending to the socket'); } else if ($bytes_sent != $len) { @unlink($address); die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected'); @@ -41,7 +41,7 @@ if (!extension_loaded('sockets')) { $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from); if ($bytes_received == -1) { @unlink($address); - die('An error occured while receiving from the socket'); + die('An error occurred while receiving from the socket'); } else if ($bytes_received != $len) { @unlink($address); die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected'); diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index dbae3e2a09..0fcbd317e3 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1432,6 +1432,7 @@ SPL_METHOD(FilesystemIterator, __construct) SPL_METHOD(FilesystemIterator, rewind) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS); if (zend_parse_parameters_none() == FAILURE) { return; @@ -1443,7 +1444,7 @@ SPL_METHOD(FilesystemIterator, rewind) } do { spl_filesystem_dir_read(intern TSRMLS_CC); - } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name)); + } while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name)); } /* }}} */ diff --git a/ext/spl/tests/bug52238.phpt b/ext/spl/tests/bug52238.phpt index 85410bdf1e..10da0b5fd9 100644 --- a/ext/spl/tests/bug52238.phpt +++ b/ext/spl/tests/bug52238.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #52238 - Crash when an Exception occured in iterator_to_array +Bug #52238 - Crash when an Exception occurred in iterator_to_array --FILE-- <?php class Foo implements IteratorAggregate diff --git a/ext/spl/tests/bug62433.phpt b/ext/spl/tests/bug62433.phpt new file mode 100644 index 0000000000..bfb3568bac --- /dev/null +++ b/ext/spl/tests/bug62433.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. and ..) +--FILE-- +<?php +$dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__))); +$ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS))); + +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $dots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $dots)); + +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $ndots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $ndots)); +?> +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(false) diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c index a3d542a40c..d96367e212 100644 --- a/ext/sqlite3/libsqlite/sqlite3.c +++ b/ext/sqlite3/libsqlite/sqlite3.c @@ -23307,7 +23307,7 @@ static int os2OpenSharedMemory( os2File *fd, int szRegion ) { sqlite3_mutex_leave(pNode->mutex); } else { - /* Error occured. Free our link object. */ + /* Error occurred. Free our link object. */ sqlite3_free(pLink); } @@ -28994,7 +28994,7 @@ static int fillInUnixFile( unixEnterMutex(); rc = findInodeInfo(pNew, &pNew->pInode); if( rc!=SQLITE_OK ){ - /* If an error occured in findInodeInfo(), close the file descriptor + /* If an error occurred in findInodeInfo(), close the file descriptor ** immediately, before releasing the mutex. findInodeInfo() may fail ** in two scenarios: ** @@ -32173,7 +32173,7 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ ** containing the lower 32-bits of the new file-offset. Or, if it fails, ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine - ** whether an error has actually occured, it is also necessary to call + ** whether an error has actually occurred, it is also necessary to call ** GetLastError(). */ dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); @@ -32273,7 +32273,7 @@ static int winWrite( int amt, /* Number of bytes to write */ sqlite3_int64 offset /* Offset into the file to begin writing at */ ){ - int rc; /* True if error has occured, else false */ + int rc; /* True if error has occurred, else false */ winFile *pFile = (winFile*)id; /* File handle */ assert( amt>0 ); @@ -37068,7 +37068,7 @@ int sqlite3PagerTrace=1; /* True to enable tracing */ ** * A write transaction is active. ** * An EXCLUSIVE or greater lock is held on the database file. ** * All writing and syncing of journal and database data has finished. -** If no error occured, all that remains is to finalize the journal to +** If no error occurred, all that remains is to finalize the journal to ** commit the transaction. If an error did occur, the caller will need ** to rollback the transaction. ** @@ -54279,7 +54279,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); - /* If no error has occured and pPage has an overflow cell, call balance() + /* If no error has occurred and pPage has an overflow cell, call balance() ** to redistribute the cells within the tree. Since balance() may move ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey ** variables. @@ -57935,7 +57935,7 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){ } sqlite3DbFree(v->db, sIter.apSub); - /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. + /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred. ** If malloc failed, then the while() loop above may not have iterated ** through all opcodes and hasAbort may be set incorrectly. Return ** true for this case to prevent the assert() in the callers frame @@ -59562,7 +59562,7 @@ SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){ /* If p->iStatement is greater than zero, then this Vdbe opened a ** statement transaction that should be closed here. The only exception - ** is that an IO error may have occured, causing an emergency rollback. + ** is that an IO error may have occurred, causing an emergency rollback. ** In this case (db->nStatement==0), and there is nothing to do. */ if( db->nStatement && p->iStatement ){ @@ -59697,7 +59697,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ ** ** Even if the statement is read-only, it is important to perform ** a statement or transaction rollback operation. If the error - ** occured while writing to the journal, sub-journal or database + ** occurred while writing to the journal, sub-journal or database ** file as part of an effort to free up cache space (see function ** pagerStress() in pager.c), the rollback is required to restore ** the pager to a consistent state. @@ -61245,7 +61245,7 @@ end_of_step: assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ /* If this statement was prepared using sqlite3_prepare_v2(), and an - ** error has occured, then return the error code in p->rc to the + ** error has occurred, then return the error code in p->rc to the ** caller. Set the error code in the database handle to the same value. */ rc = db->errCode = p->rc; @@ -113286,7 +113286,7 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ }else{ int rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK ){ - /* If no row was found and no error has occured, then the %_content + /* If no row was found and no error has occurred, then the %_content ** table is missing a row that is present in the full-text index. ** The data structures are corrupt. */ diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 4bf24fbc6a..0bb8616d96 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1097,7 +1097,7 @@ static int php_sqlite3_stream_close(php_stream *stream, int close_handle TSRMLS_ php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; if (sqlite3_blob_close(sqlite3_stream->blob) != SQLITE_OK) { - /* Error occured, but it still closed */ + /* Error occurred, but it still closed */ } efree(sqlite3_stream); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 646005ebc7..a5637db50d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3833,7 +3833,7 @@ PHP_NAMED_FUNCTION(php_inet_ntop) } if (!inet_ntop(af, address, buffer, sizeof(buffer))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "An unknown error occured"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "An unknown error occurred"); RETURN_FALSE; } diff --git a/ext/standard/string.c b/ext/standard/string.c index 5c33232f7d..9a64376c27 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -131,8 +131,8 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * register unsigned char *result = NULL; size_t i, j; - result = (unsigned char *) safe_emalloc(oldlen * 2, sizeof(char), 1); - + result = (unsigned char *) safe_emalloc(oldlen, 2 * sizeof(char), 1); + for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4]; result[j++] = hexconvtab[old[i] & 15]; @@ -4029,13 +4029,12 @@ PHP_FUNCTION(nl2br) RETURN_STRINGL(str, str_len, 1); } - if (is_xhtml) { - new_length = str_len + repl_cnt * (sizeof("<br />") - 1); - } else { - new_length = str_len + repl_cnt * (sizeof("<br>") - 1); - } + { + size_t repl_len = is_xhtml ? (sizeof("<br />") - 1) : (sizeof("<br>") - 1); - tmp = target = emalloc(new_length + 1); + new_length = str_len + repl_cnt * repl_len; + tmp = target = safe_emalloc(repl_cnt, repl_len, str_len + 1); + } while (str < end) { switch (*str) { diff --git a/ext/standard/tests/file/umask_basic.phpt b/ext/standard/tests/file/umask_basic.phpt index 7a2eb762db..761df97253 100644 --- a/ext/standard/tests/file/umask_basic.phpt +++ b/ext/standard/tests/file/umask_basic.phpt @@ -20,7 +20,7 @@ for($mask = 0000; $mask <= 0777; $mask++) { var_dump( umask() ); echo "\n"; if ($mask != umask()) { - die('An error occured while changing back the umask'); + die('An error occurred while changing back the umask'); } } diff --git a/ext/tidy/examples/cleanhtml.php b/ext/tidy/examples/cleanhtml.php index 9a6713dc55..2644210cbf 100644 --- a/ext/tidy/examples/cleanhtml.php +++ b/ext/tidy/examples/cleanhtml.php @@ -26,7 +26,7 @@ if(tidy_warning_count() || tidy_error_count()) { - echo "\n\nThe following errors or warnings occured:\n"; + echo "\n\nThe following errors or warnings occurred:\n"; echo tidy_get_error_buffer(); echo "\n"; } diff --git a/ext/tidy/examples/cleanhtml5.php b/ext/tidy/examples/cleanhtml5.php index 4dfd7643e1..2ce683acad 100644 --- a/ext/tidy/examples/cleanhtml5.php +++ b/ext/tidy/examples/cleanhtml5.php @@ -25,7 +25,7 @@ if(!empty($tidy->errorBuffer)) { - echo "\n\nThe following errors or warnings occured:\n"; + echo "\n\nThe following errors or warnings occurred:\n"; echo "{$tidy->errorBuffer}\n"; } diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 5ac1a69196..72d8f5db66 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -1238,7 +1238,7 @@ static PHP_FUNCTION(tidy_parse_string) /* }}} */ /* {{{ proto string tidy_get_error_buffer() - Return warnings and errors which occured parsing the specified document*/ + Return warnings and errors which occurred parsing the specified document*/ static PHP_FUNCTION(tidy_get_error_buffer) { TIDY_FETCH_OBJECT; diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index d48e7090ae..5aa6aa943b 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -336,7 +336,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler)); valuePush(ctxt, xmlXPathNewString("")); } - /* retval is == NULL, when an exception occured, don't report anything, because PHP itself will handle that */ + /* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */ } else if (retval == NULL) { } else { if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) { diff --git a/run-tests.php b/run-tests.php index 9a01f56c97..302167a6e5 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2089,8 +2089,10 @@ $output if (isset($old_php)) { $php = $old_php; } + + $diff = empty($diff) ? '' : "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>"; - junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>"); + junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff); return $restype[0] . 'ED'; } @@ -2666,12 +2668,15 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag $time = null !== $time ? $time : junit_get_timer($file_name); junit_suite_record($suite, 'execution_time', $time); + $escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8'); + $escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES); $JUNIT['files'][$file_name]['xml'] = "<testcase classname='$suite' name='$escaped_test_name' time='$time'>\n"; if (is_array($type)) { $output_type = $type[0] . 'ED'; - $type = reset(array_intersect(array('XFAIL', 'FAIL'), $type)); + $temp = array_intersect(array('XFAIL', 'FAIL'), $type); + $type = reset($temp); } else { $output_type = $type . 'ED'; } @@ -2686,10 +2691,10 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag $JUNIT['files'][$file_name]['xml'] .= "<skipped>$message</skipped>\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); - $JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$message'>$details</failure>\n"; + $JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$message'>$escaped_details</failure>\n"; } else { junit_suite_record($suite, 'test_error'); - $JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'>$details</error>\n"; + $JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'>$escaped_details</error>\n"; } $JUNIT['files'][$file_name]['xml'] .= "</testcase>\n"; diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index e8116f9eba..0b51cfbe62 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -311,7 +311,7 @@ php_apache_disable_caching(ap_filter_t *f) static double php_apache_sapi_get_request_time(TSRMLS_D) { php_struct *ctx = SG(server_context); - return apr_time_as_msec(ctx->r->request_time); + return ((double) apr_time_as_msec(ctx->r->request_time)) / 1000.0; } extern zend_module_entry php_apache_module; |