WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
Avoid using WP_error as string (7 posts)

  1. codenegar
    Member
    Posted 10 months ago #

    Hi,

    At file all-in-one-seo-pack\aioseop_class.php Line 1392 the plugin just checks URL is not empty, and it doesn't check if URL contains errors.
    Here is the original line:
    if ( !empty( $url ) )
    Here is a better version of it
    if ( !empty( $url ) && ! is_wp_error( $url ) )

    Could you change this line in the next update?
    Thanks.

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

  2. Peter Baylies
    Member
    Plugin Author

    Posted 10 months ago #

    codenegar,

    Are you running into an issue where the URL is getting set as a WP_Error object? The functions used here such as get_permalink() and get_post_type_archive_link() return false on error, so is_empty() is generally sufficient here. If you can provide a case where it isn't, sure, I'll change it, but I'd like to know if or why this is happening for you.

  3. codenegar
    Member
    Posted 9 months ago #

    I have a plugin that generates pages on the fly, it uses WordPress search and custom taxonomies to create pages with custom posts.
    Some users can't load pages when your plugin is active, I debugged the code and found that your plugin uses $url variable as string (in fact it's a wp_error object in those cases).
    I need to edit each your plugin, but it's more bullet proof for your plugin to avoid using wp_error as string.

  4. Peter Baylies
    Member
    Plugin Author

    Posted 9 months ago #

    codenegar,

    Can you tell me how $url gets set as a WP_Error() object? Is that happening in the aiosp_mrt_get_url() function or in some other code? I'll consider adding a check for this, but it'd help to know where or how this is taking place. You should also be able to fix this by using the aioseop_canonical_url filter.

  5. codenegar
    Member
    Posted 9 months ago #

    Thank you.
    I did another debug and found that errors happen in aiosp_mrt_get_url function.
    At line 1821 when it looks for a taxonomy and a term, if the term is empty, get_term_link return an error.
    If you add here a condition to check $term, $taxonomy are not empty, it would be much bullet proof code.

  6. Peter Baylies
    Member
    Plugin Author

    Posted 9 months ago #

    codenegar,

    Thanks for that; I'll add some better error checking and handling of this in the next release, which should be out soon.

  7. codenegar
    Member
    Posted 9 months ago #

    Great. Thanks.

Reply

You must log in to post.

About this Plugin

About this Topic