Re: [PHP-CVS] com php-src: - Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable): ext/json/json.c ext/json/tests/bug61978.phpt
This should probably not just insert null but let the whole function fail. Otherwise one has to add additional error checks on every call. Nikita On Wed, May 9, 2012 at 2:05 AM, Felipe Pena fel...@php.net wrote: Commit: 92bc49b2b06417f86dc0fc537326e60f4d0a0c0b Author: Felipe Pena felipe...@gmail.com Tue, 8 May 2012 21:05:51 -0300 Parents: 2cb0ed1328da3bca00990648c3dfc90c957395f1 Branches: PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=92bc49b2b06417f86dc0fc537326e60f4d0a0c0b Log: - Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable) Bugs: https://bugs.php.net/61978 Changed paths: M ext/json/json.c A ext/json/tests/bug61978.phpt Diff: diff --git a/ext/json/json.c b/ext/json/json.c index fc1fcb7..557fbc3 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -513,6 +513,19 @@ 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) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, recursion detected); + smart_str_appendl(buf, null, 4); + return; + } ZVAL_STRING(fname, jsonSerialize, 0); diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt new file mode 100644 index 000..2c73297 --- /dev/null +++ b/ext/json/tests/bug61978.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #61978 (Object recursion not detected for classes that implement JsonSerializable) +--SKIPIF-- +?php if (!extension_loaded(json)) print skip; ? +--FILE-- +?php + +class JsonTest1 { + public $test; + public $me; + public function __construct() { + $this-test = '123'; + $this-me = $this; + } +} + +class JsonTest2 implements JsonSerializable { + public $test; + public function __construct() { + $this-test = '123'; + } + public function jsonSerialize() { + return array( + 'test' = $this-test, + 'me' = $this + ); + } +} + + +$obj1 = new JsonTest1(); +var_dump(json_encode($obj1)); + +echo \n==\n; + +$obj2 = new JsonTest2(); +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}} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug 61901 ext\phar\tests\phar_buildfromdirectory2.phpt fails: ext/phar/tests/phar_buildfromdirectory2-win.phpt ext/phar/tests/phar_buildfromdirectory2.phpt
Commit:7fb16d5bd9cd5a317c52ed36b5a94fc5e0067b4a Author:Anatoliy Belsky a...@php.net Wed, 9 May 2012 13:02:33 +0200 Parents: c12fdbde5fe1da3f5ddd3be70a807b46755ff118 Branches: PHP-5.3 PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7fb16d5bd9cd5a317c52ed36b5a94fc5e0067b4a Log: Fix bug 61901 ext\phar\tests\phar_buildfromdirectory2.phpt fails Another error message is produced by win specific code Bugs: https://bugs.php.net/61901 Changed paths: A ext/phar/tests/phar_buildfromdirectory2-win.phpt M ext/phar/tests/phar_buildfromdirectory2.phpt Diff: diff --git a/ext/phar/tests/phar_buildfromdirectory2-win.phpt b/ext/phar/tests/phar_buildfromdirectory2-win.phpt new file mode 100644 index 000..9dbcf96 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory2-win.phpt @@ -0,0 +1,30 @@ +--TEST-- +Phar::buildFromDirectory() - non-directory passed as first parameter +--SKIPIF-- +?php + if (!extension_loaded(phar)) die(skip); + if (substr(PHP_OS, 0, 3) != WIN) die(skip Windows only test); +? +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +?php +try { + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); + $phar-buildFromDirectory(1); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e-getMessage() . \n; +} +? +===DONE=== +--CLEAN-- +?php +unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +__HALT_COMPILER(); +? +--EXPECTF-- +%s(24) UnexpectedValueException +RecursiveDirectoryIterator::__construct(1,1): The system cannot find the file specified. (code: 2) +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory2.phpt b/ext/phar/tests/phar_buildfromdirectory2.phpt index 6c67f20..639ff0b 100644 --- a/ext/phar/tests/phar_buildfromdirectory2.phpt +++ b/ext/phar/tests/phar_buildfromdirectory2.phpt @@ -1,7 +1,10 @@ --TEST-- Phar::buildFromDirectory() - non-directory passed as first parameter --SKIPIF-- -?php if (!extension_loaded(phar)) die(skip); ? +?php + if (!extension_loaded(phar)) die(skip); + if (substr(PHP_OS, 0, 3) == WIN) die(skip not for Windows); +? --INI-- phar.require_hash=0 phar.readonly=0 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/phpruntests/trunk/ build.xml phpt-tests/sample_clean.php phpt-tests/sample_clean_fail.php phpt-tests/sample_fileexternal.phpt phpt-tests/sample_gzippost.phpt phpt-tests/utils/hw.ph
zoe Wed, 09 May 2012 16:26:29 + Revision: http://svn.php.net/viewvc?view=revisionrevision=325627 Log: tidying up Changed paths: U php/phpruntests/trunk/build.xml D php/phpruntests/trunk/phpt-tests/sample_clean.php D php/phpruntests/trunk/phpt-tests/sample_clean_fail.php U php/phpruntests/trunk/phpt-tests/sample_fileexternal.phpt U php/phpruntests/trunk/phpt-tests/sample_gzippost.phpt A php/phpruntests/trunk/phpt-tests/utils/ A php/phpruntests/trunk/phpt-tests/utils/hw.php A php/phpruntests/trunk/phpt-tests/utils/hw.save A php/phpruntests/trunk/phpt-tests/utils/windows_line_endings.php D php/phpruntests/trunk/phpt-tests/windows_line_endings.php U php/phpruntests/trunk/tests/testcase/rtCookieExecutionTest.php Modified: php/phpruntests/trunk/build.xml === --- php/phpruntests/trunk/build.xml 2012-05-09 16:12:35 UTC (rev 325626) +++ php/phpruntests/trunk/build.xml 2012-05-09 16:26:29 UTC (rev 325627) @@ -11,6 +11,15 @@ delete dir=QA/sapi / delete dir=QA/tests / delete dir=QA/Zend / +delete + fileset dir=phpt-tests includes=*.out / + fileset dir=phpt-tests includes=*.exp / + fileset dir=phpt-tests includes=*.diff / + fileset dir=phpt-tests includes=*.log / + fileset dir=phpt-tests includes=*.sh / + fileset dir=phpt-tests includes=*.post / + fileset dir=phpt-tests includes=*.php / +/delete /target target name=qa depends=lint, test, coverage, compare, doc description=Perform quality assurance. @@ -28,13 +37,6 @@ include name=**/*.php/ /fileset /phplint - -phplint haltonfailure=true - fileset dir=tests -include name=*.php/ -include name=**/*.php/ - /fileset -/phplint /target target name=test description=Run all unit tests. Deleted: php/phpruntests/trunk/phpt-tests/sample_clean.php === --- php/phpruntests/trunk/phpt-tests/sample_clean.php 2012-05-09 16:12:35 UTC (rev 325626) +++ php/phpruntests/trunk/phpt-tests/sample_clean.php 2012-05-09 16:26:29 UTC (rev 325627) @@ -1,7 +0,0 @@ -?php - - $file_name = dirname(__FILE__) . /cleantest.tmp; - file_put_contents($file_name, hello world); - echo written\n; - -? Deleted: php/phpruntests/trunk/phpt-tests/sample_clean_fail.php === --- php/phpruntests/trunk/phpt-tests/sample_clean_fail.php 2012-05-09 16:12:35 UTC (rev 325626) +++ php/phpruntests/trunk/phpt-tests/sample_clean_fail.php 2012-05-09 16:26:29 UTC (rev 325627) @@ -1,7 +0,0 @@ -?php - - $file_name = dirname(__FILE__) . /cleantest.tmp; - file_put_contents($file_name, hello world); - echo written\n; - -? Modified: php/phpruntests/trunk/phpt-tests/sample_fileexternal.phpt === --- php/phpruntests/trunk/phpt-tests/sample_fileexternal.phpt 2012-05-09 16:12:35 UTC (rev 325626) +++ php/phpruntests/trunk/phpt-tests/sample_fileexternal.phpt 2012-05-09 16:26:29 UTC (rev 325627) @@ -1,6 +1,6 @@ --TEST-- sample test for file_external --FILE_EXTERNAL-- -hw.php +utils/hw.php --EXPECT-- hello world Modified: php/phpruntests/trunk/phpt-tests/sample_gzippost.phpt === --- php/phpruntests/trunk/phpt-tests/sample_gzippost.phpt 2012-05-09 16:12:35 UTC (rev 325626) +++ php/phpruntests/trunk/phpt-tests/sample_gzippost.phpt 2012-05-09 16:26:29 UTC (rev 325627) @@ -5,8 +5,8 @@ --FILE-- ?php $content = file_get_contents('php://input'); - -if ($content != gzencode('blahblah=blah')) +$string = gzdecode($content); +if ($string != blahblah=blah) { echo invalid gzipped content; } else { Added: php/phpruntests/trunk/phpt-tests/utils/hw.php === --- php/phpruntests/trunk/phpt-tests/utils/hw.php (rev 0) +++ php/phpruntests/trunk/phpt-tests/utils/hw.php 2012-05-09 16:26:29 UTC (rev 325627) @@ -0,0 +1,3 @@ +?php + echo hello world\n; +? Added: php/phpruntests/trunk/phpt-tests/utils/hw.save === --- php/phpruntests/trunk/phpt-tests/utils/hw.save (rev 0) +++ php/phpruntests/trunk/phpt-tests/utils/hw.save 2012-05-09 16:26:29 UTC (rev 325627) @@ -0,0 +1,3 @@ +?php + echo hello world\n; +? Added: php/phpruntests/trunk/phpt-tests/utils/windows_line_endings.php === --- php/phpruntests/trunk/phpt-tests/utils/windows_line_endings.php (rev 0) +++ php/phpruntests/trunk/phpt-tests/utils/windows_line_endings.php 2012-05-09 16:26:29 UTC (rev
[PHP-CVS] svn: /php/phpruntests/trunk/phpt-tests/utils/ hw.save
zoe Wed, 09 May 2012 16:27:07 + Revision: http://svn.php.net/viewvc?view=revisionrevision=325628 Log: added by accident Changed paths: D php/phpruntests/trunk/phpt-tests/utils/hw.save Deleted: php/phpruntests/trunk/phpt-tests/utils/hw.save === --- php/phpruntests/trunk/phpt-tests/utils/hw.save 2012-05-09 16:26:29 UTC (rev 325627) +++ php/phpruntests/trunk/phpt-tests/utils/hw.save 2012-05-09 16:27:07 UTC (rev 325628) @@ -1,3 +0,0 @@ -?php - echo hello world\n; -? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/phpruntests/trunk/phpt-tests/ hw.php
zoe Wed, 09 May 2012 16:29:30 + Revision: http://svn.php.net/viewvc?view=revisionrevision=325629 Log: moree tidying Changed paths: D php/phpruntests/trunk/phpt-tests/hw.php Deleted: php/phpruntests/trunk/phpt-tests/hw.php === --- php/phpruntests/trunk/phpt-tests/hw.php 2012-05-09 16:27:07 UTC (rev 325628) +++ php/phpruntests/trunk/phpt-tests/hw.php 2012-05-09 16:29:30 UTC (rev 325629) @@ -1,3 +0,0 @@ -?php - echo hello world\n; -? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/phpruntests/trunk/tests/testcase/sections/configurationsections/ rtPostSectionTest.php
zoe Wed, 09 May 2012 16:54:16 + Revision: http://svn.php.net/viewvc?view=revisionrevision=325630 Log: clean up temporary file Changed paths: U php/phpruntests/trunk/tests/testcase/sections/configurationsections/rtPostSectionTest.php Modified: php/phpruntests/trunk/tests/testcase/sections/configurationsections/rtPostSectionTest.php === --- php/phpruntests/trunk/tests/testcase/sections/configurationsections/rtPostSectionTest.php 2012-05-09 16:29:30 UTC (rev 325629) +++ php/phpruntests/trunk/tests/testcase/sections/configurationsections/rtPostSectionTest.php 2012-05-09 16:54:16 UTC (rev 325630) @@ -13,6 +13,9 @@ $fileName = $postSection-getPostFileName(); $string = file_get_contents($fileName); +//clean up +unlink($fileName); + $this-assertEquals('hello=Worldgoodbye=MrChips', $string); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/phpruntests/trunk/ build.xml
zoe Wed, 09 May 2012 18:57:48 + Revision: http://svn.php.net/viewvc?view=revisionrevision=325631 Log: remove hard coded paths Changed paths: U php/phpruntests/trunk/build.xml Modified: php/phpruntests/trunk/build.xml === --- php/phpruntests/trunk/build.xml 2012-05-09 16:54:16 UTC (rev 325630) +++ php/phpruntests/trunk/build.xml 2012-05-09 18:57:48 UTC (rev 325631) @@ -50,8 +50,10 @@ /target target name=compare description=Old/New comparison of phpt results. -fail unless=php message=Path to PHP executable not defined, use -Dphp=/path/to/php / +fail unless=php message=Path to standard PHP executable not defined, use -Dphp=/path/to/php / +fail unless=php_to_test message=Path to test PHP source dir not defined, use -Dphp_to_test=/path/to/php_source_dir / + delete dir=_compare / mkdir dir=_compare / @@ -62,8 +64,8 @@ exec command=tar xfz QATESTS.tgz dir=/tmp/phpruntests / -exec command=${php} -n /Users/zoe/Applications/PHP/php-5.4.0/run-tests.php -n -p ${php} /tmp/phpruntests/Zend /tmp/phpruntests/ext /tmp/phpruntests/sapi /tmp/phpruntests/tests ${project.basedir}/_compare/old.out dir=/tmp/phpruntests passthru=true checkReturn=true/ -exec command=${php} -n ${project.basedir}/src/run-tests.php -n -p ${php} -o csv -s ${project.basedir}/_compare/new.out /tmp/phpruntests dir=/tmp/phpruntests passthru=true checkReturn=true / +exec command=${php} -n ${php_to_test}/run-tests.php -n -p ${php_to_test}/sapi/cli/php /tmp/phpruntests/Zend /tmp/phpruntests/ext /tmp/phpruntests/sapi /tmp/phpruntests/tests ${project.basedir}/_compare/old.out dir=/tmp/phpruntests passthru=true checkReturn=true/ +exec command=${php} -n ${project.basedir}/src/run-tests.php -n -p ${php_to_test}/sapi/cli/php -o csv -s ${project.basedir}/_compare/new.out /tmp/phpruntests dir=/tmp/phpruntests passthru=true checkReturn=true / exec command=${php} -n QA/compareNewOld.php ${project.basedir}/_compare/new.out ${project.basedir}/_compare/old.out phpruntests ${project.basedir}/_compare/compare_new_old.out dir=${project.basedir} passthru=true checkReturn=true/ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php