• Just updated to WordPress 3.1.3. Did fresh install of All in One SEO Pack 1.6.13.2.

    Tested Debug Mode and got the following errors:

    Notice: Undefined index: aiosp_enabled in test/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766

    Notice: Undefined index: aiosp_enabled in test/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766

    Warning: Cannot modify header information – headers already sent by (output started at test/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php:766) in test/wp-includes/pluggable.php on line 897

Viewing 4 replies - 1 through 4 (of 4 total)
  • To the plugin author, this is easy to fix and needs to be done in the next version. It occurs when WP_DEBUG is enabled:

    http://codex.wordpress.org/Editing_wp-config.php#Debug

    The fix is simple this case. The warning is caused by you checking the value of an array item inside $_POST without first checking that the key exists. PHP is very picky when you give it the chance, and demands that you never access array/object properties that odn’t exist. When you want to use part of $_POST, like the ‘aiosp_enabled’ key that sets off the warning described above, you need to run isset() first. So instead of

    if ($_POST['aiosp_enabled'] == null)
         do_thing();

    You should instead have something like

    $aiosp_enabled = false;
    if (isset($_POST['aiosp_enabled'])
         $aiosp_enabled = $_POST['aiosp_enabled'];
    if ($aiosp_enabled == null)
         do_thing();

    More fundamentally, you should enable WP_DEBUG while you are developing your plugins , this will let you know when your code is causing warnings and make it easy to fix them as you go. It is important that all plugins be WP_DEBUG-compatible because otherwise developers who run it to test their own plugins are forced to disable yours while doing so, which means they effectively haven’t tested compatibilty with your plugin during the process.

    Thanks in advance for fixing this. In this case it will be very simple to solve the problem, though once you enable WP_DEBUG you will probably find more simple issues to fix in your plugin.

    @jeremyclarke

    Running wp 3.3.2 here with Debug Bar plug activated and it shows lately a lot Notice: Undefined index: for several plugins (although they seem to work when debug option in wp-config.php is not activated).

    I am totaly not familiar with the debug option and errors which show up now. If it are “just” notices does that mean they still can harm or what can be the case if these “notices” are not solved?

    Some specs here:(VMware) Wampserver 2.2 with PHP v5.3.10 / MySQL 5.5.20 and WP v3.3.2 (XP-Pro Srv3 as OS).

    Thnx in advance for anyone who could give some input.

    Hi another-webmaster,

    The notices are not harmful necessarily, they are just PHP noting that the developer was not particularly careful. DebugBar/WP_DEBUG effectively tell PHP to be strict, which makes it behave more like other programming languages which have very precise standards about what is acceptable, compared to default PHP which allows sloppy behavior.

    When you are coding, notices are often an excellent way to find why your code isn’t working, which is why keeping your working code notice-free is so valuable.

    You usually don’t have to worry about plugins throwing notices, it’s just annoying because it gets in the way of testing your own plugin. Most plugins only have notices on their own pages so you can just ignore them. If you want to keep WP_DEBUG on but a plugin is causing a notice on every single pageload you can usually fix it pretty easily in the plugin code, you’ll just have to re-apply the fix when you update the plugin in the future unless you can convince the plugin author to update their version (which I’m trying to do above 😉

    http://codex.wordpress.org/Debugging_in_WordPress

    Thank you for the clear explanation Jeremy.
    I thought it had to do with the sandbox setup but after reading this I realised I activated debug for my own simple “creation”, which lucky enough for me is still flawless 🙂
    To be short…it should not be a cause for pageload delays?! and is actual (nasty said) crappy coding.
    Several authors said that I should take off the debug and be happy that the plugin was/is for free…ugh.
    Anyway, thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Errors – Notice: Undefined Index and Cannot modify header’ is closed to new replies.