WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
[resolved] Notice: Undefined index: wp_the_query (7 posts)

  1. Aaron D. Campbell
    Member
    Posted 2 years ago #

    I get a notice from wp-seo. Basically, WPSEO_Frontend::__construct() calls wp_reset_query(). Since this is included as soon as the plugin is loaded instead of from a hook, $GLOBALS['wp_query'] doesn't yet exist, which wp_reset_query() tries to use. If you're just trying to reset something *if* another plugin has messed with it, you could probably do:

    if ( isset( $GLOBALS['wp_query'] ) )
    	wp_reset_query();

    Here's the actual notice:

    Notice: Undefined index: wp_the_query in /var/www/vhosts/bluedog/wordpress/wp-includes/query.php on line 108
    
    Call Stack:
        0.0002     638792   1. {main}() /var/www/vhosts/bluedog/index.php:0
        0.0004     644320   2. require('/var/www/vhosts/bluedog/wordpress/wp-blog-header.php') /var/www/vhosts/bluedog/index.php:17
        0.0007     667336   3. require_once('/var/www/vhosts/bluedog/wordpress/wp-load.php') /var/www/vhosts/bluedog/wordpress/wp-blog-header.php:12
        0.0010     694368   4. require_once('/var/www/vhosts/bluedog/wp-config.php') /var/www/vhosts/bluedog/wordpress/wp-load.php:34
        0.0022     834760   5. require_once('/var/www/vhosts/bluedog/wordpress/wp-settings.php') /var/www/vhosts/bluedog/wp-config.php:98
        0.1240   36844520   6. include_once('/var/www/vhosts/bluedog/bd-content/plugins/wordpress-seo/wp-seo.php') /var/www/vhosts/bluedog/wordpress/wp-settings.php:196
        0.1305   38138568   7. require('/var/www/vhosts/bluedog/bd-content/plugins/wordpress-seo/frontend/class-frontend.php') /var/www/vhosts/bluedog/bd-content/plugins/wordpress-seo/wp-seo.php:58
        0.1305   38138952   8. WPSEO_Frontend->__construct() /var/www/vhosts/bluedog/bd-content/plugins/wordpress-seo/frontend/class-frontend.php:829
        0.1305   38138952   9. wp_reset_query() /var/www/vhosts/bluedog/bd-content/plugins/wordpress-seo/frontend/class-frontend.php:7

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. bobbingwide
    Member
    Posted 2 years ago #

    Shouldn't wp_reset_query() deal with this?
    I think this is a problem with WordPress 3.3. It doesn't occur in 3.2.1
    3.2.1 code was:
    $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
    3.3 code is currently:
    $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];

    Was this a change for php 5.3?

  3. bobbingwide
    Member
    Posted 2 years ago #

    Note: This change was made in changeset 18995 on 18th October. The comment "new does not require by reference" applies to the first change made in query_posts(), but not to the second which is an assignment by reference. I've raised this as http://core.trac.wordpress.org/ticket/19412

  4. Aaron D. Campbell
    Member
    Posted 2 years ago #

    Since PHP 5+ using =& for the assignment of objects isn't needed, and that's what $GLOBALS['wp_the_query'] is supposed to be. If $GLOBALS['wp_the_query'] is NOT an object yet, then you're calling wp_reset_query() too soon and _doing_it_wrong().

    I still think this is something the plugin should account for, but I'm passing it by the lead devs anyway.

  5. Aaron D. Campbell
    Member
    Posted 2 years ago #

    Yep, the ticket was closed as "wontfix" so my recommendation to fix this in the plugin stands.

  6. bobbingwide
    Member
    Posted 2 years ago #

    IMHO: it would have been just as easy to add an
    if ( isset( $GLOBALS['wp_the_query'] ) )
    into wp_reset_query.
    then no one would have to worry about _doing_it_wrong()

  7. Aaron D. Campbell
    Member
    Posted 2 years ago #

    Looks like this was fixed in 1.1

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic