Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/20/2017 09:14:42 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Widgets: add isset() checks to checkbox attributes.

This change fixes debug notices when saving Topics & Replies widgets and show_date or show_user are not checked.

Trunk, for 2.6. Props jrf. Fixes #3142.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/widgets.php

    r6606 r6660  
    832832        $instance['order_by']     = strip_tags( $new_instance['order_by'] );
    833833        $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] );
    834         $instance['show_date']    = (bool) $new_instance['show_date'];
    835         $instance['show_user']    = (bool) $new_instance['show_user'];
    836834        $instance['max_shown']    = (int) $new_instance['max_shown'];
     835
     836        // Date
     837        $instance['show_date'] = isset( $new_instance['show_date'] )
     838            ? (bool) $new_instance['show_date']
     839            : false;
     840
     841        // Author
     842        $instance['show_user'] = isset( $new_instance['show_user'] )
     843            ? (bool) $new_instance['show_user']
     844            : false;
    837845
    838846        // Force to any
     
    11771185        $instance              = $old_instance;
    11781186        $instance['title']     = strip_tags( $new_instance['title'] );
    1179         $instance['show_date'] = (bool) $new_instance['show_date'];
    1180         $instance['show_user'] = (bool) $new_instance['show_user'];
    11811187        $instance['max_shown'] = (int) $new_instance['max_shown'];
     1188
     1189        // Date
     1190        $instance['show_date'] = isset( $new_instance['show_date'] )
     1191            ? (bool) $new_instance['show_date']
     1192            : false;
     1193
     1194        // Author
     1195        $instance['show_user'] = isset( $new_instance['show_user'] )
     1196            ? (bool) $new_instance['show_user']
     1197            : false;
    11821198
    11831199        return $instance;
Note: See TracChangeset for help on using the changeset viewer.