[wp-trac] [WordPress Trac] #44848: Ensure that empty author profiles have proper 404 behaviour

WordPress Trac noreply at wordpress.org
Mon Aug 27 14:33:38 UTC 2018


#44848: Ensure that empty author profiles have proper 404 behaviour
----------------------------+-----------------------------
 Reporter:  jonoaldersonwp  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Query           |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  template        |
----------------------------+-----------------------------
 ** Summary **

 - WordPress 'creates' a ''profile posts archive'' (i.e., "See all posts by
 [author name]") for each user in the system. This can be reached by
 clicking 'view' from the Users table in wp-admin.

 - It does so, ''even if they have no posts'' - and even if they lack the
 permission to publish posts entirely.

 - Whilst the empty profile pages ''look'' like they serve a standard 404
 error, in fact, they return a 200 HTTP header status, and just call the
 404 template part for the main page body.

 - This results in many 'soft 404' pages/errors, which can adversley impact
 the way in search engines and other systems (Facebook, Twitter, etc)
 crawl, extract information from, and value/evaluate websites (see Google's
 documentation on soft 404s at
 https://support.google.com/webmasters/answer/181708?hl=en).

 It's important that we correct this behaviour in WordPress Core for
 numerous reasons; from compliance with basic web standards (error pages
 should return an appropriate HTTP header status), to adherence with the
 guidelines and preferences of external platforms (search engines, social
 networks, etc), to consistency with other page/template handling
 processes.

 ** Example **

 A newly created `subscriber` user on a test site (called 'Test User 2')
 with no authored posts has an author archive accessible at
 https://yoast.jonoalderson.com/author/test-user-2/. Although this presents
 as a 404 error, the page returns meta data and behaviour consistent with a
 valid author request (see the tags contained in the `<head>` of the HTML
 source; particularly the `<meta>` tags). The body template then just calls
 the 404 template part.

 ** Solution **

 We should ensure that these scenarios return proper/consistent 404
 behaviour.

 Specifically, requests to author profiles where the author has zero posts
 should trigger normal 404 behaviour (including headers, query behaviour,
 etc), as opposed to just calling the 404 template.

 E.g.,
 {{{
 // If author archive has zero posts
 global $wp_query;
 $wp_query->set_404();
 status_header(404);
 include( get_query_template( '404' ) );
 die();
 }}}

 As opposed to just:
 {{{
 // If author archive has zero posts
 include( get_query_template( '404' ) );
 die();
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44848>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list