Support » Plugin: Safe SVG » Notice trying to get property ID

  • Resolved killua99

    (@killua99)


    Hi,

    The latest version of this plugin is causing a notice.

    ] PHP Notice: Trying to get property 'ID' of non-object in /www/xxxx/wp-content/plugins/safe-svg/safe-svg.php on line 407

    What would be the steps to fix this, or to solve this minor issue

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Daryll Doyle

    (@enshrined)

    Hey @killua99,

    That’s a strange one, the line you reference is the second line in this function:

    public function fix_direct_image_output( $attr, $attachment, $size ) {
                $mime = get_post_mime_type( $attachment->ID );

    As per the documentation for the filter that this function is hooked into (See here) the second argument should be an instance of WP_Post.

    I would guess that another plugin is calling this filter and passing the wrong parameter types through.

    Safe SVG could potentially check for the WP_Post type inside that function before using it to save the notice, but ultimately the issue is elsewhere.

    Do you have any other media plugins installed that may be causing this?

    Cheers,
    Daryll

    Sorry that I didn’t mention it, yes, I knew it was another plugin that was doing that. I skip the debugging to actually track the entire runtime. But caught me it was the only Notice I was getting.

    This is the plugin that I thing was causing it https://github.com/bueltge/multisite-global-media

    But well, I think I’ve more than once plugin that use the same hook, but this plugin was the only one causing that message. Nothing wrong with the plugin, but could be cool to have a check for WP_Post instanceof of the $attachment in case something is wrong.

    Plugin Author Daryll Doyle

    (@enshrined)

    Got a fix for this in the next release. Closing now 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Notice trying to get property ID’ is closed to new replies.