WP_DEBUG throws lots of warnings with Widget Logic (7 posts)

  1. Mike Schinkel
    Posted 6 years ago #

    After reading Andrew Nacin's recommendation[1] to use WP_DEBUG during development I found that WIdget Logics throws lots of warnings which makes it pretty impossible for me to use WP_DEBUG to debug my own plugins on a site that also uses Widget Logic.

    Next time you update Widget Logic would use consider doing it while using WP_DEBUG and make the required fixes? Mostly it's changing things like "if ($array['element'])" to "if (isset($array['element']) && $array['element'])" but it could also identify if you have any subtle bugs before a user would find them.

    Much appreciated if you can do this (I'll even consider doing the update for you if need be, although since I'm not the original developer there's a small chance I might not get some of the logic updated correctly.)

    Thanks in advance.


    [1] http://www.andrewnacin.com/2010/03/22/deprecated-functions-and-wp_debug/

  2. alanft
    Posted 6 years ago #

    I will take a look at this and update the code as soon as i get a chance and work out what the problem is. Thanks for bringing this up

  3. alanft
    Posted 6 years ago #

    quick look over seems to imply the only major issue is on line 137 where

    if (!$wp_registered_widgets[$id]['callback_wl_redirect'])

    should be changed to

    if (!array_key_exists('callback_wl_redirect', $wp_registered_widgets[$id]))

    if you see any other lines being referenced in your dubug.log, let me know.

    Thanks for the tip by the way. though this has shown up lots of debug problems like this with my theme and some plugins (google analytics!)

  4. Darrell Schauss
    Posted 6 years ago #

    Also get undefined index for widget_logic-options-filter and widget_logic-options-wp_reset_query in my sidebar. By default install of widget logic these options do not exist in the database record. For now I turn these on and then turn them back off so the index is there and set to off.

  5. alanft
    Posted 6 years ago #

    ah good catch. will look at that too. thanks all.

  6. Andrew Nacin
    Lead Developer
    Posted 6 years ago #

    A better option would be using isset() or empty() (note that they are different) instead of array_key_exists().

    isset( $wp_registered_widgets[$id]['callback_wl_redirect'] ) returns true if the key exists, false if it does not.

    empty( $wp_registered_widgets[$id]['callback_wl_redirect'] ) returns true if the key exists and the value doesn't evaluate to false (loosely -- see php.net/empty for more), and false if those conditions aren't met.

  7. Jason
    Posted 5 years ago #

    I was also getting similar debug errors for lines 159 and 164 (in version 0.47). I changed to the following (might be something better but it works)

    Line 159:

    if (isset($wl_options['widget_logic-options-wp_reset_query']) && $wl_options['widget_logic-options-wp_reset_query']=='checked' && !$wp_reset_query_is_done)

    Line 164:
    { if (isset($wl_options['widget_logic-options-filter']) && $wl_options['widget_logic-options-filter']!='checked')

Topic Closed

This topic has been closed to new replies.

About this Topic