[buddypress-trac] [BuddyPress] #4086: Friends, Groups & Co are handled as 404 & nothing gets indexed by search engines
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Sat Mar 17 12:53:45 UTC 2012
#4086: Friends, Groups & Co are handled as 404 & nothing gets indexed by search
engines
--------------------------+-----------------------------
Reporter: wpdennis | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Core | Version:
Severity: blocker | Keywords: dev-feedback
--------------------------+-----------------------------
I've found a very critical bug in handling detail pages in buddypress. It
will throw a 404 internally, is setting wrong canonical urls and results
in a strange behaviour of functions like is_single().
----
Just have a look into the html source of:
http://buddypress.org/community/groups/installing-buddypress/home/
The canonical tag says "http://buddypress.org/community/groups/"
The result is: nothing gets indexed by search engines. The forum posts
have wrong canonical tags, too. So, Google doesn't know any of the
existing topics. Each one is redirecting to the group index:
https://www.google.de/#q=site:buddypress.org+inurl%3Aforum%2Ftopic
(This query would show a lot of posts in the forums, if the canonical
wouldn't disallow it)
Further problems are, that functions like "is_single()" have unpredictable
results.
Example: is_single() returns FALSE at
http://buddypress.org/community/groups/installing-buddypress/
BUT if you have an image uploaded in wordpress with the name "installing-
buddypress", is_single() will return TRUE at
http://buddypress.org/community/groups/installing-buddypress/
----
'''A try to break it down'''
I implemented a quick backtrace if wp_query->is_single is set.
A call to http://buddypress.org/community/groups/installing-buddypress/
(just as an example) will result in:
{{{
#0 WP_Query->__set(is_single, ) called at [/wp/wp-
includes/query.php:1290]
#1 WP_Query->init_query_flags() called at [/wp/wp-
includes/query.php:1344]
#2 WP_Query->init() called at [/wp/wp-includes/query.php:2911]
#3 WP_Query->query(Array ([attachment] => installing-buddypress)) called
at [/wp/wp-includes/class-wp.php:460]
#4 WP->query_posts() called at [/wp/wp-includes/class-wp.php:507]
#5 WP->main() called at [/wp/wp-includes/functions.php:1570]
#6 wp() called at [/wp/wp-blog-header.php:14]
#7 require(/wp/wp-blog-header.php) called at [/wp/index.php:17]
}}}
This is just the initialization and init_query_flags() will set is_single
to FALSE.
The second call is because the query gets parsed. The group is handled as
attachement. If an attachement with the same name exists, it will set
is_single to TRUE. If not, a 404 is handled internally.
{{{
#0 WP_Query->__set(is_single, 1) called at [/wp/wp-
includes/query.php:1466]
#1 WP_Query->parse_query() called at [/wp/wp-includes/query.php:1921]
#2 WP_Query->get_posts() called at [/wp/wp-includes/query.php:2913]
#3 WP_Query->query(Array ([attachment] => installing-buddypress)) called
at [/wp/wp-includes/class-wp.php:460]
#4 WP->query_posts() called at [/wp/wp-includes/class-wp.php:507]
#5 WP->main() called at [/wp/wp-includes/functions.php:1570]
#6 wp() called at [/wp/wp-blog-header.php:14]
#7 require(/wp/wp-blog-header.php) called at [/wp/index.php:17]
}}}
With existing attachement:
parse_query() sets is_single to TRUE.
Without existing attachement:
parse_query() sets is_single to FALSE.
If an attachement exists, is_single isn't set again. If no attachement
exists, wordpress handles it as an 404. In this case set(is_single) is
called a third time:
{{{
#0 WP_Query->__set(is_single, ) called at [/wp/wp-
includes/query.php:1290]
#1 WP_Query->init_query_flags() called at [/wp/wp-
includes/query.php:1871]
#2 WP_Query->set_404() called at [/wp/wp-includes/class-wp.php:484]
#3 WP->handle_404() called at [/wp/wp-includes/class-wp.php:508]
#4 WP->main() called at [/wp/wp-includes/functions.php:1570]
#5 wp() called at [/wp/wp-blog-header.php:14]
#6 require(/wp/wp-blog-header.php) called at [/wp/index.php:17]
}}}
Because of the init_query_flags() is_single is now set to FALSE. So
is_single() will return FALSE again.
----
There are multiple bad things we should investigate:
1. The wrong canonical tags are a blocker. Nothing gets indexed by search
engines. Because of a plugin (YOAST SEO) my canonical tags gets stripped
out in the most cases - except on groups where an attachement with the
same name exists.
2. Is it avoidable to throw a 404 internally?
3. is_single() should return the same value for each group (I rely on it
for a breadcrumb menu, for example). This would be the case, if we can
avoid the 404, I think.
Important: This isn't group specific, so I set "Core" as Component for
this ticket. Members have the exact same issues. Every profile throws an
404 and has a wrong canonical url.
To check this, just add
{{{
global $wp_query;
print_r($wp_query->query_vars);
}}}
to the theme template file for member or group home. You'll find the
error=>404 except you have an image with the same name. Then it'll contain
attachement=>groupOrMemberName.
I would love to hear some oppinions from more experienced bp-developers,
before I digg in the wrong direction.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4086>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list