--- template.php.orig	2009-10-02 22:22:37.000000000 +0200
+++ template.php	2009-10-02 22:32:09.000000000 +0200
@@ -183,7 +183,7 @@ function phptemplate_preprocess_page(&$v
   }
   $body_classes[] = (module_exists('panels_page') && (panels_page_get_current())) ? 'panels' : '';        // Page is Panels page
   $body_classes[] = 'layout-'. (($vars['sidebar_first']) ? 'first-main' : 'main') . (($vars['sidebar_last']) ? '-last' : '');  // Page sidebars are active
-  if ($vars['preface_first'] || $vars['preface_middle'] || $vars['preface_last']) {                       // Preface regions are active
+  if ((isset($vars['preface_first']) && $vars['preface_first']) || (isset($vars['preface_middle']) && $vars['preface_middle']) || (isset($vars['preface_last']) &&$vars['preface_last'])) {                       // Preface regions are active
     $preface_regions = 'preface';
     $preface_regions .= ($vars['preface_first']) ? '-first' : '';
     $preface_regions .= ($vars['preface_middle']) ? '-middle' : '';
@@ -208,7 +208,7 @@ function phptemplate_preprocess_page(&$v
   foreach ($region_list as $sub_region_key => $sub_region_list) {
     $active_regions = array();
     foreach ($sub_region_list as $region_item) {
-      if ($vars[$region_item]) {
+      if (isset($vars[$region_item]) && $vars[$region_item]) {
         $active_regions[] = $region_item;
       }
     }
@@ -294,7 +294,7 @@ function phptemplate_preprocess_page(&$v
 
 function phptemplate_preprocess_block(&$vars) {
   // Add regions with rounded blocks (e.g., sidebar_first, sidebar_last) to $rounded_regions array
-  $rounded_regions = array(sidebar_first);
+  $rounded_regions = array('sidebar_first');
   $vars['rounded_block'] = (in_array($vars['block']->region, $rounded_regions)) ? TRUE : FALSE;
 }
 
@@ -471,7 +471,7 @@ function phptemplate_preprocess_comment(
   static $comment_odd = TRUE;                                                                             // Comment is odd or even
   $comment_classes[] = $comment_odd ? 'odd' : 'even';
   $comment_odd = !$comment_odd;
-  $comment_classes[] = ($vars['comment']->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : '';  // Comment is unpublished
+  $comment_classes[] = (isset($vars['comment']->status) && $vars['comment']->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : '';  // Comment is unpublished
   $comment_classes[] = ($vars['comment']->new) ? 'comment-new' : '';                                      // Comment is new
   $comment_classes[] = ($vars['comment']->uid == 0) ? 'comment-by-anon' : '';                             // Comment is by anonymous user
   $comment_classes[] = ($user->uid && $vars['comment']->uid == $user->uid) ? 'comment-mine' : '';         // Comment is by current user
@@ -666,9 +666,10 @@ function phptemplate_button($element) {
   }
 
   // Wrap non-hidden input elements with span tags for button graphics
-  if (stristr($element['#attributes']['style'], 'display: none;') || 
+  if (isset($element['#attributes']['style']) &&
+      (stristr($element['#attributes']['style'], 'display: none;') ||
       stristr($element['#attributes']['class'], 'fivestar-submit')  || 
-      is_array($element['#upload_validators'])) {
+      is_array($element['#upload_validators']))) {
     return '<input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ')  .'id="'. $element['#id'].'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
   }
   else {
