• Resolved pumka

    (@pumka)


    Hi!

    We use Broadcast on a WP network with sites utilizing hierarchical page structure a lot and we do not need to broadcast parent pages, just child ones. We noticed that in this case, if we save a child page on the source site, Broadcast plugin copies its changes to linked pages on target sites but resets parent page IDs there.

    I was able to trace the cause down to wp-content/plugins/threewp-broadcast/src/traits/broadcasting.php:301 where it sets ‘post_parent’ property to zero. It later tries to find the parent page ID on a target site but fails because it is not liked via Broadcast.
    We just wanted to keep parent page the same and I find that if I unset new_post->post_parent property in a ‘threewp_broadcast_broadcasting_after_switch_to_blog’ action handler, then the post is getting saved w/o an error but post_parent field remains the same.

    While this workaround worked for us, I suggest that Broadcast logic should be changed so that other users wouldn’t be affected by the issue. I believe that if post_parent property would be unset instead of setting it to zero, this will eliminate unwanted parent reset while for posts/pages having their parents linked via Broadcast, this property would be still correctly initialized by later code.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author edward_plainview

    (@edward_plainview)

    The handling of the parent post during broadcasting is as designed: if the parent post is not broadcasted, it cannot set the correct parent.

    Luckily, there are already two solutions for the problem:

    1. Custom code that can protect the parent_post property during broadcasting
    or
    2. Using the Protect Child Properties add-on, which has a parent post checkbox.

    Plugin Author edward_plainview

    (@edward_plainview)

    The custom code being pieced together from the various snippets on the Broadcast documentation page.

    The general idea is: after switching to the blog, get the current parent post ID. Before switching back, update the post with the old parent post ID.

    Thread Starter pumka

    (@pumka)

    Hi, Edward!

    Thanks for the links! As I wrote I was able to implement a workaround myself by unsetting post_parent property in ‘threewp_broadcast_broadcasting_after_switch_to_blog’ action handler in my custom plugin. If the property is not found in the post object, WordPress would not update the corresponding field and thus existing parent would be kept.

    I just thought that if Broadcast couldn’t find a correct parent itself, it shouldn’t really reset the existing parent, and that’s quite easy to implement.
    But no problem if you assume that resetting the parent is a correct behavior here.

    • This reply was modified 5 years, 11 months ago by pumka.
    Plugin Author edward_plainview

    (@edward_plainview)

    Seeing as it’s been this way for year, it would be very unwise to change how Broadcast works all of a sudden. People get used to things working in a specific way and when things change (apparently for no reason) then people get inconvenienced / upset / angry.

    We’ve seen this recently with WP5. :/

    Thread Starter pumka

    (@pumka)

    Sure, no problem at all as my fix was relative easy to implement once I find out what caused the reset. ??
    Emailed you another issue with the Bulk Cloner add-on as I believe it does not belong here. Let me know if add-ons have their issue tracker(s) as I couldn’t find one.

    Plugin Author edward_plainview

    (@edward_plainview)

    Yepp. Got your e-mail and replied.

    There is no real issue tracker since Broadcast has so very little issues. ?? Email is the tool of choice for quickly solving problems.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Broadcast resets post_parent’ is closed to new replies.