Title: [PATCH] Undefined variables
Last modified: August 20, 2016

---

# [PATCH] Undefined variables

 *  [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-undefined-variables/)
 * When visiting the YD options page in admin I’m getting alot of PHP warnings:
 * > Notice: Undefined property: wpdb::$_3wp_broadcast in /path/to/wp-content/plugins/
   > yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.php on line 705
   > Notice: Undefined property: wpdb::$_3wp_broadcast_broadcastdata in /path/to/
   > wp-content/plugins/yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.php on
   > line 705
   > …
 * The fix was to change line 705 from
 *     ```
       if( $wpdb->$post and $wpdb->$post == $table ) continue; //this is a WP core table
       ```
   
 * to
 *     ```
       if( isset($wpdb->$post) and $wpdb->$post == $table ) continue; //this is a WP core table
       ```
   
 * Then
 * > Notice: Undefined index: debug in /path/to/wp-content/plugins/yd-wpmu-sitewide-
   > options/yd-wpmu-sitewide-options.php on line 166
 * On line 166 change
 *     ```
       if( $_POST['debug'] == 1 ) $d = true;
       ```
   
 * to
 *     ```
       if( !empty($_POST['debug']) && $_POST['debug'] == 1 ) $d = true;
       ```
   
 * Then
 * > Notice: unserialize() [function.unserialize]: Error at offset 0 of 18 bytes
   > in /path/to/wp-content/plugins/yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.
   > php on line 604
   > Notice: unserialize() [function.unserialize]: Error at offset 0 of 1 bytes 
   > in /path/to/wp-content/plugins/yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.
   > php on line 604
   > …
 * On line 604 change
 *     ```
       if( is_string( $option->option_value ) ) $uns = unserialize( $option->option_value );
       ```
   
 * to
 *     ```
       if( is_string( $option->option_value ) ) $uns = @unserialize( $option->option_value );
       ```
   
 * Also
 * > Notice: Undefined index: debug in /path/to/wp-content/plugins/yd-wpmu-sitewide-
   > options/yd-wpmu-sitewide-options.php on line 534
 * Change
 *     ```
       if( $_POST['debug'] == 1 )
       ```
   
 * to
 *     ```
       if( !empty($_POST['debug']) && $_POST['debug'] == 1 )
       ```
   
 * Also
 * > Notice: Undefined index: page in /path/to/wp-content/plugins/yd-wpmu-sitewide-
   > options/yd-wpmu-sitewide-options.php on line 555
 * Change
 *     ```
       echo '<input type="hidden" name="page" value="' . $_POST["page"] . '" />';
       ```
   
 * to
 *     ```
       echo '<input type="hidden" name="page" value="' . (isset($_POST["page"]) ? $_POST["page"] : '') . '" />';
       ```
   
 * When submitting the form I get plenty more warnings:
 * > Notice: Undefined index: yd_wpmuso-selected_options-0 in /path/to/wp-content/
   > plugins/yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.php on line 1064
   > Notice: Undefined index: yd_wpmuso-selected_options-0 in /path/to/wp-content/
   > plugins/yd-wpmu-sitewide-options/yd-wpmu-sitewide-options.php on line 1065
 * Change
 *     ```
       if( !is_array( $fields[$prefix . $key . '-' . $number] ) ) {
       	$value = html_entity_decode( stripslashes( $fields[$prefix . $key . '-' . $number] ) );
       ```
   
 * to
 *     ```
       $field_name = $prefix . $key . '-' . $number;
       if ( !isset($fields[$field_name]) )
       	$value = '';
       elseif( !is_array( $fields[$field_name] ) ) {
       	$value = html_entity_decode( stripslashes( $fields[$field_name] ) );
       ```
   
 * > Notice: Undefined index: debug in /path/to/wp-content/plugins/yd-wpmu-sitewide-
   > options/yd-wpmu-sitewide-options.php on line 760
 * Change
 *     ```
       if( $_POST['debug'] == 1 ) $d = true;
       ```
   
 * to
 *     ```
       if( !empty($_POST['debug']) && $_POST['debug'] == 1 ) $d = true;
       ```
   
 * That seems to get rid of them all for now.
 * [http://wordpress.org/extend/plugins/yd-wpmu-sitewide-options/](http://wordpress.org/extend/plugins/yd-wpmu-sitewide-options/)

The topic ‘[PATCH] Undefined variables’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/yd-wpmu-sitewide-options.svg)
 * [YD Network-wide Options](https://wordpress.org/plugins/yd-wpmu-sitewide-options/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yd-wpmu-sitewide-options/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yd-wpmu-sitewide-options/)
 * [Active Topics](https://wordpress.org/support/plugin/yd-wpmu-sitewide-options/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yd-wpmu-sitewide-options/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yd-wpmu-sitewide-options/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/patch-undefined-variables/)
 * Status: not resolved