[wp-hackers] possible small bug in widgets.php

Otto otto at ottodestruct.com
Mon Feb 15 19:05:59 UTC 2010


Callback shouldn't be an object. It should be a function name.
Basically, a string.

-Otto



On Mon, Feb 15, 2010 at 12:10 PM, Johannes Ruthenberg
<tech at johannes-ruthenberg.de> wrote:
> Hi!
>
> There's a possible bug in wp-includes/widgets.php. Since I don't really
> understand all the details I wanted to ask here what everyone else thinks
> before opening a trac ticket.
>
> The bug was found in this discussion on the German WordPress forum:
> http://forum.wordpress-deutschland.org/konfiguration/62484-error-bei-den-widgets.html
>
> A user got a PHP error when opening the backend widgets page: "Nesting level
> too deep – recursive dependency" The error originates in widgets.php, in
> function is_active_widget, what is now line 924.
>
> Apparently, you get this message in newer PHP versions (5.2+) when PHP
> compares two objects with == instead ob ===. It compares all properties of
> the objects, which can lead to a loop if the objects have circular
> dependencies. Details for example here:
> http://www.richardlord.net/blog/php-nesting-level-too-deep-recursive-dependency
>
> So, line 924 looks like this:
>
> if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) &&
> $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base &&
> _get_widget_id_base($widget) == $id_base ) ) {
>
> The second comparison should be harmless, that would always be a String. But
> I'm not really sure what's inside
> $wp_registered_widgets[$widget]['callback']. It seems to be an object which
> can cause this problem, at least with some widgets. The poster in above
> mentioned thread changed both comparisons to === and the PHP error vanished.
> Of course, he doesn't want to change this with every WP upgrade, so I
> promised to bring this to attention. ;-)
>
> So, do you think I should just open a trac ticket for this? Could the
> stricter comparison have possible side effects? As I said, I'm not quite
> sure what's actually compared there.
>
> Regards,
> Johannes Ruthenberg
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list