Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#24577 closed defect (bug) (fixed)

Undefined index notice caused by default-widgets.php - WP_Widget_Recent_Posts

Reported by: jrf Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.5
Component: Widgets Keywords: has-patch
Focuses: Cc:


When updating the Recent Posts widget, it can cause an undefined index notice:

[14-Jun-2013 04:56:40] Backtrace from warning 'Undefined index: show_date' at /www/wp-includes/default-widgets.php 596:
	/www/wp-includes/widgets.php 232 calling update()
	<unknown file> <unknown line> calling update_callback()
	/www/wp-admin/includes/ajax-actions.php 1562 calling call_user_func_array()
	<unknown file> <unknown line> calling wp_ajax_save_widget()
	/www/wp-includes/plugin.php 406 calling call_user_func_array()
	/www/wp-admin/admin-ajax.php 72 calling do_action()

To fix, line 599 (based on current trunk):

$instance['show_date'] = (bool) $new_instance['show_date'];

would need to be replaced with:

$instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;

Patch file included.

Hope this helps ;-)

Attachments (1)

default-widgets.php.patch (573 bytes) - added by jrf 2 years ago.
Unified patch file for wp-includes/default-widgets.php

Download all attachments as: .zip

Change History (3)

2 years ago

Unified patch file for wp-includes/default-widgets.php

#1 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 3.6
  • Version changed from trunk to 3.5

Confirmed with WP_DEBUG_LOG enabled. Introduced in [21935].

We currently handle widget parameters inconsistently (some widgets use wp_parse_args(), others isset() and ! empty()), but that can be fixed in a future release.

#2 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 24504:

Avoid an undefined index notice in WP_Widget_Recent_Posts::update(). props jrf. fixes #24577.

Note: See TracTickets for help on using tickets.