Skip to content

Fix #80648: Fix for bug 79296 should be based on runtime version #6625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jan 20, 2021

This should go into PHP-7.4 only, since that fallback is removed as of PHP 8.0.0 altogether.

@remicollet, what do you think?

@cmb69 cmb69 added the Bug label Jan 20, 2021
@aboks
Copy link
Contributor

aboks commented Jan 20, 2021

@cmb69 Thanks for the quick patch!

This should go into PHP-7.4 only, since that fallback is removed as of PHP 8.0.0 altogether.

Just to clarify, the fallback is not removed as of PHP 8.0.0. It is just deprecated and not dependent on the libzip version anymore. The latter is probably because PHP 8.0.0 can only be used with newer versions of libzip, so that the >= 1.6.0 version constraint is necessarily true.

@remicollet
Copy link
Member

remicollet commented Jan 20, 2021

Simpler way is to drop version check (as in PHP 8, without the warning).

In short, before 1.6.0 ZIP_TRUNCATE is implicit for empty file, so always adding it is not a problem

P.S. so have to add the #ifdef ZIP_RDONLY which only exists in v1+ and 0.11 is still supported

@remicollet
Copy link
Member

remicollet commented Jan 20, 2021

@aboks also notice that code pasted in referenced issue is wrong... will raise a warnign with PHP 8 and will fail in the future ;)

Should be (as tempnam create an empty file, which is NOT a valid archive)

<?php
$zipfile_path = tempnam(sys_get_temp_dir(), "zip");
$zip_archive = new \ZipArchive();
var_dump($zip_archive->open($zipfile_path, \ZipArchive::TRUNCATE));

@cmb69
Copy link
Member Author

cmb69 commented Jan 20, 2021

Simpler way is to drop version check (as in PHP 8, without the warning).

Makes sense to me.

@remicollet remicollet self-requested a review January 20, 2021 14:28
Copy link
Member

@remicollet remicollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants