Skip to content

Commit 42c0fc5

Browse files
committed
Merge branch 'hotfix/3.0.3'
2 parents 810b7ca + 6688f47 commit 42c0fc5

6 files changed

Lines changed: 22 additions & 20 deletions

File tree

.codeclimate.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ cache:
1212
- vendor
1313
- $HOME/.composer/cache
1414

15-
addons:
16-
code_climate:
17-
repo_token: 486a09d58d663450146c53c81c6c64938bcf3bb0b7c8ddebdc125fe97c18213a
18-
1915
install:
2016
- travis_retry composer self-update && composer --version
2117
- travis_retry composer install --prefer-dist --no-interaction
@@ -25,8 +21,4 @@ before_script:
2521

2622
script:
2723
- composer validate --no-check-lock
28-
- vendor/bin/phpunit -v -c bootstrap.xml --coverage-clover build/logs/clover.xml
29-
30-
after_success:
31-
- vendor/bin/test-reporter
32-
24+
- vendor/bin/phpunit -v -c bootstrap.xml

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.0.3 (2017-11-11)
2+
Fix bug issue #8 - Error if the file is empty.
3+
14
## 3.0.0 (2017-03-15)
25
Merge `ZipOutputFile` with ZipFile and optimize the zip archive update.
36

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![Latest Stable Version](https://poser.pugx.org/nelexa/zip/v/stable)](https://packagist.org/packages/nelexa/zip)
77
[![Total Downloads](https://poser.pugx.org/nelexa/zip/downloads)](https://packagist.org/packages/nelexa/zip)
88
[![Minimum PHP Version](http://img.shields.io/badge/php%2064bit-%3E%3D%205.5-8892BF.svg)](https://php.net/)
9-
[![Test Coverage](https://codeclimate.com/github/Ne-Lexa/php-zip/badges/coverage.svg)](https://codeclimate.com/github/Ne-Lexa/php-zip/coverage)
109
[![License](https://poser.pugx.org/nelexa/zip/license)](https://packagist.org/packages/nelexa/zip)
1110

1211
Table of contents

src/PhpZip/Model/Entry/ZipReadEntry.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ public function getEntryContent()
151151
fseek($this->inputStream, $pos);
152152

153153
// Get raw entry content
154-
$content = fread($this->inputStream, $this->getCompressedSize());
154+
$content = '';
155+
if ($this->getCompressedSize() > 0) {
156+
$content = fread($this->inputStream, $this->getCompressedSize());
157+
}
155158

156159
// Strong Encryption Specification - WinZip AES
157160
if ($this->isEncrypted()) {

tests/PhpZip/ZipFileTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PhpZip;
34

45
use PhpZip\Exception\ZipAuthenticationException;
@@ -1811,6 +1812,19 @@ public function testZipAlign()
18111812
self::assertTrue($result);
18121813
}
18131814

1815+
public function testEmptyContents()
1816+
{
1817+
$zipFile = new ZipFile();
1818+
$contents = '';
1819+
$zipFile->addFromString('file', $contents);
1820+
$zipFile->saveAsFile($this->outputFilename);
1821+
$zipFile->close();
1822+
1823+
$zipFile->openFile($this->outputFilename);
1824+
self::assertEquals($zipFile['file'], $contents);
1825+
$zipFile->close();
1826+
}
1827+
18141828
/**
18151829
* Test support ZIP64 ext (slow test - normal).
18161830
* Create > 65535 files in archive and open and extract to /dev/null.

0 commit comments

Comments
 (0)