Skip Navigation

[Resolved] Bugs and issues with conditionals

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 8 replies, has 2 voices.

Last updated by Nigel 10 months ago.

Assisted by: Nigel.

Author
Posts
#2679436

Hi,

Please find different issues or bugs I am facing related to conditionals:

1. Taxonomy conditionals returning "Incomplete condition" even if set up correctly are still there (see my previous ticket of one year ago: https://toolset.com/forums/topic/bugs-in-conditional-block/ ) but unfortunately I found out that not all of them work anyways. The new one I need that is "if the XXX taxonomy is NOT empty show the content/terms, otherwise show nothing" doesn't work, no matter which taxonomy is selected. See short video and debug info here:
hidden link

2. I have set a conditional (not related to taxonomies) in a new Content Template to test "if featured image exists show something, if not show something else" (two separate conditionals).
I noticed that in a CT the Featured-image-URL option is not available in the conditional select dropdown so I couldn't select it (I am sure it was available in the past because I used it). So I wrote the condition in the Advanced editor like this:
NOT ( empty( '[wpv-post-featured-image]') ) or empty( '[wpv-post-featured-image]')
and I got the "Incomplete condition" warning, but the conditional works anyways!
I think that the missing option could be a bug, also because it IS available in the conditional editor select when the conditional block is used in a page layout instead.

3. I was working on a Content Template (ID=14696) in the Gutenberg editor when the Update button became dark blue, can't save/update anymore. Reloading the editing page has no effect, same purging the cache. Closing the page end reopening the CT for editing the browser page goes to Server timeout and there is no way to open the CT again. The CT still works fine in the front end.
I got the following email from WP :
Details about the error
====================
An E_ERROR was detected at line 911 of file /home/musicain/public_html/wp-content/plugins/toolset-blocks/embedded/inc/wpv-conditional.php. Error message: Maximum execution time of 300 seconds exceeded
Actually there are about 10 conditionals in this CT.
It happened to me already once and I decided to delete the CT and start it from scratch, if possible I would like not to redo this one too. Is there a way to understand what happened and recover the CT for editing ? and just in case it happens again in the future.

4. Could you please let me know what's the right syntax to test if the user didn't select any term in a taxonomy select in a form (= empty taxonomy)? The best I could come up with was:
[wpv-conditional if="( [wpv-taxonomy-field name='wpcf-geo'] eq '' )"]
but it doesn't work. Using CONTAINS when a taxonomy has many terms would be quite difficult.

Please let me know.

Thanks
Regards
Nicola

#2679493

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2024-01-22 at 15.21.34.png

Hi Nicola

Let me answer each of these in turn.

1. We already have an internal ticket about this. I've commented on it to see if we can raise the priority of it to get it resolved sooner.

The video you shared isn't public so I can't see it. If there is a particular condition you are trying to apply to a particular template can you let me know and I'll take a look.

2. I tried this on my local site and featured image is available in the dynamic source dropdown, though you have to scroll down to find it (screenshot). Can you double-check?

3. I'm going to visit your site and check this now.

4. Can you clarify what you intend?

The wpv-conditional shortcode is evaluated on the server, while the page is being generated. So if you include a wpv-conditional shortcode in a form it will be evaluated at the time the form is being rendered, before any data has been entered. (Testing the role of a user might be a sensible use case, for example.)

You can conditionally display part of the form dynamically, which will adapt depending on the data as it is entered. Is this what you mean? See https://toolset.com/course-lesson/conditional-display-for-form-inputs/

#2679506

Hello Nigel,
thanks a lot for taking care of these.
1. pls retry this new link, the folder is public now, let me know if it works. Thanks for speeding this up internally.
hidden link
2. You are right, Featured-image-URL shows up everywhere now and also the condition is ok. I really don't understand, I spent quite a good time on this a few days ago .... sorry
3. ok thanks
4. Apologise, this is actually the same issue in point 1 !
Kind regards
Nicola

#2679510

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Trying to test 3 I couldn't open the template, so I grabbed a copy of the database and installed it locally in a clean site with just Types and Blocks installed.

There I didn't have any problems opening or editing the template (though there are many Kadence blocks that can't render), so it looks like the issue is a compatibility issue arising from some 3rd party code.

Your site looks to be a production site, do you have a staging server where you can test editing the template with other plugins disabled and the theme switched to a default theme like twentytwentyone?

Try re-activating plugins and re-testing editing the template, to see if you can identify what provokes the problem.

I'll take a look at that video now.

#2679511

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I looked at the video. It just seems to show the problem where the UI reports "Incomplete condition" when entering a valid taxonomy condition.

Was there some specific condition you were trying to add that you couldn't get to work?

#2679513

This is not the first time I meet incompatibilities between Kadence and Toolset, unfortunately. In that CT I am using various conditionals, two show Kadence modals. It still works fine on frontend, look at this (green button opens a modal with a Toolset form)
hidden link
but all of a sudden I couldn't edit the CT anymore.
The site is not in production yet, data is all fake, but I don't have a staging server. I have backups though. Would it be possible for you to make a copy of the db, open the CT and delete the modals, restore the db so that I can try to open the CT ? too bad if I have to give up the modals though .... ;-(

AFA the taxonomy condition, I was just trying to set a simple one: "if the XXX taxonomy is NOT empty show the content/terms, otherwise show nothing"
thanks

#2679590

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I first tried testing your site with most of the plugins disabled, to reproduce what I found on my local copy of your site, that the content template could be edited in a minimal install.

But on your server it still wasn't possible to edit the template, and I also tried a few other things like switching theme, without success.

While thinking about the differences between the online version and my local version I realised that while exporting your site I excluded post revisions.

I checked the database on your server and found one post revision for the template, and so I deleted it.

And that fixed it, the template then became editable once more.

I'm not sure how, but it appears that the post revision became corrupted somehow, and that is what was preventing the current template version from loading in the editor, if you could please verify.

(Note, I lost track of which plugins had been active on your site—there were a lot of inactive plugins—and you'll need to re-activate the ones you need, sorry about that.)

Regarding the problem setting the empty taxonomy condition, can you give me a specific taxonomy to test, and where should I test it (editing a particular template?).

#2679880

WOW Nigel, thanks for finding the guilty !
I can edit the CT now ! So it had nothing to do with Kadence/Toolset compatibility, but it's the post revisions. I read somewhere that they could be problematic. So just please let me know how I can delete them by myself if needed so that I don't bother you again with this, then we can close this ticket. Just note that the issue happened to me only editing CTs, never when editing pages (don't know if it means something).

Regarding the problem setting the empty taxonomy condition, I tried again and this time it was accepted, even though the Incomplete Condition warning still occours. So it looks like this goes back to the known issue. Hope developers can solve it soon.

Kind regards and many thanks for your support and patience.
Nicola

#2679968

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The content templates are stored in wp_posts as a view-template post type. The main template has a post_status of "publish", and would have post_parent = 0.

I deleted the entries directly from the database. If you are familiar with phpMyAdmin that should be easy enough: I added the adminer plugin to give me an interface like phpMyAdmin to inspect the database.

Or you could add a code snippet that you run whenever you think there are template revisions that need deleting. (In Toolset > Settings > Custom Code you can add a snippet but not activate it, and run once whenever you need to.)

Something like:

function delete_draft_templates() {

    // first, get published templates
    $templates = get_posts(
        array(
            'post_type' => 'view-template',
            'post_status' => 'publish',
            'numberposts' => -1,
            'fields' => 'ids'
        )
    );

    // see if there are any revisions for each template, and delete

    foreach ($templates as $template) {

        $revisions = get_posts(
            array(
                'post_type' => 'revision',
                'parent_post' => $template,
                'numberposts' => -1,
                'fields' => 'ids'
            )
        );

        if ( $revisions ){
            foreach ($revisions as $revision) {

                wp_delete_post( $revision, true );
            }
        }
    }
}

I haven't tested that. Do have a backup before running it.