Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#1467 closed defect (bug) (fixed)

foreach( $metavalues ) in pluggable-functions.php causes PHP warnings

Reported by: davidhouse's profile davidhouse Owned by: davidhouse's profile davidhouse
Milestone: Priority: normal
Severity: major Version: 1.6
Component: Administration Keywords: bg|has-patch bg|squashed
Focuses: Cc:

Description

wp-includes/pluggable-functions.php:42 has a foreach() statement that loops over a user's meta. However, this gives warnings when creating a new user and when promoting a user from level 0 level 1. If you have PHP's ini setting display_errors set to 'on', it even causes a crash when promoting a user into an author as the header() call fails.

Patch:

--- ../xmouse/wp-includes/pluggable-functions.php       2005-06-19 09:33:44.000000000 +0100
+++ wp-includes/pluggable-functions.php 2005-06-24 09:45:27.270279048 +0100
@@ -39,8 +39,10 @@

        $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");

-       foreach ( $metavalues as $meta )
-               $user->{$meta->meta_key} = $meta->meta_value;
+       if ($metavalues) {
+               foreach ( $metavalues as $meta )
+                       $user->{$meta->meta_key} = $meta->meta_value;
+       }

        $cache_userdata[$user_id] = $user;

Attachments (1)

1467.patch (1.2 KB) - added by skippy 19 years ago.

Download all attachments as: .zip

Change History (5)

#1 @davidhouse
19 years ago

  • Owner changed from anonymous to davidhouse
  • Status changed from new to assigned

#2 @skippy
19 years ago

  • Keywords bg|has-patch added

@skippy
19 years ago

#3 @skippy
19 years ago

  • Keywords bg|squashed added

added 1467.patch to reflect current state of pluggable-functions.php in 1.6.

#4 @ryan
19 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [3038]) Don't loop over empty list. Props skippy. fixes #1467

Note: See TracTickets for help on using tickets.