MDL-51863 packer: ensure empty zip files behavior remains consistent
commit2ff58a3b052dbe5cf8165b60ce6f41954593b78f
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 26 Oct 2015 16:59:40 +0000 (26 17:59 +0100)
committerDan Poltawski <dan@moodle.com>
Tue, 27 Oct 2015 11:57:00 +0000 (27 11:57 +0000)
treec1c089ef7056d820a4722fc6acc7e71c3be6e747
parent6f3a4fb5c36c82fa82a1008baf70e607dea37b65
MDL-51863 packer: ensure empty zip files behavior remains consistent

With PHP bug #70322 fixed, ZipArchive::close() did start returning false
and throwing PHP Warnings with recent PHP versions (5.6.14 and up).
Previously (5.6.13 verified) it was returning true, and false in older
versions (5.4.x verified).

This change does silent the 2 "hacky" calls to close() that we perform
in core leaving the 3rd one (used for files having files) unmodified.

A new unit test has been created to cover the close() behavior, ideally
supporting both old and new PHP versions without harcoding any PHP
version.

Note that we don't use to rely much on results coming from close(), and
that's a good thing given the buggy behavior commented above. This just
keeps empty zips working like they were before.
lib/filestorage/tests/zip_packer_test.php
lib/filestorage/zip_archive.php