note 119960 added to ziparchive.close
| From: | javier dot santacruz at avature dot net | Date: | Wed, 28 Sep 2016 11:06:00 +0000 |
| Subject: | note 119960 added to ziparchive.close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206695@lists.php.net to get a copy of this message | ||
ZipArchive.close() changes its behaviour in PHP7. The function ignores directories in PHP5 but fails
in PHP7 with:
Unexpected PHP error [ZipArchive::close(): Read error: Is a directory]
The following code works in PHP5 but not in PHP7:
<?php
// test.php
$zip = new ZipArchive();
$zip->open('/tmp/test.zip', ZipArchive::CREATE);
$zip->addFile('.', '.');
$ret = $zip->close();
echo "Closed with: " . ($ret ? "true" : "false") . "\n";
?>
For php5:
php --version
PHP 5.5.38-1-avature-ondrej-fork (cli) (built: Aug 31 2016 16:37:38)
php test.php
Closed with: true
For php7:
php --version
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
php test.php
Closed with: false
----
Server IP: 72.52.91.14
Probable Submitter: 212.0.97.74
----
Manual Page -- http://php.net/manual/en/ziparchive.close.php
Edit -- https://master.php.net/note/edit/119960
Del: integrated -- https://master.php.net/note/delete/119960/integrated
Del: useless -- https://master.php.net/note/delete/119960/useless
Del: bad code -- https://master.php.net/note/delete/119960/bad+code
Del: spam -- https://master.php.net/note/delete/119960/spam
Del: non-english -- https://master.php.net/note/delete/119960/non-english
Del: in docs -- https://master.php.net/note/delete/119960/in+docs
Del: other reasons-- https://master.php.net/note/delete/119960
Reject -- https://master.php.net/note/reject/119960
Search -- https://master.php.net/manage/user-notes.php