diff -urN -F'^f' drupal/includes/common.inc drupal-patched/includes/common.inc
--- drupal/includes/common.inc	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/includes/common.inc	2004-08-22 20:49:27.633472752 +1000
@@ -446,6 +446,7 @@ function fix_gpc_magic() {
  */
 function array2object($array) {
   if (is_array($array)) {
+    $object = new stdClass();
     foreach ($array as $key => $value) {
       $object->$key = $value;
     }
diff -urN -F'^f' drupal/includes/file.inc drupal-patched/includes/file.inc
--- drupal/includes/file.inc	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/includes/file.inc	2004-08-22 20:49:27.634472600 +1000
@@ -437,6 +437,7 @@ function file_scan_directory($dir, $mask
         }
         elseif (ereg($mask, $file)) {
           $name = basename($file);
+          $files["$dir/$file"] = new stdClass();
           $files["$dir/$file"]->filename = "$dir/$file";
           $files["$dir/$file"]->name = substr($name, 0, strrpos($name, '.'));
           if ($callback) {
diff -urN -F'^f' drupal/includes/module.inc drupal-patched/includes/module.inc
--- drupal/includes/module.inc	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/includes/module.inc	2004-08-22 20:53:25.202356792 +1000
@@ -238,7 +238,7 @@ function module_invoke_all($hook, $a1 = 
   $return = array();
   foreach (module_list() as $module) {
     $result = module_invoke($module, $hook, $a1, $a2, $a3, $a4);
-    if (isset($result)) {
+    if (is_array($result)) {
       $return = array_merge($return, $result);
     }
   }
diff -urN -F'^f' drupal/modules/block.module drupal-patched/modules/block.module
--- drupal/modules/block.module	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/modules/block.module	2004-08-22 20:49:27.636472296 +1000
@@ -360,7 +360,10 @@ function block_list($region) {
         ** based on server load.
         */
         if (!($block['throttle'] && (module_invoke('throttle', 'status') > 4))) {
-          $block = array_merge($block, module_invoke($block['module'], 'block', 'view', $block['delta']));
+          $array = module_invoke($block['module'], 'block', 'view', $block['delta']);
+          if (is_array($array)) { 
+            $block = array_merge($block, $array);
+          }
         }
         if (isset($block['content']) && $block['content']) {
           $blocks[$region]["$block[module]_$block[delta]"] = (object) $block;
diff -urN -F'^f' drupal/modules/comment.module drupal-patched/modules/comment.module
--- drupal/modules/comment.module	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/modules/comment.module	2004-08-22 21:21:54.910441656 +1000
@@ -503,6 +503,7 @@ function comment_preview($edit) {
 
   $output = '';
 
+  $comment = new StdClass();
   foreach ($edit as $key => $value) {
     $comment->$key = $value;
   }
diff -urN -F'^f' drupal/modules/forum.module drupal-patched/modules/forum.module
--- drupal/modules/forum.module	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/modules/forum.module	2004-08-22 21:19:44.951198464 +1000
@@ -152,6 +152,7 @@ function forum_link($type, $node = 0, $m
 
     while ($topic = db_fetch_object($result)) {
       if ($stop == 1) {
+        $next = new StdClass();
         $next->nid = $topic->nid;
         $next->title = $topic->title;
         break;
@@ -306,7 +307,12 @@ function _forum_last_comment($nid) {
 
 function _forum_last_reply($nid) {
   $value = db_fetch_object(db_query_range('SELECT c.timestamp, c.name AS anonymous_name, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = 0 ORDER BY c.timestamp DESC', $nid, 0, 1));
-  $value->name = $value->uid ? $value->name : $value->anonymous_name;
+  if ($value) {
+    $value->name = $value->uid ? $value->name : $value->anonymous_name;
+  }
+  else {
+    $value = new StdClass();
+  }
   return $value;
 }
 
@@ -368,10 +374,13 @@ function _forum_topics_read($term, $uid)
 
 function _forum_last_post($term) {
   $topic = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), n.created AS timestamp, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {users} u ON n.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY timestamp DESC", $term, 0, 1));
-
   $reply = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), c.timestamp, c.name AS anonymous_name, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {comments} c ON n.nid = c.nid INNER JOIN {users} u ON c.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." AND c.status = 0 ORDER BY c.timestamp DESC", $term, 0, 1));
-  $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name;
-
+  if ($reply) {
+    $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name;
+  }
+  else {
+    $reply = new StdClass();
+  }
   $value = ($topic->timestamp > $reply->timestamp) ? $topic : $reply;
 
   return $value;
diff -urN -F'^f' drupal/modules/node.module drupal-patched/modules/node.module
--- drupal/modules/node.module	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/modules/node.module	2004-08-22 20:49:27.637472144 +1000
@@ -342,7 +342,7 @@ function node_invoke_nodeapi(&$node, $op
     $function = $name .'_nodeapi';
     if (function_exists($function)) {
       $result = $function($node, $op, $a3, $a4);
-      if (isset($result)) {
+      if (is_array($result)) {
         $return = array_merge($return, $result);
       }
     }
@@ -392,7 +392,7 @@ function node_load($conditions, $revisio
   }
 
   // Return the desired revision.
-  if ($revision != -1 && isset($node->revisions[$revision])) {
+  if ($revision != -1 && is_array($node->revisions[$revision])) {
    $node = $node->revisions[$revision]['node'];
   }
 
@@ -809,6 +809,7 @@ function node_default_settings() {
 
   $header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings')));
   foreach (node_list() as $type) {
+    $node = new StdClass();
     $node->type = $type;
     $cols = array();
     foreach (node_invoke_nodeapi($node, 'settings') as $setting) {
@@ -1216,7 +1217,13 @@ function node_form($edit) {
     }
   }
 
-  return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], array_merge($param['options'], array('id' => 'node-form')));
+  if (is_array($param['options'])) {
+    $array = array_merge($param['options'], array('id' => 'node-form'));
+  }
+  else {
+    $array = array('id' => 'node-form');
+  }
+  return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $array);
 }
 
 /**
diff -urN -F'^f' drupal/modules/user.module drupal-patched/modules/user.module
--- drupal/modules/user.module	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/modules/user.module	2004-08-22 20:49:27.642471384 +1000
@@ -49,14 +49,19 @@ function user_load($array = array()) {
   }
   $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", 0, 1);
 
-  $user = db_fetch_object($result);
-  $user = drupal_unpack($user);
-  user_module_invoke('load', $array, $user);
+  if (db_num_rows($result)) {
+    $user = db_fetch_object($result);
+    $user = drupal_unpack($user);
+     user_module_invoke('load', $array, $user);
 
-  $user->roles = array();
-  $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
-  while ($role = db_fetch_object($result)) {
-    $user->roles[$role->rid] = $role->name;
+    $user->roles = array();
+    $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
+    while ($role = db_fetch_object($result)) {
+      $user->roles[$role->rid] = $role->name;
+    }
+  }
+  else {
+    $user = new StdClass();
   }
 
   return $user;
diff -urN -F'^f' drupal/themes/chameleon/chameleon.theme drupal-patched/themes/chameleon/chameleon.theme
--- drupal/themes/chameleon/chameleon.theme	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/themes/chameleon/chameleon.theme	2004-08-22 21:29:42.568346848 +1000
@@ -124,6 +124,7 @@ function chameleon_node($node, $main = 0
 
   $submitted = theme_get_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small')))) : array();
 
+  $terms = array();
   if (module_exist('taxonomy')) {
     $terms = taxonomy_link("taxonomy terms", $node);
   }
diff -urN -F'^f' drupal/themes/engines/xtemplate/xtemplate.engine drupal-patched/themes/engines/xtemplate/xtemplate.engine
--- drupal/themes/engines/xtemplate/xtemplate.engine	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/themes/engines/xtemplate/xtemplate.engine	2004-08-22 21:13:13.969636696 +1000
@@ -7,6 +7,7 @@ function xtemplate_init($template) {
   if (!class_exists('XTemplate')) {
     include_once('themes/engines/xtemplate/xtemplate.inc');
   }
+  $GLOBALS["xtemplate"] = new StdClass();
   $GLOBALS['xtemplate']->template = new XTemplate(basename($template->filename), dirname($template->filename));
   $GLOBALS['xtemplate']->template->SetNullBlock(' ');  // '' doesnt work!
 }
diff -urN -F'^f' drupal/themes/engines/xtemplate/xtemplate.inc drupal-patched/themes/engines/xtemplate/xtemplate.inc
--- drupal/themes/engines/xtemplate/xtemplate.inc	2004-08-22 12:54:36.000000000 +1000
+++ drupal-patched/themes/engines/xtemplate/xtemplate.inc	2004-08-22 21:11:38.855096304 +1000
@@ -39,40 +39,40 @@
 
 /***[ variables ]***********************************************************/
 
-var $filecontents="";               /* raw contents of template file */
-var $blocks=array();                /* unparsed blocks */
-var $parsed_blocks=array();         /* parsed blocks */
-var $preparsed_blocks=array();      /* preparsed blocks, for file includes */
-var $block_parse_order=array();     /* block parsing order for recursive parsing (sometimes reverse:) */
-var $sub_blocks=array();            /* store sub-block names for fast resetting */
-var $VARS=array();                  /* variables array */
-var $FILEVARS=array();              /* file variables array */
-var $filevar_parent=array();        /* filevars' parent block */
-var $filecache=array();             /* file caching */
-
-var $tpldir="";                     /* location of template files */
-var $FILES=null;                    /* file names lookup table */
-
-var $file_delim="/\{FILE\s*\"([^\"]+)\"\s*\}/m";  /* regexp for file includes */
-var $filevar_delim="/\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}/m";  /* regexp for file includes */
-var $filevar_delim_nl="/^\s*\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}\s*\n/m";  /* regexp for file includes w/ newlines */
-var $block_start_delim="<!-- ";     /* block start delimiter */
-var $block_end_delim="-->";         /* block end delimiter */
-var $block_start_word="BEGIN:";     /* block start word */
-var $block_end_word="END:";         /* block end word */
+public $filecontents="";               /* raw contents of template file */
+public $blocks=array();                /* unparsed blocks */
+public $parsed_blocks=array();         /* parsed blocks */
+public $preparsed_blocks=array();      /* preparsed blocks, for file includes */
+public $block_parse_order=array();     /* block parsing order for recursive parsing (sometimes reverse:) */
+public $sub_blocks=array();            /* store sub-block names for fast resetting */
+public $VARS=array();                  /* variables array */
+public $FILEVARS=array();              /* file variables array */
+public $filevar_parent=array();        /* filevars' parent block */
+public $filecache=array();             /* file caching */
+
+public $tpldir="";                     /* location of template files */
+public $FILES=null;                    /* file names lookup table */
+
+public $file_delim="/\{FILE\s*\"([^\"]+)\"\s*\}/m";  /* regexp for file includes */
+public $filevar_delim="/\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}/m";  /* regexp for file includes */
+public $filevar_delim_nl="/^\s*\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}\s*\n/m";  /* regexp for file includes w/ newlines */
+public $block_start_delim="<!-- ";     /* block start delimiter */
+public $block_end_delim="-->";         /* block end delimiter */
+public $block_start_word="BEGIN:";     /* block start word */
+public $block_end_word="END:";         /* block end word */
 
 /* this makes the delimiters look like: <!-- BEGIN: block_name --> if you use my syntax. */
 
-var $NULL_STRING=array(""=>"");     /* null string for unassigned vars */
-var $NULL_BLOCK=array(""=>"");      /* null string for unassigned blocks */
-var $mainblock="main";
-var $ERROR="";
-var $AUTORESET=1;                    /* auto-reset sub blocks */
+public $NULL_STRING=array(""=>"");     /* null string for unassigned vars */
+public $NULL_BLOCK=array(""=>"");      /* null string for unassigned blocks */
+public $mainblock="main";
+public $ERROR="";
+public $AUTORESET=1;                    /* auto-reset sub blocks */
 
 /***[ constructor ]*********************************************************/
 
 
-function XTemplate ($file,$tpldir="",$files=null,$mainblock="main") {
+public function XTemplate ($file,$tpldir="",$files=null,$mainblock="main") {
   $this->tpldir = $tpldir;
   if (gettype($files)=="array")
     $this->FILES = $files;
@@ -93,7 +93,7 @@ function XTemplate ($file,$tpldir="",$fi
   assign a variable
 */
 
-function assign ($name,$val="") {
+public function assign ($name,$val="") {
   if (gettype($name)=="array")
     foreach ($name as $k=>$v)
       $this->VARS[$k]=$v;
@@ -106,7 +106,7 @@ function assign ($name,$val="") {
   assign a file variable
 */
 
-function assign_file ($name,$val="") {
+public function assign_file ($name,$val="") {
   if (gettype($name)=="array")
     foreach ($name as $k=>$v)
       $this->assign_file_($k,$v);
@@ -114,7 +114,7 @@ function assign_file ($name,$val="") {
     $this->assign_file_($name,$val);
 }
 
-function assign_file_ ($name,$val) {
+public function assign_file_ ($name,$val) {
   if (isset($this->filevar_parent[$name])) {
     if ($val!="") {
       $val=$this->r_getfile($val);
@@ -140,7 +140,7 @@ function assign_file_ ($name,$val) {
   parse a block
 */
 
-function parse ($bname) {
+public function parse ($bname) {
 
   if (isset($this->preparsed_blocks[$bname])) {
     $copy=$this->preparsed_blocks[$bname];
@@ -200,7 +200,7 @@ function parse ($bname) {
   returns the parsed text for a block, including all sub-blocks.
 */
 
-function rparse($bname) {
+public function rparse($bname) {
   if (!empty($this->sub_blocks[$bname])) {
     reset($this->sub_blocks[$bname]);
     foreach ($this->sub_blocks[$bname] as $k=>$v)
@@ -215,7 +215,7 @@ function rparse($bname) {
   inserts a loop ( call assign & parse )
 */
 
-function insert_loop($bname,$var,$value="") {
+public function insert_loop($bname,$var,$value="") {
   $this->assign($var,$value);
   $this->parse($bname);
 }
@@ -225,7 +225,7 @@ function insert_loop($bname,$var,$value=
   parses a block for every set of data in the values array
 */
 
-function array_loop($bname, $var, &$values)
+public function array_loop($bname, $var, &$values)
 {
   if (gettype($values)=="array")
   {
@@ -242,7 +242,7 @@ function array_loop($bname, $var, &$valu
   returns the parsed text for a block
 */
 
-function text($bname) {
+public function text($bname) {
   return $this->parsed_blocks[isset($bname) ? $bname :$this->mainblock];
 }
 
@@ -251,7 +251,7 @@ function text($bname) {
   prints the parsed text
 */
 
-function out ($bname) {
+public function out ($bname) {
   $length=strlen($this->text($bname));
   header("Content-Length: ".$length);
   echo $this->text($bname);
@@ -262,7 +262,7 @@ function out ($bname) {
   resets the parsed text
 */
 
-function reset ($bname) {
+public function reset ($bname) {
   $this->parsed_blocks[$bname]="";
 }
 
@@ -271,7 +271,7 @@ function reset ($bname) {
   returns true if block was parsed, false if not
 */
 
-function parsed ($bname) {
+public function parsed ($bname) {
   return (!empty($this->parsed_blocks[$bname]));
 }
 
@@ -280,7 +280,7 @@ function parsed ($bname) {
   sets the string to replace in case the var was not assigned
 */
 
-function SetNullString($str,$varname="") {
+public function SetNullString($str,$varname="") {
   $this->NULL_STRING[$varname]=$str;
 }
 
@@ -289,7 +289,7 @@ function SetNullString($str,$varname="")
   sets the string to replace in case the block was not parsed
 */
 
-function SetNullBlock($str,$bname="") {
+public function SetNullBlock($str,$bname="") {
   $this->NULL_BLOCK[$bname]=$str;
 }
 
@@ -300,7 +300,7 @@ function SetNullBlock($str,$bname="") {
   (for multiple level blocks)
 */
 
-function set_autoreset() {
+public function set_autoreset() {
   $this->AUTORESET=1;
 }
 
@@ -311,7 +311,7 @@ function set_autoreset() {
   (for multiple level blocks)
 */
 
-function clear_autoreset() {
+public function clear_autoreset() {
   $this->AUTORESET=0;
 }
 
@@ -320,7 +320,7 @@ function clear_autoreset() {
   scans global variables
 */
 
-function scan_globals() {
+public function scan_globals() {
   reset($GLOBALS);
   foreach ($GLOBALS as $k=>$v)
     $GLOB[$k]=$v;
@@ -347,7 +347,7 @@ function scan_globals() {
 */
 
 
-function maketree($con,$parentblock="") {
+public function maketree($con,$parentblock="") {
   $blocks=array();
   $con2=explode($this->block_start_delim,$con);
   if (!empty($parentblock)) {
@@ -393,7 +393,7 @@ function maketree($con,$parentblock="") 
   store container block's name for file variables
 */
 
-function store_filevar_parents($blocks){
+public function store_filevar_parents($blocks){
   $parents=array();
   foreach ($blocks as $bname=>$con) {
     preg_match_all($this->filevar_delim,$con,$res);
@@ -408,12 +408,12 @@ function store_filevar_parents($blocks){
   sets and gets error
 */
 
-function get_error()  {
+public function get_error()  {
   return ($this->ERROR=="")?0:$this->ERROR;
 }
 
 
-function set_error($str)  {
+public function set_error($str)  {
   $this->ERROR="<strong>[XTemplate]</strong>&nbsp;<i>".$str."</i>";
   trigger_error($this->get_error());
 }
@@ -423,7 +423,7 @@ function set_error($str)  {
   returns the contents of a file
 */
 
-function getfile($file) {
+public function getfile($file) {
   if (!isset($file)) {
     $this->set_error("!isset file name!");
     return "";
@@ -465,7 +465,7 @@ function getfile($file) {
 */
 
 
-function r_getfile($file) {
+public function r_getfile($file) {
   $text=$this->getfile($file);
   while (preg_match($this->file_delim,$text,$res)) {
     $text2=$this->getfile($res[1]);
