From: Greg Beaver Date: Mon, 14 Apr 2008 04:44:04 +0000 (+0000) Subject: more test coverage and fixes from increased coverage to opendir(). dir.phpt fails... X-Git-Tag: RELEASE_2_0_0b1~429 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e69ea0731dadb4bf6573713b468058f17c2eaa4d;p=php more test coverage and fixes from increased coverage to opendir(). dir.phpt fails, but for wrong reasons (bug uncovered that needs fix) --- diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index aaca07a7cd..5da223ade1 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -297,6 +297,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char uint host_len; if ((resource = phar_open_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar url \"%s\" is unknown", path); return NULL; } @@ -336,6 +337,8 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char if (error) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error); efree(error); + } else { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar file \"%s\" is unknown", resource->host); } php_url_free(resource); return NULL; @@ -510,7 +513,6 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", %s", entry.filename, phar->fname, error); zend_hash_del(&phar->manifest, entry.filename, entry.filename_len); efree(error); - efree(entry.filename); return FAILURE; } return SUCCESS; diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt index ca279ac87c..be28f4d529 100755 --- a/ext/phar/tests/027.phpt +++ b/ext/phar/tests/027.phpt @@ -50,6 +50,9 @@ echo "fwrite on dir handle\n"; var_dump(fwrite($a, 'hi')); var_dump(fstat($a)); closedir($a); +echo "opendir edge cases\n"; +var_dump(opendir("phar://")); +var_dump(opendir("phar://foo.phar/hi")); ?> ===DONE=== --CLEAN-- @@ -79,4 +82,11 @@ int(1) fwrite on dir handle int(0) bool(false) +opendir edge cases + +Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar) in %s027.php on line %d +bool(false) + +Warning: opendir(phar://foo.phar/hi): failed to open dir: phar url "phar://foo.phar/hi" is unknown in %s027.php on line %d +bool(false) ===DONE=== diff --git a/ext/phar/tests/dir.phpt b/ext/phar/tests/dir.phpt index 7071fcb5d8..233e28c682 100644 --- a/ext/phar/tests/dir.phpt +++ b/ext/phar/tests/dir.phpt @@ -28,12 +28,17 @@ clearstatcache(); var_dump(file_exists($pname . '/another/dir/')); var_dump(file_exists($pname2 . '/test/')); var_dump(file_exists($pname3 . '/another/dir/')); +ini_set('phar.readonly', 1); +mkdir($pname . '/fails'); +ini_set('phar.readonly', 0); +mkdir('phar://oops.phar/fails'); ?> +===DONE=== --CLEAN-- ---EXPECT-- +--EXPECTF-- bool(true) bool(true) bool(true) @@ -41,3 +46,6 @@ bool(true) bool(false) bool(true) bool(false) + +Warning: mkdir(): phar error: cannot create directory "phar://%sdir.phar.php/fails", write operations disabled in %sdir.php on line %d +===DONE=== \ No newline at end of file