Skip to content
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

Fatal fread() error when upgrading extras #16636

Open
davidpede opened this issue Oct 24, 2024 · 1 comment
Open

Fatal fread() error when upgrading extras #16636

davidpede opened this issue Oct 24, 2024 · 1 comment
Labels
bug The issue in the code or project, which should be addressed.

Comments

@davidpede
Copy link
Contributor

Bug report

Summary

I am getting a fatal 500 error when upgrading the Fred extra:
PHP Fatal error: Uncaught ValueError: fread(): Argument #2 ($length) must be greater than 0 in /core/xpdo/compression/pclzip.lib.php:2680

Is caused by empty files in the extra such as: https://github.com/modxcms/fred/blob/main/assets/components/fred/index.html

I believe this is a PHP 8+ compatibility issue as fatal errors can no longer be supressed: https://php.watch/versions/8.0/fatal-error-suppression

Step to reproduce

Install or upgrade an extra such as Fred that contains zero byte files.

Observed behavior

Install fails with fatal 500 error:
PHP Fatal error: Uncaught ValueError: fread(): Argument #2 ($length) must be greater than 0 in /core/xpdo/compression/pclzip.lib.php:2680

Related code:

$v_content = @fread($v_file, $p_header['size']);

Expected behavior

Extra should install successfully.

Environment

MODX 2.8.7-pl, PHP 8.2

@davidpede davidpede added the bug The issue in the code or project, which should be addressed. label Oct 24, 2024
@halftrainedharry
Copy link
Contributor

This seems to be a duplicate of this issue in the xPDO repository.

The problem is the PclZip library (that is no longer maintained). PclZip is only used if your PHP installation doesn't have the zip extension (or if the system setting archive_with is explicitely set).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

No branches or pull requests

2 participants