If one has a static page that is of type PHP (versus HTML), this type is set in the {page} table, format column as a value 1.

If one has statistics enabled, and is generating a page with most popular content, and on of those pages happens to be one of your "static" PHP pages as defined above, the PHP code is output as poorly formatted HTML text, instead of being evaluated.

This bug exist in all versions of Drupal since 4.3 as far as I can tell. I did not check older versions, but it's probably there, too.

The check probably needs to be made here, where I've hacked in a DEBUG fix to skip PHP pages:

function statistics_summary($dbfield, $dbrows) {
  /* valid dbfields: totalcount, daycount, timestamp */

  $output = "";
  $result = db_query_range("SELECT n.nid, n.title FROM {node_counter} s INNER   JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC", $dbfield, 0, $dbrows);
  while ($nid = db_fetch_array($result)) {
    $content = node_load(array("nid" => $nid["nid"]));

/* DEBUG */
if (isset($content) && $content->format == 1) {
    // this is a PHP generated node
    continue;
}
/* END DEBUG */

    $links = link_node($content, 1);

    $output .= "<tr><td><strong>". l($nid["title"], "node/view/". $nid["nid"],  array("title" => t("View this posting."))) ."</strong></td><td style=\"text-    align: right;\"><small>". t("Submitted by %a on %b", array("%a" =>              format_name($content), "%b" => format_date($content->created, "large"))) ."</   small></td></tr>";
    $output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 20px;\">".      check_output($content->teaser) ."</div></td></tr>";
    $output .= "<tr><td style=\"text-align: right;\" colspan=\"2\">[ ".         theme("links", $links) ." ]<br /><br /></td></tr>";
  }

  return $output;
}

Comments

Steven’s picture

This was fixed with the input formats patch.

Anonymous’s picture