I added a bunch of new smileys today, about 80 of them to be honest.
When I goto to forum and make a test post through the quick reply I get the error. I do the WYSIWYG editor option enabled and use full editor in quick reply.
ETA: Happens whenever I visit the thread.
This might be a bug actually, I had 2 rows of smileys and was getting the error, once I dropped to 1 row the error goes away.
Yep, looks pretty much like a bug.
At the moment I can't test, if you can disable the template evaluation (try a search in the admin area, you should find it "eval" should be enough, I wonder if I we should just disable it by default :-\) you could get the exact place the error occur.
Been trying to reproduce this one with no luck just yet.
I did not add any smileys but rearranged the stock ones. I have 3 rows in the main window and 3 rows in the the pop up window but no errors in the log.
I'm guessing this is an error in the template_control_richedit area when its building the smiley arrays, but will know for sure when template evaluation is changed.
ETA: tried 153 smileys on 3 rows w/o error :( ... I sure something is wrong since the log does not lie, but currently have not found what triggers it.
I think I found it.
I wasn't actually able to reproduce the exact same error, but through another one in javascript I think I got the idea of where the error is.
In sources/subs/Editor.subs.php, when the arrary is filled, the "last" row is marked (TBH I'm not entirely sure it's necessary, but let's leave it there for the moment <= we may convert all that stuff to "proper" JSON at some point in the future), and it is find like this:
$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
But, the "last row" could under certain circumstances be different (e.g. in the db the "row" is not always strictly sequential).
So, changing the block:
foreach ($context['smileys'] as $section => $smileyRows)
{
foreach ($smileyRows as $rowIndex => $smileys)
$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
if (!empty($smileyRows))
$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
}
to:
foreach ($context['smileys'] as $section => $smileyRows)
{
$last_row = null;
foreach ($smileyRows as $rowIndex => $smileys)
{
$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
$last_row = $rowIndex;
}
if ($last_row !== null)
$context['smileys'][$section][$last_row]['isLast'] = true;
}
seems to fix the problem.
Want me to add that to the PR I have open ?
Cool, yes!
Thank you both for looking into this so quickly.
Sent !