ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: ahrasis on February 17, 2016, 05:00:20 am

Title: Undefined Error When Search By Guest
Post by: ahrasis on February 17, 2016, 05:00:20 am
I got an undefined error when forum is searched by a guest but not really sure what causing it. Any help will be appreciated.
Code: [Select]
Guest
15.02.16 | 11:02:03 PM
162.216.19.183 
1442be50399fd9e0399b000867799598
Type of error: Undefined
8: Undefined offset: 1
URL http://192.168.0.111/index.php?amp;action=search
File: /var/www/clients/client3/web34/web/themes/default/GenericBoards.template.php
Line: 55


Code: [Select]
39:			// The +1 here are to take in consideration category headers
40: // that visuallt account for about one additional board
41: $group_totals[$current_group] += $boards_count + 1;
42: $current_streak += $boards_count + 1;
43:
44: // Start a new streak
45: if ($current_streak > $optimal_boards && $current_group < ($num_groups - 1))
46: {
47: $current_streak = 0;
48: $current_group++;
49: $groups[$current_group] = array();
50: $group_totals[$current_group] = 0;
51: }
52: }
53:
54: // The current difference of elements from left and right
==>55: $diff_current = $group_totals[0] - $group_totals[1];
56:
57: // If we have less on the right, let's try picking one from the left
58: if ($diff_current > 0)
59: {
60: $last_group = array_pop($groups[0]);
61: // Same as above, +1 for cat header
62: $diff_alternate = $diff_current - 2 * ($categories[$last_group] + 1);
63:
64: if (abs($diff_alternate) < $diff_current)
65: array_unshift($groups[1], $last_group);
66: else
67: $groups[0][] = $last_group;
68: }
69: // If we have less on the left, let's try picking one from the right
70: elseif ($diff_current < 0)
71: {
72: $first_group = array_shift($groups[1]);
73: // Same as above, +1 for cat header
74: $diff_alternate = $diff_current + 2 * ($categories[$first_group] + 1);
Title: Re: Undefined Error When Search By Guest
Post by: emanuele on February 17, 2016, 07:32:51 am
Are you on a localhost?
Title: Re: Undefined Error When Search By Guest
Post by: ahrasis on February 18, 2016, 07:13:04 am
Not really. This site is a live site but I could access it via local ip address as well. That is by using subforum addon. By the guest ip is definitely not local.
Title: Re: Undefined Error When Search By Guest
Post by: emanuele on February 18, 2016, 08:33:51 am
Ohh now I see.
Could it be you have only one or two visible boards?
I think changing this:
Code: [Select]
$group_totals = array(0 => 0);
to:
Code: [Select]
$group_totals = array(0 => 0, 1 => 0);
will do (at least for the time being).
Title: Re: Undefined Error When Search By Guest
Post by: ahrasis on February 18, 2016, 10:00:38 am
I tested the code and the error is now gone for searches in forum(s) without any board but just link(s). Thank you.
Title: Re: Undefined Error When Search By Guest
Post by: Flavio93Zena on February 18, 2016, 10:17:14 am
Should this be tracked? @emanuele
Title: Re: Undefined Error When Search By Guest
Post by: emanuele on February 18, 2016, 10:32:37 am
Quote from: ahrasis – I tested the code and the error is now gone for searches in forum(s) without any board but just link(s). Thank you.
So there is no "real" boards, just redirects?
Title: Re: Undefined Error When Search By Guest
Post by: ahrasis on February 19, 2016, 01:45:26 am
Yup. There is no board for one of the sub forums, just redirect(s).
Title: Re: Undefined Error When Search By Guest
Post by: emanuele on February 19, 2016, 02:05:25 am
Makes sense, I never accounted for this situation.
Yep, to be fixed in one of the next revisions, I'll move to bug reports.
Title: Re: Undefined Error When Search By Guest
Post by: emanuele on March 23, 2016, 05:45:45 pm
Can't find the commit, but it's fixed.