Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#2344 closed defect (bug) (fixed)

Warning: Invalid argument supplied for foreach() in /var/sites/lbt/wp-includes/functions.php on line 458

Reported by: sjmurdoch's profile sjmurdoch Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: General Keywords: bg|has-patch
Focuses: Cc:

Description

When using the subscribe to comments plugin, on removing a subscription the following warning message is displayed:

Warning: Invalid argument supplied for foreach() in /var/sites/lbt/wp-includes/functions.php on line 458

Although I have only been able to trigger this bug using subscribe to comments, the problem appears to be in Wordpress itself.

The function remove_subscriber() in subscribe-to-comments.php:546 calls delete_post_meta() in wp-includes/functions.php:436, with 3 parameters:

  1. $post_id: 18
  2. $key: "_sg_subscribe-to-comments"
  3. $value: email address

On line 458 of wp-includes/functions.php, the following returns the warning:

foreach ( $cache_key as $index => $data )

This is because $cache_key, taken from $post_meta_cache$post_id?[$key] is empty.

I would have expected delete_post_meta() to have checked for $cache_key being non-empty before passing it to foreach(). If this is in fact a bug in subscribe to comments then please close this report and I will pass this onto the plugin developer.

  • Wordpress version tested: wordpress-2.0
  • Subscribe to comments version: 2.0.3
  • PHP version: 4.1.2-7.woody5
  • Operating system: Debian GNU/Linux 3.0

Attachments (1)

2344.diff (581 bytes) - added by davidhouse 19 years ago.

Download all attachments as: .zip

Change History (3)

@davidhouse
19 years ago

#1 @davidhouse
19 years ago

  • Keywords bg|has-patch added

Thanks for the pointer.

#2 @ryan
19 years ago

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

(In [3489]) Make sure we have an array. Props David House. fixes #2344

Note: See TracTickets for help on using tickets.