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

EE 7.4.9 Trying to access array offset on value of type bool ee/legacy/libraries/Image_lib.php, line 1386 #4319

Closed
robinsowell opened this issue May 15, 2024 · 0 comments · Fixed by #4323
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.

Comments

@robinsowell
Copy link
Contributor

I don't have a setup to replicate, but in the code, we're doing:

       $vals = @getimagesize($path);
		
        $types = array(IMAGETYPE_GIF => 'gif', IMAGETYPE_JPEG => 'jpeg', IMAGETYPE_PNG => 'png', '18' => 'webp');
		
        $mime = (isset($types[$vals['2']])) ? 'image/' . $types[$vals['2']] : 'image/jpg';

        if ($return == true) {
            $v['width'] = $vals['0'];
            $v['height'] = $vals['1'];
            $v['image_type'] = $vals['2'];
            $v['size_str'] = $vals['3'];
            $v['mime_type'] = $mime;

            return $v;
  etc

isset($types[$vals['2']]) throws the error if getimagesize($path) is false. And fwiw, per https://www.php.net/manual/en/function.getimagesize.php

Caution
This function expects filename to be a valid image file. If a non-image file is supplied, it may be incorrectly detected as an image and the function will return successfully, but the array may contain nonsensical values.

So I'm a little iffy on defaulting to jpeg instead of just bailing out if '2' isn't set. But I'm also not sure that a valid image couldn't do that, so leaving that for another day.

But we either need to bail with feedback when getimagesize($path); is false or have a default set of $v we can return, which seems problematic.

@robinsowell robinsowell added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label May 15, 2024
bryannielsen added a commit that referenced this issue May 21, 2024
…esize-errors

Resolved #4319 by showing an error when image properties can't be gathered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.
Projects
None yet
1 participant