• Resolved andytela

    (@andymoonshine)


    The client has updated the plugin on a site and looks like there was still an old widget in

    It’s all done through code these days so we dont use widgets, but we can’t even get to the widget screen to remove it as it’s throwing a critical error

    PHP Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given in /wp-includes/formatting.php:1608
    Stack trace:
    #0 /wp-includes/formatting.php(1608): preg_match('/[\\\\x80-\\\\xff]/', Array)
    #1 /wp-includes/formatting.php(2223): remove_accents(Array)
    #2 /wp-content/plugins/wordpress-popular-posts/src/Widget/form.php(173): sanitize_title(Array)
    #3 /wp-content/plugins/wordpress-popular-posts/src/Widget/Widget.php(186): require('/nas/content/li...')
    #4 /wp-includes/class-wp-widget.php(535): WordPressPopularPosts\\Widget\\Widget->form(Array)
    #5 /wp-includes/widgets.php(2062): WP_Widget->form_callback(Array)
    #6 /wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php(701): wp_render_widget_control('wpp-2')
    #7 /wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php(154): WP_REST_Widgets_Controller->prepare_item_for_response(Array, Object(WP_REST_Request))
    #8 /wp-includes/rest-api/class-wp-rest-server.php(1230): WP_REST_Widgets_Controller->get_items(Object(WP_REST_Request))
    #9 /wp-includes/rest-api/class-wp-rest-server.php(1063): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/widgets', Array, NULL)
    #10 /wp-includes/rest-api.php(555): WP_REST_Server->dispatch(Object(WP_REST_Request))
    #11 /wp-includes/rest-api.php(2922): rest_do_request(Object(WP_REST_Request))
    #12 [internal function]: rest_preload_api_request(Array, '/wp/v2/widgets?...')
    #13 /wp-includes/block-editor.php(750): array_reduce(Array, 'rest_preload_ap...', Array)
    #14 /wp-admin/widgets-form-blocks.php(26): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context))
    #15 /wp-admin/widgets.php(32): require('/nas/content/li...')
    #16 {main}
    thrown in /wp-includes/formatting.php on line 1608

    We can disable the plugin to get to the widgets screen but when we switch it back on it we get the error again as obviously we can’t delete it if the plugin is inactive

    Cheers
    Andy

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @andymoonshine,

    Thanks for the heads up. I’ll have a look and get back to you ASAP.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, please go to Plugins > Plugin File Editor, select WordPress Popular Posts using the dropdown you’ll find near the top right of your screen, then under Plugin Files click on src > Widget > form.php to edit this file.

    Find (around lines 172-174):

    if ( $instance['theme']['name'] ) {
    $wpp_shortcode .= " theme='" . sanitize_title($instance['theme']['name']) . "'";
    }

    and replace that with:

    if ( $instance['theme']['name'] ) {
    // On the new Widgets screen $new_instance['theme'] is
    // an array for some reason, let's grab the theme name
    // from the array and move on
    if ( is_array($instance['theme']['name']) ) {
    $instance['theme']['name'] = $instance['theme']['name']['name'];
    }

    $wpp_shortcode .= " theme='" . sanitize_title($instance['theme']['name']) . "'";
    }

    When you’re done, click on the Update File button to save changes.

    If everything went well you should be able to access the Widgets screen normally now.

    Thread Starter andytela

    (@andymoonshine)

    Superb! That worked

    Thanks

    Plugin Author Hector Cabrera

    (@hcabrera)

    Great! I’ll make sure to include this patch in the next update.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.