沃梦达 / 编程问答 / php问题 / 正文

首次访问页面时,Drupal 生成的 HTML 上方出现神秘数字

Mysterious number appears above Drupal-generated HTML when visiting page for first time(首次访问页面时,Drupal 生成的 HTML 上方出现神秘数字)

本文介绍了首次访问页面时,Drupal 生成的 HTML 上方出现神秘数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Drupal 站点上的许多页面上,当第一次在(编辑)任何浏览器中访问该页面时,HTML 上方(和下方)会出现一个神秘数字.在 IE7 和 IE8 中,有问题的页面呈现不正确,但在其他浏览器中,页面的其余部分呈现没有问题.刷新后,该数字通常会消失.我的用户告诉我该错误每天早上都会再次发生,尽管我见过一个用户刷新并且陌生号码没有消失的情况.我在使用其他浏览器时没有遇到任何问题.

这是 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"><头><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

...页面的其余部分正常生成,然后我在底部看到以下内容:

0

我很困惑 - apache 日志或我的 vhost error.log 上都没有出现任何相关内容.我已经对带有数字的页面与没有和除了顶部和底部数字之外的页面的 html 进行了比较,唯一的区别是空格.

我在 Ubuntu 7.04 上的 Apache 2.2 中运行 Drupal 6.19.PHP 版本为 5.2.

这里是我的 index.php 供参考 - 我认为我们没有对标准进行任何更改.

解决方案

在花大量时间检查自己的代码之前,先分析一下所涉及的网络设置.

大约一年前,我们遇到了类似的现象代理服务器将类似的数字插入到他转发的页面中.

我不记得它是什么代理服务器的详细信息,以及他为什么这样做,但很明显,因为只有从某些网络访问该站点的人才能获得这些数字.

我不是 100% 确定,但我认为是 这个 nginx反向代理问题(这篇文章也可能与此相关.)

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();

解决方案

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.)

这篇关于首次访问页面时,Drupal 生成的 HTML 上方出现神秘数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:首次访问页面时,Drupal 生成的 HTML 上方出现神秘数字

基础教程推荐