cellog Sun, 26 Jul 2009 01:24:12 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=286339
Log: fix basic phar test issues, failing tests phar_oo_009.phpt and phar_buildfromiterator10.phpt are due to bugs in Spl Changed paths: U pecl/phar/trunk/stream.c U pecl/phar/trunk/tests/create_new_and_modify.phpt U pecl/phar/trunk/tests/phar_ctx_001.phpt U pecl/phar/trunk/tests/readfile_edgecases.phpt A pecl/phar/trunk/tests/readfile_edgecasesU.phpt U php/php-src/branches/PHP_5_3/ext/phar/stream.c U php/php-src/branches/PHP_5_3/ext/phar/tests/create_new_and_modify.phpt U php/php-src/branches/PHP_5_3/ext/phar/tests/phar_ctx_001.phpt U php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecases.phpt A php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecasesU.phpt U php/php-src/trunk/ext/phar/stream.c U php/php-src/trunk/ext/phar/tests/create_new_and_modify.phpt U php/php-src/trunk/ext/phar/tests/phar_ctx_001.phpt U php/php-src/trunk/ext/phar/tests/readfile_edgecases.phpt
Modified: pecl/phar/trunk/stream.c =================================================================== --- pecl/phar/trunk/stream.c 2009-07-26 01:03:47 UTC (rev 286338) +++ pecl/phar/trunk/stream.c 2009-07-26 01:24:12 UTC (rev 286339) @@ -207,18 +207,30 @@ 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; Modified: pecl/phar/trunk/tests/create_new_and_modify.phpt =================================================================== --- pecl/phar/trunk/tests/create_new_and_modify.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ pecl/phar/trunk/tests/create_new_and_modify.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -27,9 +27,9 @@ $phar = new Phar($fname); $sig2 = $phar->getSignature(); -var_dump($sig1['hash']); -var_dump($sig2['hash']); -var_dump($sig1['hash'] != $sig2['hash']); +var_dump($sig1[b'hash']); +var_dump($sig2[b'hash']); +var_dump($sig1[b'hash'] != $sig2[b'hash']); include $pname . '/a.php'; include $pname . '/b.php'; Modified: pecl/phar/trunk/tests/phar_ctx_001.phpt =================================================================== --- pecl/phar/trunk/tests/phar_ctx_001.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ pecl/phar/trunk/tests/phar_ctx_001.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -28,7 +28,7 @@ var_dump(file_get_contents($pname . '/c')); var_dump($phar['c']->isCompressed()); -$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, 'hi' => 3)))); +$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3)))); $context2 = stream_context_create(array('phar' => array('metadata' => array(4)))); file_put_contents($pname . '/a', b'new a', 0); // no compression Modified: pecl/phar/trunk/tests/readfile_edgecases.phpt =================================================================== --- pecl/phar/trunk/tests/readfile_edgecases.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ pecl/phar/trunk/tests/readfile_edgecases.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -2,6 +2,7 @@ Phar: test edge cases of readfile() function interception --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip");?> +<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?> --INI-- phar.readonly=0 --FILE-- Added: pecl/phar/trunk/tests/readfile_edgecasesU.phpt =================================================================== --- pecl/phar/trunk/tests/readfile_edgecasesU.phpt (rev 0) +++ pecl/phar/trunk/tests/readfile_edgecasesU.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -0,0 +1,61 @@ +--TEST-- +Phar: test edge cases of readfile() function interception +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip");?> +<?php if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires php 6.0 or newer"); ?> +--INI-- +phar.readonly=0 +--FILE-- +<?php +Phar::interceptFileFuncs(); +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; + +chdir(dirname(__FILE__)); +file_put_contents($fname, "blah\n"); +file_put_contents("foob", "test\n"); +readfile($fname); +unlink($fname); +mkdir($pname . '/oops'); +file_put_contents($pname . '/foo/hi', '<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("' . addslashes(dirname(__FILE__)) . '"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> +'); +include $pname . '/foo/hi'; +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> +<?php rmdir(dirname(__FILE__) . '/poo'); ?> +<?php unlink(dirname(__FILE__) . '/foob'); ?> +--EXPECTF-- +blah +<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("%stests"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> +test +test +<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("%stests"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> + +Warning: readfile(phar://%sreadfile_edgecasesU.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecasesU.phar.php/foo/hi on line %d +===DONE=== \ No newline at end of file Modified: php/php-src/branches/PHP_5_3/ext/phar/stream.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/phar/stream.c 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/branches/PHP_5_3/ext/phar/stream.c 2009-07-26 01:24:12 UTC (rev 286339) @@ -207,18 +207,30 @@ 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; Modified: php/php-src/branches/PHP_5_3/ext/phar/tests/create_new_and_modify.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/phar/tests/create_new_and_modify.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/branches/PHP_5_3/ext/phar/tests/create_new_and_modify.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -27,9 +27,9 @@ $phar = new Phar($fname); $sig2 = $phar->getSignature(); -var_dump($sig1['hash']); -var_dump($sig2['hash']); -var_dump($sig1['hash'] != $sig2['hash']); +var_dump($sig1[b'hash']); +var_dump($sig2[b'hash']); +var_dump($sig1[b'hash'] != $sig2[b'hash']); include $pname . '/a.php'; include $pname . '/b.php'; Modified: php/php-src/branches/PHP_5_3/ext/phar/tests/phar_ctx_001.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/phar/tests/phar_ctx_001.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/branches/PHP_5_3/ext/phar/tests/phar_ctx_001.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -28,7 +28,7 @@ var_dump(file_get_contents($pname . '/c')); var_dump($phar['c']->isCompressed()); -$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, 'hi' => 3)))); +$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3)))); $context2 = stream_context_create(array('phar' => array('metadata' => array(4)))); file_put_contents($pname . '/a', b'new a', 0); // no compression Modified: php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecases.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecases.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecases.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -2,6 +2,7 @@ Phar: test edge cases of readfile() function interception --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip");?> +<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?> --INI-- phar.readonly=0 --FILE-- Added: php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecasesU.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecasesU.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/phar/tests/readfile_edgecasesU.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -0,0 +1,61 @@ +--TEST-- +Phar: test edge cases of readfile() function interception +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip");?> +<?php if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires php 6.0 or newer"); ?> +--INI-- +phar.readonly=0 +--FILE-- +<?php +Phar::interceptFileFuncs(); +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; + +chdir(dirname(__FILE__)); +file_put_contents($fname, "blah\n"); +file_put_contents("foob", "test\n"); +readfile($fname); +unlink($fname); +mkdir($pname . '/oops'); +file_put_contents($pname . '/foo/hi', '<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("' . addslashes(dirname(__FILE__)) . '"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> +'); +include $pname . '/foo/hi'; +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> +<?php rmdir(dirname(__FILE__) . '/poo'); ?> +<?php unlink(dirname(__FILE__) . '/foob'); ?> +--EXPECTF-- +blah +<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("%stests"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> +test +test +<?php +readfile("foo/" . basename(__FILE__)); +$context = stream_context_create(); +readfile("foob"); +set_include_path("%stests"); +readfile("foob", true); +readfile("./hi", 0, $context); +readfile("../oops"); +?> + +Warning: readfile(phar://%sreadfile_edgecasesU.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecasesU.phar.php/foo/hi on line %d +===DONE=== \ No newline at end of file Modified: php/php-src/trunk/ext/phar/stream.c =================================================================== --- php/php-src/trunk/ext/phar/stream.c 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/trunk/ext/phar/stream.c 2009-07-26 01:24:12 UTC (rev 286339) @@ -207,18 +207,30 @@ 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; Modified: php/php-src/trunk/ext/phar/tests/create_new_and_modify.phpt =================================================================== --- php/php-src/trunk/ext/phar/tests/create_new_and_modify.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/trunk/ext/phar/tests/create_new_and_modify.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -27,9 +27,9 @@ $phar = new Phar($fname); $sig2 = $phar->getSignature(); -var_dump($sig1['hash']); -var_dump($sig2['hash']); -var_dump($sig1['hash'] != $sig2['hash']); +var_dump($sig1[b'hash']); +var_dump($sig2[b'hash']); +var_dump($sig1[b'hash'] != $sig2[b'hash']); include $pname . '/a.php'; include $pname . '/b.php'; @@ -40,8 +40,8 @@ <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- brand new! -%unicode|string%(40) "%s" -%unicode|string%(40) "%s" +string(40) "%s" +string(40) "%s" bool(true) modified! another! Modified: php/php-src/trunk/ext/phar/tests/phar_ctx_001.phpt =================================================================== --- php/php-src/trunk/ext/phar/tests/phar_ctx_001.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/trunk/ext/phar/tests/phar_ctx_001.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -28,7 +28,7 @@ var_dump(file_get_contents($pname . '/c')); var_dump($phar['c']->isCompressed()); -$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, 'hi' => 3)))); +$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3)))); $context2 = stream_context_create(array('phar' => array('metadata' => array(4)))); file_put_contents($pname . '/a', b'new a', 0); // no compression Modified: php/php-src/trunk/ext/phar/tests/readfile_edgecases.phpt =================================================================== --- php/php-src/trunk/ext/phar/tests/readfile_edgecases.phpt 2009-07-26 01:03:47 UTC (rev 286338) +++ php/php-src/trunk/ext/phar/tests/readfile_edgecases.phpt 2009-07-26 01:24:12 UTC (rev 286339) @@ -2,6 +2,7 @@ Phar: test edge cases of readfile() function interception --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip");?> +<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?> --INI-- phar.readonly=0 --FILE--
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php