• Resolved annaam

    (@annaam)


    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 138

    Environment: WordPress 6.9, PHP 8.3, Code Snippets 3.9.3 (same code exists in 3.9.4)

    Information:

    1. Occurred during a single formidable forms’ user registration via a modal on an event page
    2. $post->post_content was an array in this rare AJAX request, triggering the fatal
    3. 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,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter annaam

    (@annaam)

    Surprisingly, this just happened again (now twice in the last 24 hours). We haven’t updated anything recently, odd.

    We just disabled “syntax highlighting when displaying snippet code on the front-end” via settings, and hope this mitigates our issue as we don’t need highlighting.

    Plugin Contributor Carolina

    (@carolinaop)

    Hi @annaam!

    Thank you so much for taking the time to report this and for sharing the detailed information.

    You’re correct in identifying this as a rare edge case which can lead to this PHP 8+ fatal error when syntax highlighting is being enqueued. As a temporary workaround, disabling front-end syntax highlighting should help prevent this from occurring.

    I’ve noted your findings, I will check it deeper for further review and handling in a future update. In the meantime, please let us know if disabling syntax highlighting resolves the issue for you, or if you continue to see the error — your feedback is very helpful.

    Thanks again for reporting this and helping us improve the plugin!

    Thread Starter annaam

    (@annaam)

    Thank you for looking into this.

    Yes, disabling syntax highlighting via code snippet settings immediately resolved the issue.

    Feel free to mark this as resolved, unless you’d like to keep it open until it’s corrected within the code.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.