From: Greg Beaver Date: Sun, 26 Jul 2009 01:24:12 +0000 (+0000) Subject: fix basic phar test issues, failing tests phar_oo_009.phpt and phar_buildfromiterator... X-Git-Tag: php-5.3.1RC1~268 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66908185b72d42eadc505af14c5e561e5e4679be;p=php fix basic phar test issues, failing tests phar_oo_009.phpt and phar_buildfromiterator10.phpt are due to bugs in Spl --- diff --git a/ext/phar/stream.c b/ext/phar/stream.c index e8d80ce684..a357ba0da5 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -207,18 +207,30 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *pat fpf = php_stream_alloc(&phar_ops, idata, NULL, mode); php_url_free(resource); efree(internal_file); +#if PHP_MAJOR_VERSION >= 6 + if (context && context->options && phar_find_key(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption TSRMLS_CC)) { +#else if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) { +#endif pharcontext = HASH_OF(*pzoption); if (idata->internal_file->uncompressed_filesize == 0 && idata->internal_file->compressed_filesize == 0 +#if PHP_MAJOR_VERSION >= 6 + && phar_find_key(pharcontext, "compress", sizeof("compress"), (void**)&pzoption TSRMLS_CC) +#else && zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS +#endif && Z_TYPE_PP(pzoption) == IS_LONG && (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0 ) { idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK; idata->internal_file->flags |= Z_LVAL_PP(pzoption); } +#if PHP_MAJOR_VERSION >= 6 + if (phar_find_key(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption TSRMLS_CC)) { +#else if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) { +#endif if (idata->internal_file->metadata) { zval_ptr_dtor(&idata->internal_file->metadata); idata->internal_file->metadata = NULL; diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt index 66587de023..d6c469d9cb 100755 --- a/ext/phar/tests/create_new_and_modify.phpt +++ b/ext/phar/tests/create_new_and_modify.phpt @@ -27,9 +27,9 @@ file_put_contents($pname .'/b.php', "another!\n"); $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'; diff --git a/ext/phar/tests/phar_ctx_001.phpt b/ext/phar/tests/phar_ctx_001.phpt index 14b7afc71c..72edc5a99e 100644 --- a/ext/phar/tests/phar_ctx_001.phpt +++ b/ext/phar/tests/phar_ctx_001.phpt @@ -28,7 +28,7 @@ var_dump($phar['b']->isCompressed()); 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 diff --git a/ext/phar/tests/readfile_edgecases.phpt b/ext/phar/tests/readfile_edgecases.phpt index 1a78d7b5b0..2c93c8b221 100644 --- a/ext/phar/tests/readfile_edgecases.phpt +++ b/ext/phar/tests/readfile_edgecases.phpt @@ -2,6 +2,7 @@ Phar: test edge cases of readfile() function interception --SKIPIF-- +=")) die("skip requires php older than 6.0"); ?> --INI-- phar.readonly=0 --FILE-- diff --git a/ext/phar/tests/readfile_edgecasesU.phpt b/ext/phar/tests/readfile_edgecasesU.phpt new file mode 100644 index 0000000000..c26b45fc57 --- /dev/null +++ b/ext/phar/tests/readfile_edgecasesU.phpt @@ -0,0 +1,61 @@ +--TEST-- +Phar: test edge cases of readfile() function interception +--SKIPIF-- + + +--INI-- +phar.readonly=0 +--FILE-- + +'); +include $pname . '/foo/hi'; +?> +===DONE=== +--CLEAN-- + + + +--EXPECTF-- +blah + +test +test + + +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