Sauter la navigation

[Résolu] Call to undefined function get_current_screen() in is_block php

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

Withe Toolset Types plugin version 3.2 + Toolset form plugin version 2.2, there are some PHP errors:

Fatal error: Uncaught Error: Call to undefined function get_current_screen() 

Solution:

This is caused by Toolse fields, some of which have default validation rules, so no need to check for specific field types.

Types 3.2.1 released with a fix for problem, you can download it here:

https://toolset.com/account/downloads/

Relevant Documentation:

This support ticket is created Il y a 6 années. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 9 réponses, a 3 voix.

Dernière mise à jour par Tim Elliott Il y a 6 années.

Assisté par: Luo Yang.

Auteur
Publications
#1155960

I am trying to:
Submit a form

Link to a page where the issue can be seen:
It's currently hidden but I can give you login details if you want.

I expected to see:
The form working

Instead, I got:
Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /www/htdocs/xxxxxxxxxxxx/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/utility/condition/post_type/editor/is_block.php:67 Stack trace: #0 /www/htdocs/xxxxxxxxxxxx/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/utility/condition/post_type/editor/is_block.php(32): Toolset_Condition_Post_Type_Editor_Is_Block->get_post_type_by_current_screen() #1 /www/htdocs/xxxxxxxxxxxx/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/classes/class.conditional.php(157): Toolset_Condition_Post_Type_Editor_Is_Block->is_met() #2 /www/htdocs/xxxxxxxxxxxx/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/classes/class.conditional.php(121): WPToolset_Forms_Conditional->get_block_editor_form_selectors() #3 /www/htdocs/xxxxxxxxxxxx/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/ in /www/htdocs/w00bb115/digitalmarketing.at/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/utility/condition/post_type/editor/is_block.php on line 67

A couple of things to note.
The form had a lot of custom JS in it originally and was working earlier today. I made some changes to the form content, the js and to the fields on the custom post type - added some fields and removed others.

I tried the following:
- switching off ajax submission (the original error message had no detail and it wasn't till I switchedoff ajax that I got the whole error message
- removing the JS
- regenerating the form using "Auto generate form content"
- switching off the "Charge payment with this form"
- updating all Toolset plugins
- site doesn't use Jetpack. I didn't test turning other plugins off

It seems it may be related to this problem, but with a different file:
https://toolset.com/forums/topic/call-to-undefined-function-get_current_screen-in-classesclass-file-php/
I used the solution in this support topic and it seems to have done the trick, but like this user I could do with a solution that doesn't involve changes to a Toolset file.

Thanks
Tim

#1156097

Hello,

Thanks for the details, I can login your website, but there are lots of forms in your website, I am not sure where I can check the problem.

Please try these:
1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

2) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1156147

I've just performed the latest round of updates (to Types 3.2, Access 2.6, Forms 2.2, Views 2.7 & Maps 1.7) and I'm getting the same errors. I'll raise a separate ticket.

#1156152

@julieP, thanks for the feedback, we got some other similar reports, for example:
https://toolset.com/forums/topic/jquery-bug-rendering-repeatable-fields-unusable/

And they should be the same problem, I have escalated this thread to our 2nd tier supporters, will update here if there is any news.

#1156189
#1156192

Hi Luo,
I should have said, the form in question is:
Add New Job Listing
Found at: /add-new-job-listing/

Other forms seem to be working OK.

Tim

#1156205

Here is the hot fix:
https://toolset.com/errata/validated-fields-in-forms-are-breaking-form-submit-with-fatal-error/

Please test it, and feedback if the problem is fixed, thanks

#1156221

That doesn't look like much of a fix.

"Workaround
There is no solution just yet, unless to not use such fields."

#1156227

Yes, there is only a workaround for it. And our developers are working on it, I will keep on updating here.

#1156234

Here is the feedback from our developers:
This is caused by Toolse fields, some of which have default validation rules, so no need to check for specific field types.

Types 3.2.1 released with a fix for problem, you can download it here:
https://toolset.com/account/downloads/
please test it again, thanks

#1156264

My issue is resolved now. Thank you!