WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
[resolved] Two "undefined index" notices (9 posts)

  1. Christian Sciberras
    Member
    Posted 2 years ago #

    In a system I work with, I'm logging all information about the running of the said system.

    As such, we get a lot of diagnostic information which are otherwise ignored by regular installs. This allows us to issue "advisories" to plugin authors (and WordPress itself) to help them fix potential issues in code.

    As such, I would like to report my findings on AIOSEOP plugin:

    [aioseop.class.php : 1155] Notice: Undefined index: nonce-aioseop-edit
    [aioseop.class.php : 1154] Notice: Undefined index: aiosp_edit

    Kind regards, Chris.

    http://wordpress.org/extend/plugins/all-in-one-seo-pack/

  2. Peter Baylies
    Member
    Plugin Author

    Posted 2 years ago #

    Chris,

    Thanks for the tip; this should be fixed in the next release.

  3. Christian Sciberras
    Member
    Posted 1 year ago #

    Still not fixed, though the source locations have changed.

    A simple fix would be to replace the following:

    $awmp_edit = $_POST['aiosp_edit'];
    $nonce = $_POST['nonce-aioseop-edit'];

    with this one:

    $awmp_edit = isset($_POST['aiosp_edit']) && $_POST['aiosp_edit'];
    $nonce = isset($_POST['nonce-aioseop-edit']) && $_POST['nonce-aioseop-edit'];

    Also, I gave a more general look to the code; while I don't mean to criticize, there's an excessive amount of unnecessary code, such as loading $title and not actually using it anywhere.
    A simple way to fix these issues would be with the use of an intelligent IDE, such as Netbeans, or by making using of PHP QA (quality assurance) tools.

    Kind regards,
    Chris.

  4. Peter Baylies
    Member
    Plugin Author

    Posted 1 year ago #

    Chris,

    Thanks for the advice; a lot of this has been changed in our development version, which will be our next major release; I'd appreciate your feedback on that once it's released. Personally, I generally use TextMate for my programming. What do you use for QA tools, I've tried using phpmd before, some of its recommendations can be helpful.

  5. Christian Sciberras
    Member
    Posted 1 year ago #

    Peter,

    Once you get past Netbeans' general sluggishness, you get to see some of its (very useful) features.
    I think sluggishness is a good trade-off for writing better code.
    While I don't want to force Netbeans on anyone, I think it is worth a try.

    I gave the code another look. In all of the PHP files I checked, aioseop.class.php is the one with most issues as reported through Netbeans.

    The file is v1.6.15, and it has issues on the following lines:
    201 - $home not used in function
    217 - $title not used in function
    316 - $matches is not defined, just do a $matches = null; before that line
    469 - Global variable not in use (this doesn't cost much in performance, I wouldn't change it for the sake of remembering variable name)
    474 - $has_ut is not used in function.
    564 - $has_ut is not defined (I guess you need to move line 474 here?)
    596 - Variable $len_end not in use.
    639 - $post not in use (or did you mean to replace $GLOBALS['post']?)
    1022 - $id not used.
    1167..1169 - I think you meant to specify global $aiosp_keywords etc in the beginning of the function?
    1251 - $description not used
    1360 - $message not used
    2094 - $typeswehave doesn't seem to be used

  6. Christian Sciberras
    Member
    Posted 1 year ago #

    Adding to my earlier message, while the above code tips are not really instrumental to running this plugin, I think they're worth a quick look.

    The bigger issue I would tackle is ensuring all those $_POST values do in fact exist.

    Of course QA tools would probably help, but I think with this list you'll pretty much cover most of it.

    The coding style in general looks ok. As far as I can tell, indentation is consistent etc, unlike other plugins I've reviewed. Thumbs up for that. :)

  7. Peter Baylies
    Member
    Plugin Author

    Posted 1 year ago #

    Chris,

    Thanks for that; I've used Netbeans before, and while I do enjoy having a good IDE, I've also found it to be rather sluggish, clunky, and overly complex. What feature are you using to report those issues? As I've said, a lot of this has changed and will change, but we're always improving things, so I do appreciate the feedback.

  8. Christian Sciberras
    Member
    Posted 1 year ago #

    Peter,

    As of Netbeans 7.2, the issues I mentioned are reported automatically (they're yellow marks in the right margin and warning icon on the left next to the line).

    Here's an example of hints, although in a Java file instead of PHP.

    If you would like to see some more details about Netbeans, please check out this link.

    Although I can't be specific about external QA tools, I remember seeing an article detailing how they work and what they do.

  9. Peter Baylies
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, that's a pretty useful little feature there.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic