[wp-trac] [WordPress Trac] #10354: Argument not array in comment.php

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 8 15:16:10 UTC 2009


#10354: Argument not array in comment.php
--------------------------+-------------------------------------------------
 Reporter:  dawblog       |       Owner:                                                         
     Type:  defect (bug)  |      Status:  new                                                    
 Priority:  normal        |   Milestone:  2.8.5                                                  
Component:  General       |     Version:  2.8                                                    
 Severity:  normal        |    Keywords:  reporter-feedback array_merge editing wp_update_comment
--------------------------+-------------------------------------------------
Changes (by sowsinsk):

  * keywords:  reporter-feedback array_merge editing => reporter-feedback
               array_merge editing wp_update_comment


Comment:

 I am having the same issue when calling wp_update_comment(). I believe the
 problem is line 1092 (in 2.8.4), which turns the $comment array that was
 retrieved via get_comment() into a string. That string is then passed to
 array_merge in line 1097, which throws the error.

 The $wpdb->escape function is turning the $comment array into a string
 because it calls addslashes() on any non-object data and returns it (this
 includes arrays, which presumably get turned into a string because
 addslashes() expects a string). In previous versions (such as 2.7.1),
 there was code that recursed through the $comment array and called
 $wpdb->escape on each key/value pair, which worked correctly. However, as
 of 2.8 on, it just calls $wpdb->escape() on the array as a whole.

 I'll also note that in previous versions (for instance 2.7.1) when
 escape() was called recursively via a foreach, it did not work 100% of the
 time... there would occasionally be an instance where the $comment array
 had a 'post' index with post data in it... this would also trip up the
 $wpdb->escape call, even though it was being called recursively on each
 index of the array. I believe the ideal solution would be for the escape()
 function to add recursive behavior based on the type of data passed to it.
 This way, if it encountered an array of arrays, it could recurse deeply
 through them and return the original array with deeply-escaped values.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10354#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list