Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: live627 on June 29th, 2013, 09:43 AM

Title: Just emptied the boards table and got an error
Post by: live627 on June 29th, 2013, 09:43 AM

Notice: Undefined offset: 0 in I:\www\wedge\trunk\Sources\Subs-BoardIndex.php on line 476


The mod category still shows up just fine.

Will this happen to some crazy person other than me?
Title: Re: Just emptied the boards table and got an error
Post by: Arantor on June 29th, 2013, 06:02 PM
Did you truncate the table or empty it board by board?
Title: Re: Just emptied the boards table and got an error
Post by: live627 on June 29th, 2013, 07:51 PM
I truncated it and only it.
Title: Re: Just emptied the boards table and got an error
Post by: Arantor on June 29th, 2013, 08:31 PM
Ah, yes, I see the problem and it will affect anyone. If there's a situation where you're viewing the board index without any visible categories it'll throw the error. And if there's no visible boards, there's no visible categories.

Code: [Select]
if ($key == -1)
{
$cats = array_keys($categories);
$key = $cats[0];
$after = false;
}

$categories = array_insert($categories, $key, $thiscat, $after);

is the current code... I'm guessing it should be:
Code: [Select]
if ($key == -1)
{
$cats = array_keys($categories);
$key = !empty($cats) ? $cats[0] : 0;
$after = false;
}

$categories = array_insert($categories, $key, $thiscat, $after);
Title: Re: Just emptied the boards table and got an error
Post by: live627 on August 10th, 2013, 02:52 AM
Just got around to testing this again. It works.
Title: Re: Just emptied the boards table and got an error
Post by: live627 on February 4th, 2014, 06:46 AM
Quote from Arantor on June 29th, 2013, 08:31 PM
Ah, yes, I see the problem and it will affect anyone. If there's a situation where you're viewing the board index without any visible categories it'll throw the error. And if there's no visible boards, there's no visible categories.

Code: [Select]
if ($key == -1)
{
$cats = array_keys($categories);
$key = $cats[0];
$after = false;
}

$categories = array_insert($categories, $key, $thiscat, $after);

is the current code... I'm guessing it should be:
Code: [Select]
if ($key == -1)
{
$cats = array_keys($categories);
$key = !empty($cats) ? $cats[0] : 0;
$after = false;
}

$categories = array_insert($categories, $key, $thiscat, $after);
Is this now in the codebase? I'm in the middle of rebuilding my localhost so can't check atm...
Title: Re: Just emptied the boards table and got an error
Post by: Nao on February 4th, 2014, 11:13 AM
To me, this looks like code that's only in the pseudo-board stuff, i.e. moderation quicklinks...
There's only one line to change, I just changed it because it's basically a free one, but... Well, at least it should fix your error at that line number.
It'll be in my next commit!