Skip to main content
Topic: Smiley error in log (Read 2141 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Smiley error in log

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.

Re: Smiley error in log

Reply #1

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.
Bugs creator.
Features destroyer.
Template killer.

Re: Smiley error in log

Reply #2

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.
Last Edit: September 06, 2014, 07:44:57 am by Spuds

Re: Smiley error in log

Reply #3

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:
Code: [Select]
$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:
Code: (find) [Select]
				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:
Code: (replace with) [Select]
				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.
Bugs creator.
Features destroyer.
Template killer.

Re: Smiley error in log

Reply #4

Want me to add that to the PR I have open ?

Re: Smiley error in log

Reply #5

Cool, yes!
Bugs creator.
Features destroyer.
Template killer.

Re: Smiley error in log

Reply #6

Thank you both for looking into this so quickly.

Re: Smiley error in log

Reply #7

Sent !