Index: blogs/inc/_core/_class4.funcs.php
===================================================================
RCS file: /cvsroot/evocms/b2evolution/blogs/inc/_core/_class4.funcs.php,v
retrieving revision 1.4
diff -u -r1.4 _class4.funcs.php
--- blogs/inc/_core/_class4.funcs.php	6 Dec 2007 20:04:34 -0000	1.4
+++ blogs/inc/_core/_class4.funcs.php	8 Dec 2007 03:52:36 -0000
@@ -54,92 +54,98 @@
 
 /**
  * @todo fp> split into 1 function per case. (typed @return values)
+ * @todo dh> using globals "pollutes" the global namespace. Use some "static" cache?! -
+ *           we seem to use the return value anyway always to assign it to a var in
+ *           the current scope ($FooCache = get_Cache("fooCache").
+ *
+ * NOTE: Using $GLOBALS[$foo] instead of "global $$foo", because the latter is buggy
+ *       when assigning/returning by reference - at least in some PHP versions under
+ *       some circumstances.
  *
  * @return DataObjectCache
  */
 function & get_Cache( $objectName )
 {
 	global $Plugins;
-	global $$objectName;
 
-	if( isset( $$objectName ) )
+	if( isset( $GLOBALS[$objectName] ) )
 	{	// Cache already exists:
-		return $$objectName;
+		return $GLOBALS[$objectName];
 	}
 
 	switch( $objectName )
 	{
 		case 'BlogCache':
 			load_class( 'collections/model/_blogcache.class.php' );
-			$BlogCache = new BlogCache(); // COPY (FUNC)
-			return $BlogCache;
+			$GLOBALS['BlogCache'] = new BlogCache(); // COPY (FUNC)
+			return $GLOBALS['BlogCache'];
 
 		case 'ChapterCache':
 			load_class( 'chapters/model/_chaptercache.class.php' );
-			$ChapterCache = new ChapterCache(); // COPY (FUNC)
-			return $ChapterCache;
+			$GLOBALS['ChapterCache'] = new ChapterCache(); // COPY (FUNC)
+			return $GLOBALS['ChapterCache'];
 
 		case 'FileCache':
 			load_class( 'files/model/_filecache.class.php' );
-			$FileCache = new FileCache(); // COPY (FUNC)
-			return $FileCache;
+			$GLOBALS['FileCache'] = new FileCache(); // COPY (FUNC)
+			return $GLOBALS['FileCache'];
 
 		case 'FileRootCache':
 			load_class( 'files/model/_filerootcache.class.php' );
 			$Plugins->get_object_from_cacheplugin_or_create( 'FileRootCache' );
-			return $FileRootCache;
+			return $GLOBALS['FileRootCache'];
 
 		case 'FiletypeCache':
 			load_class( 'files/model/_filetypecache.class.php' );
 			$Plugins->get_object_from_cacheplugin_or_create( 'FiletypeCache' );
-			return $FiletypeCache;
+			return $GLOBALS['FiletypeCache'];
 
 		case 'GroupCache':
 			$Plugins->get_object_from_cacheplugin_or_create( 'GroupCache', 'new DataObjectCache( \'Group\', true, \'T_groups\', \'grp_\', \'grp_ID\', \'grp_name\', \'\', T_(\'No group\') )' );
-			return $GroupCache;
+			return $GLOBALS['GroupCache'];
 
 		case 'ItemCacheLight';
-			$ItemCacheLight = new DataObjectCache( 'ItemLight', false, 'T_items__item', 'post_', 'post_ID' ); // COPY (FUNC)
-			return $ItemCacheLight;
+			$GLOBALS['ItemCacheLight'] = new DataObjectCache( 'ItemLight', false, 'T_items__item', 'post_', 'post_ID' ); // COPY (FUNC)
+			return $GLOBALS['ItemCacheLight'];
 
 		case 'ItemCache';
 			load_class( 'items/model/_itemcache.class.php' );
-			$ItemCache = new ItemCache(); // COPY (FUNC)
-			return $ItemCache;
+			$GLOBALS['ItemCache'] = new ItemCache(); // COPY (FUNC)
+			return $GLOBALS['ItemCache'];
 
 		case 'ItemStatusCache':
 			$Plugins->get_object_from_cacheplugin_or_create( 'ItemStatusCache', 'new GenericCache( \'GenericElement\', true, \'T_items__status\', \'pst_\', \'pst_ID\', NULL, \'\', T_(\'No status\') )' );
-			return $ItemStatusCache;
+			return $GLOBALS['ItemStatusCache'];
 
 		case 'ItemTypeCache':
 			load_class( 'items/model/_itemtypecache.class.php' );
 			$Plugins->get_object_from_cacheplugin_or_create( 'ItemTypeCache', 'new ItemTypeCache( \'ptyp_\', \'ptyp_ID\' )' );
-			return $ItemTypeCache;
+			return $GLOBALS['ItemTypeCache'];
 
 		case 'LinkCache':
 			load_class( 'items/model/_linkcache.class.php' );
-			$LinkCache = new LinkCache(); // COPY (FUNC)
-			return $LinkCache;
+			$GLOBALS['LinkCache'] = new LinkCache(); // COPY (FUNC)
+			return $GLOBALS['LinkCache'];
 
 		case 'Plugins_admin':
 			load_class('plugins/model/_plugins_admin.class.php');
-			$Plugins_admin = new Plugins_admin(); // COPY (FUNC)
-			return $Plugins_admin;
+			$GLOBALS['Plugins_admin'] = new Plugins_admin(); // COPY (FUNC)
+			return $GLOBALS['Plugins_admin'];
 
 		case 'SkinCache':
 			load_class( 'skins/model/_skincache.class.php' );
-			$SkinCache = new SkinCache(); // COPY (FUNC)
-			return $SkinCache;
+			$GLOBALS['SkinCache'] = new SkinCache(); // COPY (FUNC)
+			return $GLOBALS['SkinCache'];
 
 		case 'UserCache':
 			load_class( 'users/model/_usercache.class.php' );
-			$UserCache = new UserCache(); // COPY (FUNC)
-			return $UserCache;
+			$GLOBALS['UserCache'] = new UserCache(); // COPY (FUNC)
+			return $GLOBALS['UserCache'];
 
 		case 'WidgetCache':
 			load_class( 'widgets/model/_widgetcache.class.php' );
-			$WidgetCache = new WidgetCache(); // COPY (FUNC)
-			return $WidgetCache;
+			$GLOBALS['WidgetCache'] = new WidgetCache(); // COPY (FUNC)
+			return $GLOBALS['WidgetCache'];
 
 		default:
 			debug_die( 'getCache(): Unknown Cache type:'.$objectName );
