WordPress.org

Support

Support » Plugins and Hacks » Widget Logic » Undefined index.., Undefined offset.. warnings with WP_DEBUG

Undefined index.., Undefined offset.. warnings with WP_DEBUG

  • Here my contribution to your helpful plugin.

    With define('WP_DEBUG', true); in wp-config.php some PHP warnings can be observed in a WordPress 3.4.2 and 3.5.1 admin backend, especially in combination with WPML plugin and its language switcher widget.

    1. Warning on top of page /wp-admin/widgets.php:

    Notice: Undefined index: icl_lang_sel_widget in ..wp-content/plugins/widget-logic/widget_logic.php on line 116

    Line 116, old:

    if (!$wp_registered_widget_controls[$id])

    Line 116, quick fix:

    if (!isset($wp_registered_widget_controls[$id]))

    2. Warning when clicking the dropdown “open” button at WPML language switcher widget:

    Notice: Undefined offset: 0 in ..wp-content/plugins/widget-logic/widget_logic.php on line 233

    Line 233, old:

    $number=$params[0]['number'];
    if ($number==-1) {$number="__i__"; $value="";}
    $id_disp=$id;

    Line 233, quick fix:

    if (!empty($params)) {
    	$number=$params[0]['number'];
    	if ($number==-1) {$number="__i__"; $value="";}
    }
    $id_disp=$id;

    Warnings like these are pretty annoying during development where WP_DEBUG is required as they also break unrelated ajax-responses within admin-backend.

    Note: WPML plugin seems to be available for free for plugin-authors with compatibility issues, more here: http://wpml.org/documentation/theme-compatibility/go-global-program/

    http://wordpress.org/extend/plugins/widget-logic/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author alanft

    @alanft

    thanks! i’ll pop those in the dev version asap.

    Thanks for quick reponse.

    Maybe there are also other undefined variables, did not check the whole plugin…

    Plugin Author alanft

    @alanft

    i tried another approach with line 233, which is in the DEV now. give it a go, let me know.

    The current DEV causes a similar warning because if $params is empty then variable $number is not defined/set before the comparison: if ($number==-1) ..

    Notice: Undefined variable: number in ..wp-content/plugins/widget-logic/widget_logic.php on line 234
    Plugin Author alanft

    @alanft

    sorry, of course, must get round to a DEV install with WP_DEBUG turned on myself. hang on…

    Plugin Author alanft

    @alanft

    that should do it.

    Now the current DEV fixes the problem. Thanks for quick response.

    andamira

    @andamira

    Do you plan to update the main version from the trunk? I found the same error and I could apply the fix manually but since the bug was solved 10 months ago…

    Plugin Author alanft

    @alanft

    ok. will do. and update ‘works with too’ why not

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Undefined index.., Undefined offset.. warnings with WP_DEBUG’ is closed to new replies.
Skip to toolbar