WordPress.org

Support

Support » Plugins and Hacks » [Plugin: NextGEN Custom Fields] Undefined index notices in various places.

[Plugin: NextGEN Custom Fields] Undefined index notices in various places.

  • I am using version 1.2.2. There are undefined index in various places. I know by setting ^E_NOTICE can remove the message. However, should undefined index be checked before using it?

    Here is the notices I got.
    PHP Notice: Undefined index: PID in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 298
    If I change line 298 from
    if(!$nggcf_values[$pid])
    to
    if(isset($nggcf_values[$pid]) and !$nggcf_values[$pid])

    I got
    PHP Notice: Trying to get property of non-object in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 807

    Because of the new notice, I didn’t go any further since it might break the plug-in. Below are other notices which show up in admin panel.

    PHP Notice:  Undefined index: mode in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 342
    PHP Notice:  Undefined index: delete in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 391
    PHP Notice:  Undefined index: editname in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 426
    PHP Notice:  Undefined index: editlink in PATH TO MY WordPress\wp-content\plugins\nextgen-gallery-custom-fields\ngg-custom-fields.php on line 458

    Is it possible to have those notices checked?

    http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I applied a wrong change to the line 298. It should be
    !isset($nggcf_values[$pid])
    Not
    isset($nggcf_values[$pid])

    After I applied the new change, notice message on line 807 doesn’t show up.

    Plugin Author shauno
    Member

    @shauno

    I had notices suppressed when developing the plugin. Most major hosts also suppress notices by default, so it never really came up. It’s one of those things with a loosely typed language like PHP. One day I will get around to making sure all variables get declared etc, but for now, you get what you pay for I guess 🙂
    Thanks for the feedback, I hope that despite the notices, the plugin is useful to you

    I definitely appreciate your plugin. Thanks a quick reply. Maybe I can apply those isset check for those few lines and send it to you, and you can check them to see if they are good to stay.

    Here is the code blocks for the changes I applied to the plugin.

    Line 298

    if(!isset($nggcf_values[$pid]) or !$nggcf_values[$pid])

    Line 342

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Line 391 becomes 406

    if(isset($_GET["delete"]) and is_numeric($_GET["delete"]))

    Line 426 becomes 441

    if(isset($_GET["editname"]) and $_GET["editname"] == $val->id)

    Line 458 becomes 473

    <div id="nggcf-edit-link-<?php echo $val->id; ?>" class="nggcf-edit-link" style="display:<?php echo (isset($_GET["editlink"]) and $_GET["editlink"] == $val->id) ? "block" : "none"; ?>;">

    So far, I haven’t found a broken function. If anyone apply those changes and found a function broken let me know.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: NextGEN Custom Fields] Undefined index notices in various places.’ is closed to new replies.