-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Bug Affecting Widgets without description #14587
Fix: Bug Affecting Widgets without description #14587
Conversation
lib/widgets.php
Outdated
@@ -110,7 +115,7 @@ function gutenberg_legacy_widget_settings( $settings ) { | |||
} | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what way is this change related to the fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.