• Resolved Themosaurus

    (@themosaurus)


    Hi,

    I believe I ran into a bit of an edge case with bidirectional relationship.

    To summarize, when previewing a post that has a relationship type field set to be bidirectional with a post object type field, the post object field’s value gets replaced with a revision id of the post I just previewed (probably the revision that wordpress generates to show the preview). The revision then automatically gets deleted and my post object field ends up with an id that doesn’t exist.

    Here are the steps to reproduce this behaviour :

    • Create 2 CPTs (we’ll call them “recipe” and “ingredient” for convenience). Make sure they are not using Gutenberg (the issue doesn’t seem to happen with Gutenberg enabled post types, maybe because preview is handled differently).
    • On the recipe CPT, add a relationship field set to select ingredients.
    • On the ingredients CPT, add a post object field set to select a single recipe.
    • Create a recipe, and some ingredients.
    • Edit the recipe, and add some ingredients in the relationship field and save.
    • The bidirectional setting works as expected and the post object field in the ingredients gets updated accordingly.
    • Now back in the recipe, do some changes (e.g. change the title and content), then don’t save but instead click the “Preview Changes” button. This should open a preview in a different tab.
    • Now open one of the ingredient’s edit screen, the post object field should appear empty.

    I believe what might be happening here is WordPress generates a revision for previewing, which triggers the bidirectional saving in said revision and overrides the value in the post object field of the ingredient with the id of that revision. Could be something else entirely but I thought it seemed like a logical explanation.

    I’ve been able to reproduce this issue with the latest WP version (6.1.1), the latest ACF Pro (6.0.7) and the latest ACFE (0.8.9) using the Twenty Twenty-Three theme on a fresh WP install.

    I hope it’s not too confusing as it’s a bit hard to explain this. Don’t hesitate to ask for more details if needed.

    Best regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    It is pleasant to have such detailed report. Please allow me some time in order to reproduce the issue and find what would cause it.

    I’ll try to come back to you with a temporary fix before the upcoming update.

    Regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I managed to reproduce the issue following the steps you provided. A fix has been added in the next patch to avoid that behavior.

    Unfortunately due to the complex nature of the feature, I cannot provide you a standalone quickfix. However, the next 0.8.9.1 patch should be out very soon.

    Sorry for the inconvenience.

    Have a nice day!

    Regards.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Just a heads up to let you know the latest 0.8.9.1 update fix this issue.

    Have a nice day!

    Regards.

    Thread Starter Themosaurus

    (@themosaurus)

    Hi,

    Glad I could help pinpoint the issue ??

    Thanks a lot for such a quick update !

    Best regards,

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    You’re welcome!

    Thanks for the nice review ??

    Have a nice day!

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bidirectional saving gets triggered by post preview, removes post object value’ is closed to new replies.