Skip to content

Check for existing $metadata['sizes'] to reduce PHP warnings #632

Closed

Description

@jamesozzie

Bug Description

As raised in the support forums users may encounter ... is undefined PHP warnings, possibly due to there not being image size arrays in the image metadata.

To lessen the likelihood of such errors check does $metadata['sizes'] in the webp-uploads/load.php file exist here, and if so exit early.

In this users example the error appeared as below:

Warning: Undefined array key “sizes” in /…/plugins/performance-lab/modules/images/webp-uploads/load.php on line 594

Warning: foreach() argument must be of type array|object, null given in /…/plugins/performance-lab/modules/images/webp-uploads/load.php on line 594

Screenshots

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: [e.g. 22]
  • Device: [e.g. iPhone6]

Activity

  1. added this to the 2.0.0 milestone on Jan 27, 2023
  2. added
    InfrastructureIssues for the overall performance plugin infrastructure
    on Feb 6, 2023
  3. added
    Needs DevAnything that requires development (e.g. a pull request)
    on Feb 6, 2023
  4. removed
    Needs DevAnything that requires development (e.g. a pull request)
    on Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions