Commit 959cae82 authored by Dries's avatar Dries

- added sequence tables

- fixed bug in node_page()

- fixed bug in db_result()

- fixed rss glitch
parent d62b6ded
......@@ -45,7 +45,7 @@ function db_num_rows($result) {
function db_result($result, $field = 0) {
if ($result) {
$tmp = $result->fetchRow(DB_FETCHMODE_ASSOC);
$tmp = $result->fetchRow(DB_FETCHMODE_ORDERED);
return $tmp[$field];
}
}
......
......@@ -133,29 +133,29 @@ function node_save($node, $filter) {
$v2 = implode(", ", $v2);
$result = db_query ("BEGIN");
if (db_error ($result)) {
watchdog ("error", "database: ". $result->getMessage () ."\nquery: ". htmlspecialchars ("BEGIN"));
$result = db_query("BEGIN");
if (db_error($result)) {
watchdog("error", "database: ". $result->getMessage() ."\nquery: ". htmlspecialchars("BEGIN"));
}
else {
$nid = $db_handle->nextId ("node_nid");
$lid = $db_handle->nextId ($filter[type] . "_lid");
$nid = $db_handle->nextId("node");
$lid = $db_handle->nextId($filter[type]);
$result = db_query ("INSERT INTO node ($f1, nid, lid) VALUES ($v1, '$nid', '$lid')");
if (db_error ($result)) {
$result = db_query("INSERT INTO node ($f1, nid, lid) VALUES ($v1, '$nid', '$lid')");
if (db_error($result)) {
watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
}
else {
$result = db_query ("INSERT INTO $filter[type] ($f2, nid, lid) VALUES ($v2, '$nid', '$lid')");
if (db_error ($result)) {
$result = db_query("INSERT INTO $filter[type] ($f2, nid, lid) VALUES ($v2, '$nid', '$lid')");
if (db_error($result)) {
watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
}
else {
$result = db_query ("COMMIT");
if (db_error ($result)) {
watchdog ("error", "database: ". $result->getMessage () ."\nquery: ". htmlspecialchars ("BEGIN"));
$db_handle->rollback ();
$result = db_query("COMMIT");
if (db_error($result)) {
watchdog("error", "database: ". $result->getMessage() ."\nquery: ". htmlspecialchars("BEGIN"));
$db_handle->rollback();
}
watchdog("special", "node: added $filter[type] '$node[title]'");
}
......
......@@ -407,7 +407,7 @@ function node_feed() {
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel(variable_get("site_name", "drupal"), path_uri() ."module.php?mod=node&op=feed", variable_get("site_slogan", ""), $items);
$output .= format_rss_channel(variable_get("site_name", "drupal"), path_uri(), variable_get("site_slogan", ""), $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
......@@ -417,7 +417,7 @@ function node_feed() {
}
function node_page() {
global $op, $theme;
global $op, $theme, $meta, $date;
if ($op == "feed") {
node_feed();
......
......@@ -407,7 +407,7 @@ function node_feed() {
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel(variable_get("site_name", "drupal"), path_uri() ."module.php?mod=node&op=feed", variable_get("site_slogan", ""), $items);
$output .= format_rss_channel(variable_get("site_name", "drupal"), path_uri(), variable_get("site_slogan", ""), $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
......@@ -417,7 +417,7 @@ function node_feed() {
}
function node_page() {
global $op, $theme;
global $op, $theme, $meta, $date;
if ($op == "feed") {
node_feed();
......
<?php
/*
** Move this file to the root of your Drupal tree and access it (execute
** it) through your browser. Make sure to delete this file afterwards so
** it can not be accessed by Malicious Mallory.
*/
include "includes/common.inc";
/*
** Create sequence tables for pear-ification of MySQL
*/
foreach (module_list() as $name) {
if (module_hook($name, "status")) {
print "$name ...";
db_query("DROP TABLE IF EXISTS ". $name ."_seq");
db_query("CREATE TABLE ". $name ."_seq (id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY(id))");
$result = db_query("SELECT MAX(". ($name == "node" ? "nid" : "lid") .") FROM $name", 1);
$count = $result ? db_result($result, 0) : 0;
db_query("INSERT INTO ". $name ."_seq (id) VALUES ('$count')");
print "done ($count)<br />";
}
}
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment