Index: /var/www/wp-dev/trunk/wp-includes/post-template.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/post-template.php (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/post-template.php (working copy)
@@ -32,11 +32,13 @@
        $post = &get_post($id);
 
        $title = $post->post_title;
-       if ( !empty($post->post_password) )
+       if ( !empty($post->post_password) ) {
               $title = sprintf(__('Protected: %s'), $title);
-       else if ( 'private' == $post->post_status )
-              $title = sprintf(__('Private: %s'), $title);
-
+       } else if (isset($post->post_status)) {
+              if ( 'private' == $post->post_status ) {
+                     $title = sprintf(__('Private: %s'), $title);
+              }
+       }
        return $title;
 }
 
Index: /var/www/wp-dev/trunk/wp-includes/bookmark.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/bookmark.php      (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/bookmark.php      (working copy)
@@ -97,6 +97,7 @@
               $recently_updated_test = '';
        }
 
+       $get_updated = '';
        if ($show_updated) {
               $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
        }
Index: /var/www/wp-dev/trunk/wp-includes/query.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/query.php (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/query.php (working copy)
@@ -347,23 +347,46 @@
                      return;
               }
 
-              if ('404' == $qv['error']) {
-                     $this->is_404 = true;
-                     if ( !empty($query) ) {
-                            do_action_ref_array('parse_query', array(&$this));
+              if (isset($qv['error'])) {
+                     if ('404' == $qv['error']) {
+                            $this->is_404 = true;
+                            if ( !empty($query) ) {
+                                   do_action_ref_array('parse_query', array(&$this));
+                            }
+                            return;
                      }
-                     return;
               }
 
-              $qv['m'] =  (int) $qv['m'];
-              $qv['p'] =  (int) $qv['p'];
+              if (isset($qv['m'])) {
+                     $qv['m'] =  (int) $qv['m'];
+              } else {
+                     $qv['m'] = 0;
+              }
+              if (isset($qv['p'])) {
+                     $qv['p'] =  (int) $qv['p'];
+              } else {
+                     $qv['p'] = 0;
+              }
 
               // Compat.  Map subpost to attachment.
-              if ( '' != $qv['subpost'] )
-                     $qv['attachment'] = $qv['subpost'];
-              if ( '' != $qv['subpost_id'] )
-                     $qv['attachment_id'] = $qv['subpost_id'];
+              if (isset($qv['subpost'])) {
+                     if ( '' != $qv['subpost'] )
+                            $qv['attachment'] = $qv['subpost'];
+              }
+              if (isset($qv['subpost_id'])) {
+                     if ( '' != $qv['subpost_id'] )
+                            $qv['attachment_id'] = $qv['subpost_id'];
+              }
 
+              // Fixes a lot warnings
+              if (!isset($qv['attachment_id'])) $qv['attachment_id'] = '';
+              if (!isset($qv['attachment']))    $qv['attachment']    = '';
+              if (!isset($qv['name']))          $qv['name']          = '';
+              if (!isset($qv['hour']))          $qv['hour']          = '';
+              if (!isset($qv['static']))        $qv['static']        = '';
+              if (!isset($qv['pagename']))      $qv['pagename']      = '';
+              if (!isset($qv['page_id']))       $qv['page_id']       = '';
+
               if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
                      $this->is_single = true;
                      $this->is_attachment = true;
@@ -381,8 +404,19 @@
               } elseif (!empty($qv['s'])) {
                      $this->is_search = true;
               } else {
-              // Look for archive queries.  Dates, categories, authors.
+                     // Look for archive queries.  Dates, categories, authors.
 
+                     // Fixes a lot warnings
+                     if (!isset($qv['second']))         $qv['second']         = '';
+                     if (!isset($qv['minute']))         $qv['minute']         = '';
+                     if (!isset($qv['day']))            $qv['day']            = '';
+                     if (!isset($qv['monthnum']))       $qv['monthnum']       = '';
+                     if (!isset($qv['year']))           $qv['year']           = '';
+                     if (!isset($qv['w']))              $qv['w']              = '';
+                     if (!isset($qv['category_name']))  $qv['category_name']  = '';
+                     if (!isset($qv['author_name']))    $qv['author_name']    = '';
+                     if (!isset($qv['show_post_type'])) $qv['show_post_type'] = '';
+
                      if ( (int) $qv['second']) {
                             $this->is_time = true;
                             $this->is_date = true;
@@ -465,6 +499,13 @@
                      }
               }
 
+              // Fixes some warnings
+              if (!isset($qv['feed']))           $qv['feed']           = '';
+              if (!isset($qv['tb']))             $qv['tb']             = '';
+              if (!isset($qv['paged']))          $qv['paged']          = '';
+              if (!isset($qv['comments_popup'])) $qv['comments_popup'] = '';
+              if (!isset($qv['preview']))        $qv['preview']        = '';
+
               if ('' != $qv['feed']) {
                      $this->is_feed = true;
               }
@@ -587,6 +628,27 @@
               $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
               $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
 
+              // Fixes a lot warnings
+              if (!isset($q['m']))              $q['m']              = '';
+              if (!isset($q['w']))              $q['w']              = '';
+              if (!isset($q['p']))              $q['p']              = '';
+              if (!isset($q['hour']))           $q['hour']           = '';
+              if (!isset($q['minute']))         $q['minute']         = '';
+              if (!isset($q['second']))         $q['second']         = '';
+              if (!isset($q['year']))           $q['year']           = '';
+              if (!isset($q['monthnum']))       $q['monthnum']       = '';
+              if (!isset($q['day']))            $q['day']            = '';
+              if (!isset($q['subpost']))        $q['subpost']        = '';
+              if (!isset($q['subpost_id']))     $q['subpost_id']     = '';
+              if (!isset($q['name']))           $q['name']           = '';
+              if (!isset($q['pagename']))       $q['pagename']       = '';
+              if (!isset($q['attachment']))     $q['attachment']     = '';
+              if (!isset($q['comments_popup'])) $q['comments_popup'] = '';
+              if (!isset($q['attachment_id']))  $q['attachment_id']  = '';
+              if (!isset($q['page_id']))        $q['page_id']        = '';
+              if (!isset($q['category_name']))  $q['category_name']  = '';
+              if (!isset($q['author_name']))    $q['author_name']    = '';
+
               // If a month is specified in the querystring, load that month
               if ( (int) $q['m'] ) {
                      $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
@@ -725,6 +787,9 @@
                      }
               }
 
+              // Fixes a warning
+              if (!isset($search)) $search = '';
+
               // Category stuff
 
               if ((empty($q['cat'])) || ($q['cat'] == '0') || 
@@ -903,12 +968,20 @@
 
               // Paging
               if (empty($q['nopaging']) && ! $this->is_single && ! $this->is_page) {
-                     $page = abs(intval($q['paged']));
-                     if (empty($page)) {
+                     // Fixes a warning
+                     if (!isset($q['paged'])) {
                             $page = 1;
+                     } else {
+                            $page = abs(intval($q['paged']));
+                            if (empty($page)) {
+                                   $page = 1;
+                            }
                      }
 
                      if (($q['what_to_show'] == 'posts')) {
+                            // Fixes a notice
+                            if (!isset($q['offset'])) $q['offset'] = '';
+
                             $q['offset'] = abs(intval($q['offset']));
                             if ( empty($q['offset']) ) {
                                    $pgstrt = '';
Index: /var/www/wp-dev/trunk/wp-includes/link-template.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/link-template.php (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/link-template.php (working copy)
@@ -235,7 +235,8 @@
 
 function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
        global $post, $comment;
-
+       if (!isset($post->post_type)) $post->post_type = '';
+       if (!isset($post->ID)) $post->ID = 0;
        if( $post->post_type == 'page' ){
               if ( ! current_user_can('edit_page', $post->ID) )
                      return;
Index: /var/www/wp-dev/trunk/wp-includes/wp-db.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/wp-db.php (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/wp-db.php (working copy)
@@ -215,7 +215,11 @@
                      $this->query($query);
 
               if ( $output == OBJECT ) {
-                     return $this->last_result[$y] ? $this->last_result[$y] : null;
+                     if (isset($this->last_result[$y])) {
+                            return $this->last_result[$y];
+                     } else {
+                            return null;
+                     }
               } elseif ( $output == ARRAY_A ) {
                      return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null;
               } elseif ( $output == ARRAY_N ) {
@@ -289,6 +293,25 @@
               }
        }
 
+       // ==================================================================
+       // Function to close the database connection (really simple one)
+       function close() {
+              if ($this->dbh !== false) {
+                     if (@mysql_close($this->dbh) === false) {
+                            // Something has failed
+                            die("Failed closing connection to database!");
+                     } else {
+                            // Remove the link resource
+                            unset($this->dbh);
+                     }
+              }
+       }
+
+       // Simple getter function
+       function getNumQueries() {
+              return $this->num_queries;
+       }
+
        function timer_start() {
               $mtime = microtime();
               $mtime = explode(' ', $mtime);
@@ -363,6 +386,12 @@
        }
 }
 
-if ( ! isset($wpdb) )
-       $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
-?>
\ No newline at end of file
+if ( ! isset($wpdb) ) {
+       if (defined('ENABLE_SQL_CACHE')) {
+              require_once(ABSPATH . WPINC . "/wp-db_cache.php");
+              $wpdb = new wpdb_cache(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
+       } else {
+              $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
+       }
+}
+?>
Index: /var/www/wp-dev/trunk/wp-includes/category.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/category.php      (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/category.php      (working copy)
@@ -119,7 +119,9 @@
        }
        reset ( $categories );
 
-       return apply_filters('get_categories', $categories, $r);
+       // Apply all filters
+       $category = apply_filters('get_categories', $categories, $r);
+       return $category;
 }
 
 // Retrieves category data given a category ID or category object.
Index: /var/www/wp-dev/trunk/wp-includes/general-template.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/general-template.php      (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/general-template.php      (working copy)
@@ -199,6 +199,8 @@
        $prefix = '';
        if ( isset($title) )
               $prefix = " $sep ";
+       else
+              $title = '';
 
        $title = $prefix . $title;
        $title = apply_filters('wp_title', $title, $sep);
Index: /var/www/wp-dev/trunk/wp-includes/capabilities.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/capabilities.php  (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/capabilities.php  (working copy)
@@ -354,7 +354,12 @@
                      $args = array_merge(array('edit_page', $user_id), $args);
                      return call_user_func_array('map_meta_cap', $args);    
               }
-              $post_author_data = get_userdata($post->post_author);
+              if (isset($post->post_author)) {
+                     $post_author_data = get_userdata($post->post_author);
+              } else {
+                     // Does this really fix the notice?
+                     return $caps;
+              }
               //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
               // If the user is the author...
               if ($user_id == $post_author_data->ID) {
Index: /var/www/wp-dev/trunk/wp-includes/wp-db_cache.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/wp-db_cache.php   (revision 0)
+++ /var/www/wp-dev/trunk/wp-includes/wp-db_cache.php   (revision 0)
@@ -0,0 +1,158 @@
+<?php
+
+// SQL query caching system
+// WARNING: This code has developer status and will (currently) not work!
+
+class wpdb_cache extends wpdb {
+       //***** Local variables *****
+       // The relative path for all cache files with trailing slash
+       var $cache_dir = "wp-content/cache/sql/";
+
+       // The array for all cache firectories we want to create
+       var $cache_dirs = array('a' => "arrays", 'o' => "objects", 's' => "single");
+
+       // Number of rows while the query
+       var $query_nums = 0;
+
+       // All cached tables
+       var $hashList = array();
+
+       // Tables which needs fetching from cache/database
+       var $waitingList = array();
+
+       // Current extracted tables from query string
+       var $currTables = array();
+
+       // Counter for all cache hits
+       var $cache_hits = 0;
+
+       // Here is the usage of all directories
+       //   arrays  - For caching simple arrays (indexed and asosiative; incl. multi-dimension arrays)
+       //   objects - For caching whole objects (e.g. from mysql_fetch_object() )
+       //   single  - For caching single data (one column or result of COUNT/SUM() )
+
+       // Cache initialization part
+       function wpdb_cache ($dbuser, $dbpassword, $dbname, $dbhost) {
+              // Make the cache dir absolute
+              $this->cache_dir = ABSPATH . $this->cache_dir;
+
+              // Make all paths absolute
+              foreach ($this->cache_dirs as $type=>$dir) {
+                     $this->cache_dirs[$type] = $this->cache_dir . $dir . "/";
+              }
+
+              // Check if the main directory does exist
+              if (!is_dir($this->cache_dir)) {
+                     // Try to create it
+                     @mkdir($this->cache_dir);
+                     @chmod($this->cache_dir, 0777);
+
+                     // Re-check it
+                     if (!is_dir($this->cache_dir)) {
+                            // Please create it on your own
+                            die("Cannot create SQL cache directory (default: wp-content/cache/sql/)! Please create and CHMOD it to 0777.");
+                     } else {
+                            // Create more directories...
+                            foreach ($this->cache_dirs as $dir) {
+                                   @mkdir($this->cache_dir. $dir);  @chmod($this->cache_dir . $dir , 0777);
+                            }
+
+                            // Create the missing .htaccess file
+                            $this->create_htaccess();
+                     }
+              } elseif (!file_exists($this->cache_dir . ".htaccess")) {
+                     // Create missing .htaccess file
+                     $this->create_htaccess();
+              }
+
+              // Initialize the database layer
+              parent::wpdb($dbuser, $dbpassword, $dbname, $dbhost);
+              // When you remove the line above the database will no longer be accessible
+              // and the sky turns pitch dark! ;-)
+       }
+
+       // private: create .htaccess files for securing the directories against direct calls
+       function create_htaccess() {
+              $checkDirs = $this->cache_dirs;
+              $checkDirs[] = $this->cache_dir;
+              foreach ($checkDirs as $dir) {
+                     $fp = @fopen($dir . ".htaccess", 'w') or die("SQL-CACHE: Cannot create .htaccess file in $dir.");
+                     fwrite($fp, "Deny from all\n");
+                     fclose($fp);
+              }
+       }
+
+       // Query the database or cache file
+       // returns number of entries
+       function query ($qstring) {
+              global $table_prefix;
+
+              // Initialize counter
+              $this->query_nums = 0;
+
+              // Create MD5 checksum of current query + WP_SECRET (we will later use this)
+              if (defined('WP_SECRET')) {
+                     // WP_SECRET adds some more security to it. :-)
+                     $this->currQueryHash = md5(WP_SECRET.":".$qstring);
+              } else {
+                     // Bad, when WP_SECRET is not defined!
+                     $this->currQueryHash = md5($qstring);
+              }
+
+              // Extract all tables from the string. The ?: is for "non-capturing subpatterns"
+              // Thanx to Hinrich Sager <hinrich [DOT] sager [AT] web [DOT] de> from the PHPUG-Hamburg
+              // to help me here. :-)
+              preg_match_all(sprintf('/(?:FROM|JOIN|,)[\s](%s[\d\w]+)/i', $table_prefix), $qstring, $this->currTables);
+
+              // Take the 2nd array, so now we have all tables together :-)
+              $this->currTables = $this->currTables[1];
+
+              // Do we have a SELECT command where we can take the cache?
+              $test = trim(strtoupper($qstring));
+              if (substr($test, 0, 6) == "SELECT") {
+                     // A SELECT query was send. Check if every table is cached
+                     // We need $this->hashList for deleting cache files when UPDATE, INSERT et cetera is queried
+                     foreach ($this->currTables as $table) {
+                            if (!isset($this->hashList[$table])) {
+                                   // The table was not found in the hash list so we add it + the query
+                                   $this->hashList[$table] = array($this->currQueryHash);
+                            } elseif (!in_array($this->currQueryHash, $this->hashList[$table])) {
+                                   // The table was been added to the hash list before but not this query string
+                                   $this->hashList[$table][] = $this->currQueryHash;
+                            } else {
+                                   // Count the cache hit
+                                   $this->cache_hits++;
+                            }
+                     }
+              } else {
+                     // Check for existing cahes by analyzing the query string
+                     //die("OK");
+                     //$this->query_nums = $this->cache_flush_by_query($qstring);
+              }
+
+              // Dummy:
+              return parent::query($qstring);
+       }
+
+       // Shuts the caching system down
+       function close() {
+              // Shall we output debugging info? (useful for development)
+              if (defined('DEBUG_SQL_CACHE')) {
+                     // Output cache debug informations
+                     $this->cache_debug_output();
+              }
+
+              // Close the database connection
+              parent::close();
+       }
+
+       // Debug informations for the cache
+       function cache_debug_output() {
+              echo "Cache hits: <strong>".$this->cache_hits."</strong><br />
+Database queries: <strong>".wpdb::getNumQueries()."</strong><br />
+<br />
+<pre>".print_r($this->hashList, true)."</pre>";
+       }
+}
+
+?>
Index: /var/www/wp-dev/trunk/wp-includes/classes.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/classes.php       (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/classes.php       (working copy)
@@ -401,7 +401,11 @@
        
                             continue;      
                      }
-       
+
+                     // Fixes two notices
+                     if (!isset($previous_element->$parent_field)) $previous_element->$parent_field = 0;
+                     if (!isset($previous_element->$id_field))     $previous_element->$id_field     = 0;
+
                      // Walk the tree.
                      if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
                             // Previous element is my parent. Descend a level.
@@ -446,6 +450,8 @@
        
                      // Start the element.
                      if ( !$to_depth || ($depth <= $to_depth) ) {
+                            // Fixes a notice
+                            if (!isset($element->$id_field)) $element->$id_field = 0;
                             if ( $element->$id_field != 0 ) {
                                    $cb_args = array_merge( array($output, $element, $depth - 1), $args);
                                    $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
Index: /var/www/wp-dev/trunk/wp-includes/rss.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/rss.php   (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/rss.php   (working copy)
@@ -376,6 +376,9 @@
 require_once( dirname(__FILE__) . '/class-snoopy.php');
 
 function fetch_rss ($url) {
+       // Check if disabled
+       if (defined('__DISABLE_RSS')) return false;
+
        // initialize constants
        init();
 
Index: /var/www/wp-dev/trunk/wp-includes/script-loader.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/script-loader.php (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/script-loader.php (working copy)
@@ -92,6 +92,7 @@
                      if ( isset($handle[1]) )
                             $this->args[$handle[0]] = $handle[1];
                      $handle = $handle[0];
+                     if (!isset($return[$handle])) $return[$handle] = true;
                      if ( is_null($return[$handle]) ) // Prime the return array with $handles
                             $return[$handle] = true;
                      if ( $this->scripts[$handle]->deps ) {
Index: /var/www/wp-dev/trunk/wp-includes/bookmark-template.php
===================================================================
--- /var/www/wp-dev/trunk/wp-includes/bookmark-template.php     (revision 4201)
+++ /var/www/wp-dev/trunk/wp-includes/bookmark-template.php     (working copy)
@@ -251,6 +251,7 @@
        $r = array_merge($defaults, $r);
        extract($r);
 
+       $output = '';
        foreach ( (array) $bookmarks as $bookmark ) {
               if ( !isset($bookmark->recently_updated) )
                      $bookmark->recently_updated = false;
Property changes on: /var/www/wp-dev/trunk/wp-content
___________________________________________________________________
Name: svn:ignore
   + cache

Index: /var/www/wp-dev/trunk/wp-content/element-cache.php
===================================================================
--- /var/www/wp-dev/trunk/wp-content/element-cache.php  (revision 0)
+++ /var/www/wp-dev/trunk/wp-content/element-cache.php  (revision 0)
@@ -0,0 +1,153 @@
+<?php
+// Caches small elements from many core functions
+class Element_Cache {
+       // The big cache array for all elements
+       var $elementCache = array();
+
+       // Current loaded element
+       var $currentElement = false;
+       var $currentGroup = false;
+
+       // The cache directory
+       var $cache_dir = "wp-content/cache/element/";
+
+       // Flush these caches to disc
+       var $flushThis = array();
+
+       // Do some (maybe) initialization work
+       // public
+       function Element_Cache($newCacheDir = "") {
+              // Is a new relative paht name set?
+              if (!empty($newCacheDir)) $this->cache_dir = $newCacheDir;
+
+              // Generate full-qualified path name
+              $this->cache_dir = sprintf("%s%s", ABSPATH, $this->cache_dir);
+
+              // Is our working directory up?
+              if (!is_dir($this->cache_dir)) {
+                     // Try to create it
+                     @mkdir($this->cache_dir);
+                     @chmod($this->cache_dir, 0777);
+
+                     // Re-check it
+                     if (!is_dir($this->cache_dir)) {
+                            // FATAL ERROR!
+                            die("ELEMENT-CACHE: Cannot create my directory ".$this->cache_dir.". Please do so and CHMOD it to 0777.");
+                     } else {
+                            // Create .htaccess file
+                            $fp = @fopen($this->cache_dir . ".htaccess", 'w') or die("Cannot create .htaccess file!");
+                            fwrite($fp, "Deny from all\n");
+                            fclose($fp);
+                     }
+              }
+       }
+
+       // Check if element is in the array
+       // private
+       function isHashInArray ($elgroup, $hash) {
+              if (isset($this->elementCache[$elgroup][$hash])) {
+                     // Element is already cached!
+                     $this->currentElement = $this->elementCache[$elgroup][$hash];
+                     $this->currentGroup   = $elgroup;
+                     $this->currentHash    = $hash;
+                     return true;
+              }
+              return false;
+       }
+
+       // Generate a hash useable for all elements
+       // private
+       function hash($element) {
+              // Generate hash
+              return md5(WP_SECRET.$element);
+       }
+
+       // Check if element is cached or not and gets the requested element
+       // public
+       function isElementCached ($elgroup, $element) {
+              // Generate hash
+              $this->currentHash = $this->hash($element);
+
+              // Do we have it in cache?
+              $status = $this->isHashInArray($elgroup, $this->currentHash);
+              if (!$status) {
+                     // Generate filename
+                     $name = sprintf("%s%s.cache", $this->cache_dir, $elgroup);
+                     if (file_exists($name)) {
+                            // Load the cache file
+                            $this->elementCache[$elgroup] = unserialize(file_get_contents($name));
+
+                            // Check again...
+                            $status = $this->isHashInArray($elgroup, $this->currentHash);
+                     }
+              }
+
+              // If file exists or not makes no difference the element must be inside
+              return $status;
+       }
+
+       // Add an element to the cache (does not write it to disc!)
+       // public
+       function addElement($elgroup, $element, $data) {
+              // Is the element already added?
+              if (isset($this->elementCache[$elgroup][$this->currentHash])) return;
+
+              // Do we need to flush this group to disc?
+              if (!isset($this->flushThis[$elgroup])) $this->flushThis[$elgroup] = 1;
+
+              // Add it to the memory cache
+              $this->elementCache[$elgroup][$this->currentHash] = $data;
+       }
+
+       // Get the current loaded element
+       // public
+       function getCurrentElement() {
+              // Do we have it?
+              if (!$this->currentElement) return false; // Not set!
+
+              // Okay, look it up in our array...
+              $element = false;
+              if (isset($this->elementCache[$this->currentGroup][$this->currentHash])) {
+                     // Load the element
+                     $element = $this->elementCache[$this->currentGroup][$this->currentHash];
+
+                     // And remove the current element
+                     $this->currentElement = false;
+                     $this->currentHash = false;
+              }
+
+              // Return fetched element
+              return $element;
+       }
+
+       // Flush all changed/new caches to disc
+       function flushCache() {
+              foreach ($this->flushThis as $cache=>$dummy) {
+                     // Serialize the cache
+                     $output = serialize($this->elementCache[$cache]);
+                     // Generate file name
+                     $cacheFile = sprintf("%s%s.cache", $this->cache_dir, $cache);
+                     // And put it out to the file
+                     file_put_contents($cacheFile, $output);
+              }
+       }
+}
+
+// The initializer function
+function element_cache_init() {
+       global $elCache;
+       $elCache = new Element_Cache();
+
+       // Shutdown function
+       register_shutdown_function('element_cache_shutdown');
+}
+
+// Shutdown function
+function element_cache_shutdown() {
+       global $elCache;
+       // Flush (maybe) added/changed caches
+       $elCache->flushCache();
+       // Do something more...
+}
+
+?>
Index: /var/www/wp-dev/trunk/wp-content/themes/default/functions.php
===================================================================
--- /var/www/wp-dev/trunk/wp-content/themes/default/functions.php       (revision 4201)
+++ /var/www/wp-dev/trunk/wp-content/themes/default/functions.php       (working copy)
@@ -73,6 +73,7 @@
 add_action('admin_menu', 'kubrick_add_theme_page'); 
  
 function kubrick_add_theme_page() { 
+       if (!isset($_GET['page'])) $_GET['page'] = "";
        if ( $_GET['page'] == basename(__FILE__) ) { 
               if ( 'save' == $_REQUEST['action'] ) { 
                      if ( isset($_REQUEST['njform']) ) { 
Index: /var/www/wp-dev/trunk/wp-settings.php
===================================================================
--- /var/www/wp-dev/trunk/wp-settings.php       (revision 4201)
+++ /var/www/wp-dev/trunk/wp-settings.php       (working copy)
@@ -74,7 +74,7 @@
 timer_start();
 
 // Change to E_ALL for development/debugging
-error_reporting(E_ALL ^ E_NOTICE);
+error_reporting(E_ALL);
 
 // For an advanced caching plugin to use, static because you would only want one
 if ( defined('WP_CACHE') )
@@ -109,11 +109,19 @@
 // To be removed in 2.2
 $tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = '';
 
-if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
+if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) {
        require (ABSPATH . 'wp-content/object-cache.php');
-else
+} else {
        require (ABSPATH . WPINC . '/cache.php');
+       // You have to define ENABLE_ELEMENT_CACHE in your wp-config.php to get the element cacher working:
+       // define('ENABLE_ELEMENT_CACHE', true);
+       if ( file_exists(ABSPATH . 'wp-content/element-cache.php') && defined('ENABLE_ELEMENT_CACHE') ) {
+              require (ABSPATH . 'wp-content/element-cache.php');
+              element_cache_init();
+       }
+}      
 
+// Initialize WordPress' cache
 wp_cache_init();
 
 require (ABSPATH . WPINC . '/functions.php');
@@ -239,6 +247,14 @@
 }
 register_shutdown_function('shutdown_action_hook');
 
+function shutdown_database_connection() {
+       global $wpdb;
+       $wpdb->close();
+}
+
+// Add a shutdown function for the database connection
+register_shutdown_function('shutdown_database_connection');
+
 // Everything is loaded and initialized.
 do_action('init');
 
