Skip to:

Opened 10 years ago

Closed 10 years ago

#5716 closed defect (bug) (fixed)

bp_core_load_template() missing $wp_query declaration

Reported by: sgr33n's profile SGr33n Owned by: r-a-y's profile r-a-y
Milestone: 2.1 Priority: normal
Severity: normal Version: 1.5
Component: Core Keywords: has-patch commit



I don't know if this is a Google or a BuddyPress issue, but just on BuddyPress user pages, the Google Plugin report some notices:

Notice: Undefined property: WP_Query::$post in sitelocalpath/httpdocs/wp-content/plugins/google-publisher/Utils.php on line 55

Notice: Trying to get property of non-object in sitelocalpath/httpdocs/wp-content/plugins/google-publisher/Utils.php on line 55

The line code is:

    if (is_page()) {
      global $wp_query;
      $template_name = get_post_meta(
          // The following is line 55.
          $wp_query->post->ID, '_wp_page_template', true);
      if ($template_name != 'default') {
        return 'customPageTemplate';
      return 'page';

Thanks :)

Attachments (1)

5716.01.patch (466 bytes) - added by r-a-y 10 years ago.

Download all attachments as: .zip

Change History (9)

#1 @DJPaul
10 years ago

  • Component changed from Core to Rewrite Rules
  • Keywords reporter-feedback added
  • Milestone changed from Awaiting Review to 2.1

Thanks, we'll look into it and see if it's us. How exactly do we recreate this? Just activate that plugin, and then visit a BP user profile page? Anything else?

#2 @SGr33n
10 years ago

That's all, nothing else, just activating... then WP_DEBUG = true


#3 @SGr33n
10 years ago

  • Keywords reporter-feedback removed

#4 @r-a-y
10 years ago

  • Component changed from Rewrite Rules to Core
  • Owner set to r-a-y
  • Status changed from new to assigned
  • Summary changed from BuddyPress & Official Google Publisher Plugin to Theme compatibility - Reset post issue

I think this is a theme compatibility reset post issue.

Will take a look at it.

10 years ago

#5 @r-a-y
10 years ago

  • Keywords has-patch added
  • Summary changed from Theme compatibility - Reset post issue to bp_core_load_template() missing $wp_query declaration
  • Version set to 1.5

This is actually not a theme compatibility issue; it's an issue with bp_core_load_template().

bp_core_load_template() attempts to set some $wp_query properties to avoid notices, but doesn't set all of them. Attached patch fixes the missed $wp_query->post property declaration, which caused the notice that the Google Publisher plugin triggered.

Will commit this patch and do some further clean up of bp_core_load_template() that I eluded to in ticket:5241#comment:13.

#6 @DJPaul
10 years ago

  • Keywords commit added

Looks good

This ticket was mentioned in IRC in #buddypress-dev by paulgibbs. View the logs.

10 years ago

#8 @r-a-y
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 8738:

Fix notice in bp_core_load_template().

Fixes #5716.

Note: See TracTickets for help on using tickets.