cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 82 forks source link

PHP error triggered when visiting wp-admin/widgets.php #309

Closed joccca closed 2 years ago

joccca commented 2 years ago

Describe the bug

Visiting /wp-admin/widgets.php crashes site and throws error:

Uncaught Error: Cannot use object of type stdClass as array in /var/www/wp-content/plugins/wordpress-popular-posts/src/Widget/form.php:101
Stack trace:
#0 /var/www/wp-content/plugins/wordpress-popular-posts/src/Widget/Widget.php(185): require()
#1 /var/www/wp-includes/class-wp-widget.php(534): WordPressPopularPosts\Widget\Widget->form(Array)
#2 /var/www/wp-includes/widgets.php(2004): WP_Widget->form_callback(Array)
#3 /var/www/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php(634): wp_render_widget_control('wpp-3')
#4 /var/www/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php(122): WP_REST_Widgets_Controller->prepare_item_for_response(Array, Object(WP_REST_Request))
#5 /var/www/wp-includes/rest-api/class-wp-rest-server.php(1140): WP_REST_Widgets_Controller->get_items(Object(WP_REST_Reques

Probably interference with other plugins or—more likely—widget blocks.

To Reproduce

open /wp-admin/widgets.php

Expected behavior

widget settings are displayed or some usefull incompatibility message

Workaround

Installing Classic Widgets solves the problem.

Environment

cabrerahector commented 2 years ago

Hi @joccca,

If you're trying to use the classic WordPress Popular Posts widget with the new block-based Widgets screen introduced with WordPress 5.8 then yes these kind of compatibility issues are expected to happen, see About the classic WordPress Popular Posts widget and the new Widgets screen and WordPress Popular Posts now provides supports for the Block Editor.

There are no plans at the moment to have the classic WPP widget work with the new Widgets screen so either install the Classic Widgets plugin as you already mentioned or switch to the WordPress Popular Posts block.