Support

Account

Home Forums Bug Reports After JSON SYNC, PostObject field empty because Taxonomy missing

Solving

After JSON SYNC, PostObject field empty because Taxonomy missing

  • I’m noticing an issue when migrating page templates and custom fields to a new server and running JSON sync.

    I have a PostObject field that when synced on the live server through JSON, fails to populate the dropdown with anything on a page template — not good.

    Looking closer at the JSON I see that nothing is showing up because I have a taxonomy filter.

    
        "post_type": [
            "custom-post-type"
        ],
        "taxonomy": [
            "custom_category:my-missing-term"
        ],
    

    — at this point all is actually working as expected —

    Here is the bug.

    Because the new server never had the taxonomy, nothing shows. That WOULD make sense, but when editing the Field Group on the server that taxonomy doesn’t show! You could say that is by design, but seeing as this is a visual editor for code that should sync I believe the taxonomy should show in the editor regardless.

    I realized it won’t probably because it never found the term and became invalid for the field, but that taxonomy could show as a red object to denote that it is missing from the system in some way. Another possible option; like you show ‘required fields’ you should show a message that indicates a missing taxonomy above the field.

    The thing is, I am lucky to have caught this but I might forget again. And if I have to memorize how to modify code for a visual editor then I believe it’s ACF’s responsibly to fix this in the Field Editor. It is after all, the best custom field plugin you can get.

    Thanks,

  • The taxonomy filter only filters posts by the terms, no the actual taxonomy.

    ACF does the same thing with anything that is missing, for example if create a field group that is located on an options page and then import that field group into a site that does not have that options page, 1) the field group will not appear anywhere and 2) when you edit that field group and edit the location rule the options page will not be listed as missing.

    I’m not the developer, but I wouldn’t consider this to be a bug and find it to be expected behavior. Any location rule based on something that does not exist will need to have those things created before the field group is edited.

    Are you doing this moving to a new server to move the entire site? or to recreate part of it for an unrelated site?

  • I’m developing features locally, testing features on a dev site, then adding the updates to the production site.

    I’m most cases It would appear that this is working correctly, but unfortunately the visuals are masking filters which are still being applied to the output.

    I don’t think it’s correct to hit sync and get an empty dropdown with no indication why. And I certainly can’t make that mistake on the production server. Luckily I caught this on a local -> dev server update.

    I’m not the developer, but I wouldn’t consider this to be a bug and find it to be expected behavior. Any location rule based on something that does not exist will need to have those things created before the field group is edited.

    I agree. The filter shows on the original local site. But when on the new server without that taxonomy, the field is empty — and the filter is still applied. When you’re making more complex repeaters and flexible content it’s hard to spot a missing item.

    My expectation is that, if the field syncs, and a taxonomy is missing, it should give an idicator that you need to create that taxonomy.

  • I posted an issue about this for the developer to get his input.

  • Hi @jgraup

    Thanks for the topic, great explanation of the issue too!

    I’ll keep this one in mind for future updates, but can’t say it will be making it into he core any time soon. Just too many big features to work on.

    it’s definitely a nice to have, and should be possible for the taxonomy field to ‘validate’ it’s settings, but also, this is quite a niche bug.

    I wonder if it is possible for you to hook into the taxonomy field update_field filter “acf/update_field/type=taxonomy” and run your own validation.

    This filter will be run during the sync, and also when updating via the edit screen. Perhaps you could save a temp error to the DB, then load it and display as a WP admin notice?

    I hope everything else is smooth sailing from here on in!

  • Thanks @elliot!

    I knew this one was pretty rare but I just wanted to put in on your radar.

    Outside of this issue ACF has been fantastic in many ways so thank-you for all the work you have done and continue to do.

    If I get an easy solution running I’ll post back here but obviously I’ll just avoid the problem in the mean time.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.