Repository navigation
Fix: Bug Affecting Widgets without description - #14587
Conversation
| $available_legacy_widgets[ $widget_id ] = array( | ||
| 'name' => html_entity_decode( $widget_obj['name'] ), | ||
| 'description' => null, | ||
| 'description' => html_entity_decode( wp_widget_description( $widget_id ) ), |
There was a problem hiding this comment.
In what way is this change related to the fix?
There was a problem hiding this comment.
During these changes, I noticed I missed to pass a description when I added support some simple call back widgets.
But it is not directly related to these changes. I separated this change to other PR #14615.
There was a problem hiding this comment.
Alternative test (I'd created before this pull request):
- Ensure
define( 'WP_DEBUG', true );inwp-config.php - Add the following as
wp-content/mu-plugins/custom-widget.php:
<?php
class Custom_Widget extends WP_Widget {
public function __construct() {
parent::__construct( 'Custom_Widget', 'Custom Widget' );
}
public function widget( $args, $instance ) {
}
public function form( $instance ) {
}
public function update( $new_instance, $old_instance ) {
return $new_instance;
}
}
add_action( 'init', function() {
register_widget( 'Custom_Widget' );
} );- Navigate to Posts > Add New
The PHP warning notice is no longer shown after these changes.
Can you confirm: Prior to this change, description was passed as an empty string when not defined by the widget. It is now passed as null. Is there a meaningful impact of this difference?
fba1311 to
0d9e369
Compare
|
Hi @aduth, gutenberg/packages/block-library/src/legacy-widget/edit.js Lines 95 to 97 in b421fc9 |
Description
Fixes: #14552
We were not checking in the widget description was set and on widgets, without description, an undefined notice was being thrown.
How has this been tested?
I installed the AnsPress Question Answer plugin: https://wordpress.org/plugins/anspress-question-answer.
I created a new page and verified and checked Undefined notice was not being thrown in the PHP code. In master, a notice should appear.