Closed ollietreend closed 9 years ago
Actually, scratch that. I've just spent some time walking through the code, and I've been able to isolate the cause of the problem down to a custom save_post
hook located in my theme which is causing an infinite loop of save_post
calls. D'oh!
For the record, I was pleasantly surprised to see how straightforward and simple the TAO Schedule Update codebase is. Nice work!
Actually – I'm reopening this. I kept digging through the code, and it looks like the infinite loop was caused by something within the TAO Schedule Update plugin.
Currently the method self::prevent_status_change()
does not check if the old and new statuses are both equal to self::$TAO_PUBLISH_STATUS
. This causes an unnecessary call to wp_update_post()
even when nothing has changed, consequently firing off another round of save_post
hooks. In some situations (like mine) this can cause an infinite loop of post saves.
Aside from that, I also need to be notified when self::create_publishing_post()
has completed – i.e. once the entire post has been duplicated. Currently I can only hook into the save_post
action which is fired during the call to wp_insert_post()
, but before the call to self::copy_meta_and_terms()
– which isn't helpful, as at this point the post is only partially duplicated.
I have made the necessary changes to the plugin's code to accommodate the above two changes. I will submit a pull request to have these changes integrated into the plugin, as I feel that they are both valuable additions.
Duplicate #2
Hi,
I've been able to use this plugin successfully on a few different post types (pages, posts, and a custom post type). However I have a second custom post type which, upon clicking the 'Schedule Update' link, the page request times out and the post is not duplicated. Interestingly a new 'Scheduled Update' post is created, but it has no title or content associated with it.
As far as I'm aware, there is nothing different or unusual about the post type ('Report') which should cause the creation of the scheduled post to hang.
I've tested this on both WordPress 4.2.4 and 4.3 with identical results. I am running version 1.05 of the TAO Schedule Update plugin.
I have enabled XDebug on my development server, and I receive an instant 'fatal error' rather than the page timing out. I'm hoping that this will shed some light on what's happening, but I'd appreciate some help with interpreting the errors since I am not familiar with the internal workings of this plugin.
Here is a screenshot of the output from XDebug. It looks like there are lots of calls to the same functions, almost as if something gets stuck in a loop (which would explain the timeouts).
Can you shed any light on what might be causing the above? I'm going to be stepping through the plugin code to try and locate where this is happening, but I would value your insight and existing knowledge of the codebase.
Thanks