Ticket #1129 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 3 years ago

Improved 404 reporting

Reported by: SteveBooth Owned by:
Priority: low Milestone:
Component: Front-end Version: 1.0-rc-3 (trunk)
Severity: minor Keywords: 404 permalinks improvements
Cc:

Description

In trying to debug the problem with my bbPress implementation on my SunOS host, it became very important to know who generated the 404 errors I encountered when browsing to my bbPress home directory. Specifically, I needed to know who was reporting the 404 error (i.e. who was calling '404.php' in the selected template), and what uri was considered bad. To do this, I enhanced the 404.php module and added a single line to bb_repermalink. The simple changes greatly assisted in determining the problem.

I would submit them as an enhancement for future releases.

First, I created a GLOBALS variable as follows, in bb_repermalink:

	if ( $check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri) ) {
		if ( $issue_404 && rtrim( $check, " \t\n\r\0\x0B/" ) !== rtrim( $uri, " \t\n\r\0\x0B/" ) ) {
			status_header( 404 );

			$GLOBALS['bad404url'] = 'From functions.bb-core.bb_repermalink $uri: >' . $uri . '<';

			bb_load_template( '404.php' );
		} else {
			wp_redirect( $permalink );
		}
		exit;
	}


And the 404.php code was modified slightly (I'm using the default 'Kakumei' template:

<h2 id="http404"><?php _e('Page not found!'); ?></h2>

<p>
  <?php _e('I\'m sorry, but there is nothing at the URL:'); ?><br/>
  <b><?php 
    _e($GLOBALS['bad404url']);?>
  <br/></b>

  <!-- //_e('['); _e(strlen($GLOBALS['bad404url'])); _e(' bytes]'); ?><br/></b> -->
</p>

The basic intent here is to not just tell the user that there is a '404 Error', but to give him (and us) at least some hint as to who threw the error and why.

Attachments

404Enhancement.jpg Download (162.3 KB) - added by SteveBooth 3 years ago.
Screen shot of suggested 404 format

Change History

Screen shot of suggested 404 format

  • Type changed from defect to enhancement

If done correctly, the 404 page should be less an error message, and more a way for the user to solve the problem.

Start by placing the tag cloud on the 404 page, so that there's a good chance of finding topic-based information. A search box or (better, but difficult to implement) search results can be displayed (or at the very least, the text should refer to the existence of a search box/page).

  • Status changed from new to closed
  • Resolution set to wontfix
  • Milestone 1.0 deleted

If you want that info, then add this to your bb-config.php

define( 'BB_LOG_LEVEL', BB_LOG_ALL + BB_LOG_DEBUG );
define( 'BB_LOG_TYPE', 'display' );
Note: See TracTickets for help on using tickets.