enqueue_highlighting(): rare php fatal
-
Hi,
We observed a one-off PHP 8 fatal error during an AJAX based formidable forms registration, seemingly related to Code Snippet front-end highlighting.
PHP Fatal error: Uncaught TypeError: stripos(): Argument #1 ($haystack) must be of type string, array given in /WEBSITE/files/wp-content/plugins/code-snippets/php/front-end/class-front-end.php:138
Stack Trace:
Stack trace:
#0 /sites/WEBSITE/files/wp-content/plugins/code-snippets/php/front-end/class-front-end.php(138): stripos()
#1 /sites/WEBSITE/files/wp-includes/class-wp-hook.php(343): Code_Snippets\Front_End->enqueue_highlighting()
#2 /sites/WEBSITE/files/wp-includes/plugin.php(256): WP_Hook->apply_filters()
#3 /sites/WEBSITE/files/wp-includes/class-wp-query.php(3629): apply_filters_ref_array()
#4 /sites/WEBSITE/files/wp-includes/class-wp-query.php(3958): WP_Query->get_posts()
#5 /sites/WEBSITE/files/wp-includes/post.php(2622): WP_Query->query()
#6 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmDb.php(665): get_posts()
#7 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmFormAction.php(670): FrmDb::check_cache()
#8 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmFormAction.php(543): FrmFormAction->get_all()
#9 /sites/WEBSITE/files/wp-content/plugins/formidable-registration/helpers/FrmRegActionHelper.php(113): FrmFormAction::get_action_for_form()
#10 /sites/WEBSITE/files/wp-content/plugins/formidable-registration/models/FrmRegEntry.php(1335): FrmRegActionHelper::get_action_for_form()
#11 /sites/WEBSITE/files/wp-content/plugins/formidable-registration/models/FrmRegEntry.php(1274): FrmRegEntry::get_user_reg_password_field_id()
#12 /sites/WEBSITE/files/wp-includes/class-wp-hook.php(343): FrmRegEntry::maybe_hash_password()
#13 /sites/WEBSITE/files/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
#14 /sites/WEBSITE/files/wp-includes/plugin.php(522): WP_Hook->do_action()
#15 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmEntry.php(1042): do_action()
#16 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmEntry.php(1063): FrmEntry::after_entry_created_actions()
#17 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmEntry.php(750): FrmEntry::after_insert_entry_in_database()
#18 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmEntry.php(44): FrmEntry::continue_to_create_entry()
#19 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/models/FrmEntry.php(23): FrmEntry::create_entry()
#20 /sites/WEBSITE/files/wp-content/plugins/formidable/classes/controllers/FrmEntriesController.php(643): FrmEntry::create()
#21 /sites/WEBSITE/files/wp-content/plugins/formidable-pro/classes/controllers/FrmProEntriesController.php(3821): FrmEntriesController::process_entry()
#22 /sites/WEBSITE/files/wp-includes/class-wp-hook.php(341): FrmProEntriesController::ajax_create()
#23 /sites/WEBSITE/files/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
#24 /sites/WEBSITE/files/wp-includes/plugin.php(522): WP_Hook->do_action()
#25 /sites/WEBSITE/files/wp-settings.php(764): do_action()
#26 /sites/WEBSITE/files/wp-config.php(97): require_once('...')
#27 /sites/WEBSITE/files/wp-load.php(50): require_once('...')
#28 /sites/WEBSITE/files/wp-admin/admin-ajax.php(22): require_once('...')
#29 {main}
thrown in /sites/WEBSITE/files/wp-content/plugins/code-snippets/php/front-end/class-front-end.php on line 138Environment: WordPress 6.9, PHP 8.3, Code Snippets 3.9.3 (same code exists in 3.9.4)
Information:
- Occurred during a single formidable forms’ user registration via a modal on an event page
- $post->post_content was an array in this rare AJAX request, triggering the fatal
- User successfully completed registration
This appears to be a rare edge case where enqueue_highlighting() assumes $post->post_content is always a string.
Seemingly, adding a defensive is_string() check on $post->post_content would likely prevent this rare PHP 8+ fatal, since stripos() now strictly requires a string argument.
Thank you,
You must be logged in to reply to this topic.