Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysterious number appears above Drupal-generated HTML when visiting page for first time

On a number of pages on my Drupal site a mysterious number appears above (EDIT: and below) the HTML the first time the page is visited in (EDIT) any browser. In IE7 and IE8 the problem pages are rendering incorrectly, but in the other browsers the rest of the page renders without problems. After a refresh the number usually disappears. My users tell me that the error occurs again each morning, although I've seen one case where a user refreshes and the strange number does NOT go away. I've had no problems with other browsers.

Here are the first few lines of HTML:

3535 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

.. the rest of the page generates normally, and then I see the following at the bottom:

</html> 

0 

I'm baffled - nothing related appears on either apache logs or my vhost error.log. I've done a diff of the html on pages with the number versus pages without and apart from the numbers at top and bottom the only difference is whitespace.

I'm running Drupal 6.19 in Apache 2.2 on Ubuntu 7.04. PHP version is 5.2.

For reference here's my index.php - I don't think there's anything that we've changed from the standard.

<?php
// $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $

/**
 * (Drupal copyright ommitted for brevity)
 */

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$return = menu_execute_active_handler();

// Menu status constants are integers; page content is a string.
if (is_int($return)) {
  switch ($return) {
    case MENU_NOT_FOUND:
      drupal_not_found();
      break;
    case MENU_ACCESS_DENIED:
      drupal_access_denied();
      break;
    case MENU_SITE_OFFLINE:
      drupal_site_offline();
      break;
  }
}
elseif (isset($return)) {
  // Print any value (including an empty string) except NULL or undefined:
  print theme('page', $return);
}

drupal_page_footer();
like image 774
iftheshoefritz Avatar asked Feb 25 '23 20:02

iftheshoefritz


2 Answers

Before spending much time checking your own code, analyze the involved network setup.

We had a similar phenomenon about a year ago where a proxy server inserted numbers like that into the pages he relayed.

I do not remember the details about what proxy server it was, and why he did it, but it was pretty obvious, as only people accessing the site from certain networks would get these numbers.

EDIT: I'm not 100% sure, but I think it was this nginx reverse proxy issue (This post might be related as well.)

like image 102
Henrik Opel Avatar answered Apr 27 '23 13:04

Henrik Opel


Most likely the markup is the same for all browsers but only IE renders it.

My best guess is that somewhere there is a snip of debugging code that is printing out some id. If you have any modules/theme you have developed yourself that would be the best place to start.

If you can't find the source, you can try to switch theme and turn off modules, you should be able to pinpoint it eventually. At first try searching your code for a print_r statement.

like image 43
googletorp Avatar answered Apr 27 '23 14:04

googletorp