Home › Forums › Calendar Products › Events Calendar PRO › PHP Notice when deleting images via wp_delete_attachment
- This topic has 6 replies, 3 voices, and was last updated 8 years, 3 months ago by
Peter.
-
AuthorPosts
-
November 16, 2017 at 7:08 pm #1385224
Peter
ParticipantI have a plugin that is set to delete feature images when its parent post (a custom post type not linked to ECP at all). When the image is delete I am getting the following error, seems to happen for all images. I have ECP installed but no data in it yet so there should be no association at all with any images. But stuck on this one so any help would be awesome, Thanks!
[17-Nov-2017 02:58:29 UTC] PHP Notice: Trying to get property of non-object in /srv/www/MYINSTALL/public_html/wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php on line 48
November 17, 2017 at 4:23 pm #1386128Cliff
MemberHi, Peter. Thanks for reporting this.
It’s the first I’ve heard of it so could you please share the full PHP Stack Trace (visible in your debug.log file if you have logging enabled).
If you don’t already, please enable WP_DEBUG and WP_DEBUG_LOG (which will create a file on your server at /wp-content/debug.log if there are any WP_DEBUG messages) and share any debug messages you see.
Also, can you replicate this issue when all but Modern Tribe plugins are deactivated?
Please let me know what you find out.
November 22, 2017 at 4:36 pm #1389572Peter
ParticipantHello Cliff,
Sorry for the delay its been a crazy week.
The only error that appears is:
[23-Nov-2017 00:31:19 UTC] PHP Notice: Trying to get property of
non-object in
/srv/www/portlincoln/public_html/wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php
on line 48This appears to only happen when deleting attachments,
wp_delete_attachment( $attachment_id, true );I assume your tribe_is_recurring_event is being triggered when removing
all posts? I have printed out the post object before line 48 calls it and
it seems every second call the object is empty.November 27, 2017 at 11:33 pm #1393423Cliff
MemberHi, Peter. Sorry for the delayed reply on my end over the holiday and weekend.
Thanks for your detailed reply.
This function actually runs very often — on every page load and even Ajax requests.
I wasn’t able to duplicate the error exactly as you stated — specific to deleting any single attachment — but clicking all around the Media Library seemed to randomly trigger it (twice out of dozens of clicks, in my case).
I’ve submitted a bug report for our developers to review.
I marked this thread as Pending Fix, which means it should receive a reply once the applicable fix has been released. I cannot guarantee when it will be fixed as it’s in the development team’s hands now. They need to assign it, code it, test it, and schedule it for release.
I apologize for this issue and appreciate your understanding and patience.
If you’re comfortable changing the core plugin’s code yourself (as a temporary test), you could change Line 42 from
if ( false === $post_id ) {to
if ( empty( $post_id ) ) {and see if that resolves the issue for you.
December 19, 2017 at 12:23 pm #1409073Courtney
MemberHey there Peter
We’ve just released an update that should fix this bug. You can read more about it at http://m.tri.be/19tp. Please update your plugins and let us know if you are still experiencing this or if we can close out this ticket.
Note: We suggest testing updates on a staging server (https://theeventscalendar.com/knowledgebase/creating-using-wordpress-staging-site/).
Thanks
Courtney 🙂January 10, 2018 at 8:37 am #1422491Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘PHP Notice when deleting images via wp_delete_attachment’ is closed to new replies.
