Skip to content

PHP 8+ error in isBinary() method when trying to open a resource in the bucket that is not accessible #26

@garryn

Description

@garryn

Found a problem on a MODX Cloud site today that was using PHP 8.1 related to binary resources and the resource in question not having the ACLs required to be accessed.

The problem is in core/components/awss3mediasource/model/awss3mediasource/awss3mediasource.class.php on line 341.

The error suppression on the fread no longer works in PHP 8+ and will cause a fatal PHP error that stops any of the resources loading in the Media Source view in the Manager when the file being processed returns false from the fopen - for example, a 403 Forbidden response.

My fix was to add an explicit check right after the fopen:

if ($fh == false) { return false;}

That way, processing continues and valid resources will still be able to be displayed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions