Skip to content

500 error when saving page #941

Closed
Closed

Description

@nomadic-energy-dev

Saving some pages with the Cloudinary plugin installed causes the following error: Undefined array key "full" {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined array key "full" at /home/devadmin/sites/test/public/public/content/plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php:874

It appears that an image has been cropped, but there's no "full" meta data for the width, so the plugin throws an exception and exits.

Additional context

cloudinary-report-1708942593.json

Activity

  1. nomadic-energy-dev commented on Feb 26, 2024

    @nomadic-energy-dev
    Author

    Additional info from local debugging: this is the unserialized meta data from one of the images causing the error:

    This is the raw unserialized meta data from the database:

    Array
    (
    [width] => 100
    [height] => 100
    [file] => Website-Icons-68.svg
    [sizes] => Array
    (
    [thumbnail] => Array
    (
    [width] => 150
    [height] => 150
    [crop] => 1
    [file] => Website-Icons-68.svg
    [mime-type] => image/svg+xml
    )

            [medium] => Array
                (
                    [width] => 300
                    [height] => 300
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [medium_large] => Array
                (
                    [width] => 768
                    [height] => 0
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [large] => Array
                (
                    [width] => 1024
                    [height] => 1024
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [1536x1536] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [2048x2048] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [woocommerce_thumbnail] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                    [uncropped] => 
                )
    
            [woocommerce_single] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [woocommerce_gallery_thumbnail] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [shop_catalog] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [shop_single] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [shop_thumbnail] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
            [dgwt-wcas-product-suggestion] => Array
                (
                    [width] => 
                    [height] => 
                    [crop] => 
                    [file] => Website-Icons-68.svg
                    [mime-type] => image/svg+xml
                )
    
        )
    

    )

    This is the var_dump of the meta the plugin is using at the point of exception - you can see the width and height is missing:

    array(4) {
    ["width"]=>
    int(0)
    ["height"]=>
    int(0)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["sizes"]=>
    array(10) {
    ["woocommerce_thumbnail"]=>
    array(6) {
    ["width"]=>
    bool(false)
    ["height"]=>
    bool(false)
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    ["uncropped"]=>
    bool(false)
    }
    ["woocommerce_gallery_thumbnail"]=>
    array(5) {
    ["width"]=>
    bool(false)
    ["height"]=>
    bool(false)
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["woocommerce_single"]=>
    array(5) {
    ["width"]=>
    bool(false)
    ["height"]=>
    bool(false)
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["dgwt-wcas-product-suggestion"]=>
    array(5) {
    ["width"]=>
    bool(false)
    ["height"]=>
    bool(false)
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["thumbnail"]=>
    array(5) {
    ["width"]=>
    string(3) "150"
    ["height"]=>
    string(3) "150"
    ["crop"]=>
    string(1) "1"
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["medium"]=>
    array(5) {
    ["width"]=>
    string(3) "300"
    ["height"]=>
    string(3) "300"
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["medium_large"]=>
    array(5) {
    ["width"]=>
    string(3) "768"
    ["height"]=>
    string(1) "0"
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["large"]=>
    array(5) {
    ["width"]=>
    string(4) "1024"
    ["height"]=>
    string(4) "1024"
    ["crop"]=>
    bool(false)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["1536x1536"]=>
    array(5) {
    ["width"]=>
    int(1536)
    ["height"]=>
    int(1536)
    ["crop"]=>
    int(0)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    ["2048x2048"]=>
    array(5) {
    ["width"]=>
    int(2048)
    ["height"]=>
    int(2048)
    ["crop"]=>
    int(0)
    ["file"]=>
    string(20) "Website-Icons-68.svg"
    ["mime-type"]=>
    string(13) "image/svg+xml"
    }
    }
    }

  2. nomadic-energy-dev commented on Feb 26, 2024

    @nomadic-energy-dev
    Author

    This was directly related to SVG support in Wordpress. The SVG plug we were using (SVG Support - most popular!) was not setting the widths for SVGs where WP's attachment functions were not.

    We installed a different plugin (Safe SVG) and the problem is solved.

    I think there is still a bug here where if this does happen, it would be useful to set a default or to throw an error more helpful to customers to find a solution rather than spending time debugging core WP attachment handling and Cloudinary's plugin code.

  3. Vdeub-cloudinary commented on Feb 26, 2024

    @Vdeub-cloudinary

    Hi @nomadic-energy-dev, Is it only a specific SVG that was throwing the error? Would you have the SVG in question so I can have a look? Could you also share if SVG Support under the Cloudinary Image settings was enabled?. Thanks!

  4. nomadic-energy-dev commented on Mar 12, 2024

    @nomadic-energy-dev
    Author

    Thanks - enabling svg support resolved this. Could we improve error handling to catch and report a more useful error in this case?

  5. Vdeub-cloudinary commented on Mar 13, 2024

    @Vdeub-cloudinary

    @nomadic-energy-dev awesome news! Glad it fixed the issue. I'll share this with our development team in case there is anything they can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions