Skip to content

Commit

Permalink
fix bug issue #8 - Error if the file is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne-Lexa committed Nov 11, 2017
1 parent 810b7ca commit 6688f47
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
9 changes: 0 additions & 9 deletions .codeclimate.yml

This file was deleted.

10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ cache:
- vendor
- $HOME/.composer/cache

addons:
code_climate:
repo_token: 486a09d58d663450146c53c81c6c64938bcf3bb0b7c8ddebdc125fe97c18213a

install:
- travis_retry composer self-update && composer --version
- travis_retry composer install --prefer-dist --no-interaction
Expand All @@ -25,8 +21,4 @@ before_script:

script:
- composer validate --no-check-lock
- vendor/bin/phpunit -v -c bootstrap.xml --coverage-clover build/logs/clover.xml

after_success:
- vendor/bin/test-reporter

- vendor/bin/phpunit -v -c bootstrap.xml
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.3 (2017-11-11)
Fix bug issue #8 - Error if the file is empty.

## 3.0.0 (2017-03-15)
Merge `ZipOutputFile` with ZipFile and optimize the zip archive update.

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

Table of contents
Expand Down
5 changes: 4 additions & 1 deletion src/PhpZip/Model/Entry/ZipReadEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ public function getEntryContent()
fseek($this->inputStream, $pos);

// Get raw entry content
$content = fread($this->inputStream, $this->getCompressedSize());
$content = '';
if ($this->getCompressedSize() > 0) {
$content = fread($this->inputStream, $this->getCompressedSize());
}

// Strong Encryption Specification - WinZip AES
if ($this->isEncrypted()) {
Expand Down
14 changes: 14 additions & 0 deletions tests/PhpZip/ZipFileTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace PhpZip;

use PhpZip\Exception\ZipAuthenticationException;
Expand Down Expand Up @@ -1811,6 +1812,19 @@ public function testZipAlign()
self::assertTrue($result);
}

public function testEmptyContents()
{
$zipFile = new ZipFile();
$contents = '';
$zipFile->addFromString('file', $contents);
$zipFile->saveAsFile($this->outputFilename);
$zipFile->close();

$zipFile->openFile($this->outputFilename);
self::assertEquals($zipFile['file'], $contents);
$zipFile->close();
}

/**
* Test support ZIP64 ext (slow test - normal).
* Create > 65535 files in archive and open and extract to /dev/null.
Expand Down

0 comments on commit 6688f47

Please sign in to comment.