diff -prauN /srv/orig/wghtml/wghtml/class_wghtml.php /srv/drupal-5.2/sites/all/modules/wghtml/wghtml/class_wghtml.php
--- /srv/orig/wghtml/wghtml/class_wghtml.php 2007-02-25 03:46:58.000000000 +0100
+++ /srv/drupal-5.2/sites/all/modules/wghtml/wghtml/class_wghtml.php 2007-10-05 03:53:04.000000000 +0200
@@ -144,6 +144,8 @@ class wghtml_page {
}
$this->status = $status;
+ if ($this->status == 'fetched' || $this->status == 'retrieved' || $this->status == 'refreshed')
+ $this->status = ''; /* silence status as long as everything went ok */
return;
diff -prauN /srv/orig/wghtml/wghtml/implement_node_drupal46.php /srv/drupal-5.2/sites/all/modules/wghtml/wghtml/implement_node_drupal46.php
--- /srv/orig/wghtml/wghtml/implement_node_drupal46.php 2007-02-25 03:46:59.000000000 +0100
+++ /srv/drupal-5.2/sites/all/modules/wghtml/wghtml/implement_node_drupal46.php 2007-10-05 11:46:49.000000000 +0200
@@ -60,6 +60,22 @@ class wghtml_implementation extends wght
}
}
+/*
+ * Delete any information associated with the page id or its file
+ * identity from the database, as if the page had never been seen.
+ */
+ function drop_page() {
+ if (!empty ($this->pageId)) {
+ if ($node = node_load ($this->pageId))
+ delete_node ($node->nid);
+ db_query ('LOCK TABLES {wghtml_pages} WRITE, {wghtml_versions} WRITE');
+ db_query ('DELETE FROM {wghtml_versions} WHERE pageId = %d', $this->pageId);
+ db_query ('DELETE FROM {wghtml_pages} WHERE pageId = %d', $this->pageId);
+ if (!empty ($this->identity))
+ db_query ('DELETE FROM {wghtml_pages} WHERE identity = \'%s\'', $this->identity);
+ db_query ('UNLOCK TABLES');
+ }
+ }
/*
* Save the page into the cache. As we want the page to be a Drupal node,
@@ -77,7 +93,7 @@ class wghtml_implementation extends wght
node_save($node);
$this->pageId = $node->nid;
- // TODO why doesn't this work? db_query('LOCK TABLES {wghtml_versions} WRITE');
+ db_query('LOCK TABLES {wghtml_pages} WRITE, {wghtml_versions} WRITE');
// TODO should check here that it has still not been created and return if it has
// create page record
@@ -134,9 +150,15 @@ class wghtml_implementation extends wght
$node->created = $this->signature;
$node->changed = $this->signature;
$node->revisions = '';
- $node->comment = 2;
+ $node->comment = variable_get('comment_'. $node->type, 2);
$node->format = $this->config[$this->config['implementation']]['format'];
// 'teaser', 'revisions', 'status', 'promote', 'moderate', 'sticky', 'format');
+ $node_type_default = variable_get('node_options_'. $node->type, array('status', 'promote'));
+ $node->status = in_array('status', $node_type_default);
+ $node->promote = in_array('promote', $node_type_default);
+ $node->sticky = in_array('sticky', $node_type_default);
+ $node->revision = in_array('revision', $node_type_default);
+
return $node;
}
diff -prauN /srv/orig/wghtml/wghtml.module /srv/drupal-5.2/sites/all/modules/wghtml/wghtml.module
--- /srv/orig/wghtml/wghtml.module 2007-02-25 03:46:54.000000000 +0100
+++ /srv/drupal-5.2/sites/all/modules/wghtml/wghtml.module 2007-10-05 03:46:17.000000000 +0200
@@ -33,8 +33,10 @@ function wghtml_admin_settings() {
return 'The administration for wgHTML has note been done yet.';
}
-function &_wghtml_get_object() {
+function &_wghtml_get_object ($reuse = TRUE) {
static $wghtml;
+ if (!$reuse)
+ unset ($wghtml);
if ( !isset($wghtml) ) {
require_once dirname(__FILE__).'/wghtml/class_wghtml.php';
require_once dirname(__FILE__).'/wghtml/implement_'.$GLOBALS['wghtml_config']['implementation'].'.php';
diff -prauN /srv/orig/wghtml/wghtml_node_module.php /srv/drupal-5.2/sites/all/modules/wghtml/wghtml_node_module.php
--- /srv/orig/wghtml/wghtml_node_module.php 2007-02-25 03:46:54.000000000 +0100
+++ /srv/drupal-5.2/sites/all/modules/wghtml/wghtml_node_module.php 2007-10-05 11:48:48.000000000 +0200
@@ -98,9 +98,21 @@ function _wghtml_show($action=false, $fi
$page =& _wghtml_get_object();
// get the requested page: $file is usually false so get_page uses the REQUEST_URI from the redirect as a default
$page->get_page($file);
+ if (empty ($page->pageId)) { // redirect to 404 page for invalid page requests
+ $_REQUEST['destination'] = urldecode ($_SERVER['REQUEST_URI']); // save real request for search404
+ return drupal_not_found();
+ }
// now load the node: the node load hook will add the page to the node
$node = module_invoke('node', 'load', $page->pageId);
+ if (empty ($node) && $page->pageId) /* might be a deleted node, need page rebuild */
+ {
+ $page->drop_page(); /* delete database traces */
+ /* start over, i.e. unset ->pageId and ->version */
+ $page = &_wghtml_get_object (false);
+ $page->get_page ($file);
+ $node = module_invoke ('node', 'load', $page->pageId);
+ }
return node_page_view($node);
if ( empty($page->error) ) {