cataphract Fri, 24 Dec 2010 22:38:36 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=306627
Log: - Fixed bug #53603 (ZipArchive should quiet stat errors). #It is unclear if url_stat handlers should emit a warning in case #PHP_STREAM_URL_STAT_QUIET is not specified and the resource does #not exist. Most url_stat handlers never emit messages; the plain #one does only so in the extraordinary event of an open_basedir #restriction. #But in case, php_stat uses PHP_STREAM_URL_STAT_QUIET for the #FS_EXISTS, which suggests that mere checks on file existence are #supposed to use this flag (arguably). #The downside is that important diagnostic messages might be #omitted. Bug: http://bugs.php.net/53603 (Open) ZipArchive should quiet stat errors Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/zip/php_zip.c A php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt U php/php-src/trunk/ext/zip/php_zip.c A php/php-src/trunk/ext/zip/tests/bug53603.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-12-24 19:31:38 UTC (rev 306626) +++ php/php-src/branches/PHP_5_3/NEWS 2010-12-24 22:38:36 UTC (rev 306627) @@ -91,6 +91,8 @@ . Fixed bug #53568 (swapped memset arguments in struct initialization). (crrodriguez at opensuse dot org) . Fixed bug #53579 (stream_get_contents() segfaults on ziparchive streams) (Hannes) + . Fixed bug #53603 (ZipArchive should quiet stat errors). (brad dot froehle at + gmail dot com, Gustavo) 09 Dec 2010, PHP 5.3.4 - Upgraded bundled Sqlite3 to version 3.7.3. (Ilia) Modified: php/php-src/branches/PHP_5_3/ext/zip/php_zip.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/zip/php_zip.c 2010-12-24 19:31:38 UTC (rev 306626) +++ php/php-src/branches/PHP_5_3/ext/zip/php_zip.c 2010-12-24 22:38:36 UTC (rev 306627) @@ -196,7 +196,7 @@ } /* let see if the path already exists */ - if (php_stream_stat_path(file_dirname_fullpath, &ssb) < 0) { + if (php_stream_stat_path_ex(file_dirname_fullpath, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL) < 0) { #if defined(PHP_WIN32) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1) char *e; @@ -2378,7 +2378,7 @@ RETURN_FALSE; } - if (php_stream_stat_path(pathto, &ssb) < 0) { + if (php_stream_stat_path_ex(pathto, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL) < 0) { ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); if (!ret) { RETURN_FALSE; Added: php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/zip/tests/bug53603.phpt 2010-12-24 22:38:36 UTC (rev 306627) @@ -0,0 +1,38 @@ +--TEST-- +Bug #53603 (ZipArchive should quiet stat errors) +--SKIPIF-- +<?php +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +class TestStream { + function url_stat($path, $flags) { + if (!($flags & STREAM_URL_STAT_QUIET)) + trigger_error("not quiet"); + return array(); + } +} + +stream_wrapper_register("teststream", "TestStream"); + +$dirname = dirname(__FILE__) . '/'; +$file = $dirname . 'test_with_comment.zip'; +$zip = new ZipArchive; +if ($zip->open($file) !== TRUE) { + echo "open failed.\n"; + exit('failed'); +} + +$a = $zip->extractTo('teststream://test'); +var_dump($a); + +--EXPECTF-- +Warning: ZipArchive::extractTo(teststream://test/foo): failed to open stream: "TestStream::stream_open" call failed in %s on line %d + +Warning: ZipArchive::extractTo(teststream://test/bar): failed to open stream: "TestStream::stream_open" call failed in %s on line %d + +Warning: ZipArchive::extractTo(teststream://test/foobar/baz): failed to open stream: "TestStream::stream_open" call failed in %s on line %d +bool(true) + Modified: php/php-src/trunk/ext/zip/php_zip.c =================================================================== --- php/php-src/trunk/ext/zip/php_zip.c 2010-12-24 19:31:38 UTC (rev 306626) +++ php/php-src/trunk/ext/zip/php_zip.c 2010-12-24 22:38:36 UTC (rev 306627) @@ -196,7 +196,7 @@ } /* let see if the path already exists */ - if (php_stream_stat_path(file_dirname_fullpath, &ssb) < 0) { + if (php_stream_stat_path_ex(file_dirname_fullpath, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL) < 0) { #if defined(PHP_WIN32) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1) char *e; @@ -2379,7 +2379,7 @@ RETURN_FALSE; } - if (php_stream_stat_path(pathto, &ssb) < 0) { + if (php_stream_stat_path_ex(pathto, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL) < 0) { ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); if (!ret) { RETURN_FALSE; Added: php/php-src/trunk/ext/zip/tests/bug53603.phpt =================================================================== --- php/php-src/trunk/ext/zip/tests/bug53603.phpt (rev 0) +++ php/php-src/trunk/ext/zip/tests/bug53603.phpt 2010-12-24 22:38:36 UTC (rev 306627) @@ -0,0 +1,38 @@ +--TEST-- +Bug #53603 (ZipArchive should quiet stat errors) +--SKIPIF-- +<?php +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +class TestStream { + function url_stat($path, $flags) { + if (!($flags & STREAM_URL_STAT_QUIET)) + trigger_error("not quiet"); + return array(); + } +} + +stream_wrapper_register("teststream", "TestStream"); + +$dirname = dirname(__FILE__) . '/'; +$file = $dirname . 'test_with_comment.zip'; +$zip = new ZipArchive; +if ($zip->open($file) !== TRUE) { + echo "open failed.\n"; + exit('failed'); +} + +$a = $zip->extractTo('teststream://test'); +var_dump($a); + +--EXPECTF-- +Warning: ZipArchive::extractTo(teststream://test/foo): failed to open stream: "TestStream::stream_open" call failed in %s on line %d + +Warning: ZipArchive::extractTo(teststream://test/bar): failed to open stream: "TestStream::stream_open" call failed in %s on line %d + +Warning: ZipArchive::extractTo(teststream://test/foobar/baz): failed to open stream: "TestStream::stream_open" call failed in %s on line %d +bool(true) +
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
