Skip Navigation

[Resolved] Uncaught TypeError: Illegal offset type in isset or empty

This thread is resolved. Here is a description of the problem and solution.

Problem:

Unable to access a specific page in WordPress Admin console (post type: chapter) after upgrading the server to PHP version 8.0 or above. The error points to a custom-written plugin causing an "E_ERROR" in class.wpcf-post-types.php.

Solution:

Identified a custom-written plugin (Love on a Leash Members) causing the conflict, particularly with the usage of toolset_get_related_posts() and toolset_connect_posts() functions. The custom plugin needs to be updated to use the current implementation of these functions as outlined in Toolset documentation.

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts-legacy

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.

This topic contains 3 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 4 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2677341

Hello,

We are unable to access a page under our WordPress Admin console:

hidden link

Although it works now when clicked, it does not work if we attempt to upgrade our server to PHP version 8.0 or above.
Instead, we get this error:

An error of type E_ERROR was caused in line 56 of the file
/home/lfve5kfccxaw/public_html/wp-content/plugins/types/vendor/toolset/types/embedded/classes/class.wpcf-post-types.php.
Error message: Uncaught TypeError: Illegal offset type in isset or
empty in /home/lfve5kfccxaw/public_html/wp-content/plugins/types/vendor/toolset/types/embedded/classes/class.wpcf-post-types.php:56
Stack trace:
#0 /home/lfve5kfccxaw/public_html/wp-content/plugins/types/vendor/toolset/types/embedded/classes/class.wpcf-post-types.php(96):
WPCF_Post_Types->check_has_custom_fields()
#1 /home/lfve5kfccxaw/public_html/wp-includes/class-wp-hook.php(324):
WPCF_Post_Types->pre_get_posts()
#2 /home/lfve5kfccxaw/public_html/wp-includes/class-wp-hook.php(348):
WP_Hook->apply_filters()
#3 /home/lfve5kfccxaw/public_html/wp-includes/plugin.php(565):
WP_Hook->do_action()
#4 /home/lfve5kfccxaw/public_html/wp-includes/class-wp-query.php(1881):
do_action_ref_array()
#5 /home/lfve5kfccxaw/public_html/wp-includes/class-wp-query.php(3824):
WP_Query->get_posts()
#6 /home/lfve5kfccxaw/public_html/wp-includes/class-wp.php(696):
WP_Query->query()
#7 /home/lfve5kfccxaw/public_html/wp-includes/class-wp.php(816):
WP->query_posts()
#8 /home/lfve5kfccxaw/public_html/wp-includes/functions.php(1336): WP->main()
#9 /home/lfve5kfccxaw/public_html/wp-admin/includes/post.php(1291): wp()
#10 /home/lfve5kfccxaw/public_html/wp-admin/includes/class-wp-posts-list-table.php(165):
wp_edit_posts_query()
#11 /home/lfve5kfccxaw/public_html/wp-admin/edit.php(235):
WP_Posts_List_Table->prepare_items()
#12 {main}
thrown

Additional debug version is included in the Toolset Debug info.

#2677462

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

- Is the issue happening when you check another custom post type listing page other than Chapters?
- Would you please follow the steps below and see if the issue persists:

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Toolset and its add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.

If the issue persists, do we have your permission to copy your website to our server for further investigation?

Thanks.

#2677618

Hi Cristopher,

We found the plugin that was causing the conflict. It is a custom-written plugin (Love on a Leash Members) - however, it includes various uses of the toolset_get_related_posts() function as well as toolset_connect_posts() function. Are there any restrictions or usage instructions that we should be aware of in terms of PHP 8.0?

You may copy the website over to obtain further information needed.

#2677740

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

It should not be any issues except the usage of legacy functions.

here is the current implementation that needs to be used:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

And here is the legacy version that needs to be avoided:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts-legacy

We will not be able to delve into a custom coded plugin to find issues, but we will be happy to check if you can replicate the issue of usage of those functions in a clean installation of Toolset which you can login here and use the file manager plugin to add custom code that shows the functions do not work on PHP 8:

hidden link

Thanks.

#2678195

Hi Christopher,

Thank you for forwarding these links to us! We'll take a look the plugin to see if there are any uses of the legacy version of the function and update them accordingly.