There’s a hole in the wall at about head level next to my desk.
I’ve spent most of the day trying to track down a bug with some code I’ve been working on to add fields to a user’s profile in WordPress. The problem is that upon trying to save the profile I’d get an error like the following:
Catchable fatal error: Object of class stdClass could not be converted to string in /wp-includes/wp-db.php on line 472
Line 472 in my install is [in the wpdb::escape()
function][1]. After poking around the wrong side of the problem, I finally broke down and rewrote the function along these lines:
function escape($string) {
if( !is_object( $string ))
return( $string );
echo '
<h2>
'. $this->get_caller() .'
</h2>
<pre>';
print_r( $string );
echo '
```';
die();
}
</pre>
That’s how I finally learned that [`wp_update_user()` was at fault][2]. I also opened [a ticket for `add_magic_quotes()`][3]````
, as both probably need independent fixes.`
For now, however, I'm just converting the object to an array and avoiding the mess.`
```
`
[1]: http://core.trac.wordpress.org/browser/tags/2.7.1/wp-includes/wp-db.php#L428 "/wp-includes/wp-db.php – WordPress Trac"
[2]: http://core.trac.wordpress.org/ticket/9640 "#9640 (wp_update_user() blindly calls add_magic_quotes(), even on objects) – WordPress Trac"
[3]: http://core.trac.wordpress.org/ticket/9638 "#9638 (add_magic_quotes() fails on objects) – WordPress Trac"