MyBB Community Forums

Full Version: [F] Infinite recursion in  function.php (editing options, themes)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is continuation of:
http://community.mybboard.net/showthread.php?tid=12828
because problem still exists.

MyBB 1.2.2, PHP 5.2.0 (with Suhosin patch)
Themes:
MyBB Master Style 	 
      Niebieski (31 Users) 	 
            Niebieski - małe litery (3 Users) 	 
      PC Format (15 Users) (Default) 	 
            PC Format - małe litery (1 Users)

User goes to User CP->Edit options and:
[Mon Dec  4 12:19:51 2006] [error] PHP Fatal error:  Allowed memory size of 25165824 bytes exhausted (tried to allocate 852195 bytes) in forum/inc/functions.php on line 2726
Errors come from infinite recursion.

Line 2726 is:
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
in function build_theme_select:
				// Show theme if allowed, or if override is on
				if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
				{
					if($theme['tid'] == $selected)
					{
						$sel = " selected=\"selected\"";
					}
					if($theme['pid'] != 0)
					{
						$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
						$depthit = $depth."--";
					}
					if(array_key_exists($theme['tid'], $tcache))
					{
						build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
					}
				}

To quick-solve this issue I have just commented that line Smile.
Try this file:
This bug has been fixed in the latest code.

Please note the latest code is not live on the site or for download. An update will be released which contains this fix.
Works fine, thanks.

P.S. Patch would be more usefull since my functions.php is heavily modified Smile.
Changes from original functions.php (from MyBB 1.2.2): [attachment=4895]
Just replace the function build_theme_select with the new one in my attached file.
This fixed our problem located here: http://community.mybboard.net/showthread.php?tid=13824
What was the point of that o.o
Tikitiki Wrote:What was the point of that o.o

hi tikitiki.
i am using the bluefish1.2.1 theme. could you suggest what are the changes has to be done not getting the internal server error on registration, and usercp edit options.
i am attaching the functions.php of the theme and class_templates.php.
sif, read the thread....
[/code]
Quote:sif, read the thread....
when i down loaded the file it shown me  like this . it is
--- mybb-122/inc/functions.php	2006-12-01 03:40:40.000000000 +0100
+++ from_mybb_123-functions.php	2006-12-07 11:01:13.000000000 +0100
@@ -6,7 +6,7 @@
  * Website: http://www.mybboard.com
  * License: http://www.mybboard.com/eula.html
  *
- * $Id: functions.php 2459 2006-11-29 09:09:55Z chris $
+ * $Id: functions.php 2475 2006-12-01 04:58:21Z Tikitiki $
  */
 
 /**
@@ -2612,27 +2612,27 @@
  */
 function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
 {
-	global $db, $themeselect, $tcache, $lang, $mybb;
+	global $db, $themeselect, $tcache, $lang, $mybb, $limit;
+	
 	if($tid == 0)
 	{
 		$themeselect = "<select name=\"$name\">";
 		$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
 		$themeselect .= "<option value=\"0\">-----------</option>\n";
+		$tid = 1;
 	}
+	
 	if(!is_array($tcache))
 	{
-		$query = $db->query("
-			SELECT name, pid, tid, allowedgroups
-			FROM ".TABLE_PREFIX."themes
-			WHERE pid != 0
-			ORDER BY pid, name
-		");
+		$query = $db->simple_select(TABLE_PREFIX."themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));
+		
 		while($theme = $db->fetch_array($query))
 		{
-			$tcache[$theme['pid']][] = $theme;
+			$tcache[$theme['pid']][$theme['tid']] = $theme;
 		}
 	}
-	if(is_array($tcache))
+	
+	if(is_array($tcache[$tid]))
 	{
 		// Figure out what groups this user is in
 		if($mybb->user['additionalgroups'])
@@ -2641,9 +2641,7 @@
 		}
 		$in_groups[] = $mybb->user['usergroup'];
 
-		foreach($tcache as $misc)
-		{
-			foreach($misc as $theme)
+		foreach($tcache[$tid] as $theme)
 			{
 				$sel = "";
 				// Make theme allowed groups into array
@@ -2661,8 +2659,9 @@
 						}
 					}
 				}
+			
 				// Show theme if allowed, or if override is on
-				if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
+			if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
 				{
 					if($theme['tid'] == $selected)
 					{
@@ -2680,7 +2681,7 @@
 				}
 			}
 		}
-	}
+	
 	if(!$tid)
 	{
 		$themeselect .= "</select>";

is this the file i have to upload or there is any change i belived that there is missing closing tag of if and many +  symbols, an @@ -2680,7 +2681,7 @@, i think the file is get corrupted while downloading. i just commented the line of bulid theme so it is working now  any problem further will come if we not uploaded above  file
[/quote]

friend ,
i am using 1.2.1 and using blue fish theme which is using different funcions.php . i will upgrade it to 1.22 soon. when i upgraded to 1.2.1 to 1.22 i get errors on my local system. so for time being i am stick to 1.2.1, i will upgrade soon . so could you suggest find which line and what code has to be changed to particular file .
thanks for reading]
Pages: 1 2