Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: habakuk on May 13, 2011, 08:07:11 PM

Title: [4731] rc5 : unable to add topic icons
Post by: habakuk on May 13, 2011, 08:07:11 PM
SMF : rc5, fresh install
Modifications:  none
List any Themes: default themes.
List any non-English Language packs you have installed: german-UTF8
Are you using UTF-8? Yes

Server Software:  MacOSX Server 10.6.x
Apache/IIS version?: Apache 2.1.x
PHP version?:  5.3.x
Database type and version: postgres 8.3.x

Where the Error Occurred:

Unable to ADD a new topic symbol. Using the text link "Add new symbol" (http://blah.com/index.php?action=admin;area=smileys;sa=editicon), it's always the last icon that is getting overwritten. I can define a new icon, but it always overwrites the information of the last (fourth) icon in the list.

First, I have deleted some of the default icons from the list. Then I did upload the new icons to the default theme > images > post folder. Then I click the link "Add new icon" and specify the filename, display name and its position. After clicking save, I am returned to the listing. And the listing truly contains the new icon, but, the last one added is now gone.

In the DB, the icons get the ID 1,4,5 and 0.  The icon_order is 1,2,3 and 0.

If I fix the zero ID, things are working again - for exactly one post.

It looks like the method doesn't manage to find the last icon ID and always uses the last one added, instead of the last one aded +1.

cheers
®
Title: Re: rc5 : unable to add topic icons
Post by: habakuk on May 26, 2011, 03:48:15 AM
Just verified that on a new installation and it still shows the same problem.

Whenever I try to add a new message icon, the last icon is overwritten. The sequence is properly triggered and counts up, but the id_icon is always zero, so it always overwrites the same record.

So, I set the id manually to anything not zero (but unique and within the sequence counter...). The icon appears in the editor list. Then, I add a new one. That works, but it gets the id_icon set to ZERO again. If I now try to add a new one, it is always the last row, which has an id of zero, that gets overwritten. Nothing added.

I see you set

if (empty($_GET['icon']) && empty($context['icons']))
$_GET['icon'] = 1;


But the ID itself, during an insert, should be NULL, so the sequence is adding the proper value, no?

cheers
®

Title: Re: rc5 : unable to add topic icons
Post by: emanuele on May 28, 2011, 02:44:44 PM
I can confirm that one.

A fix could be: in ManageSmileys.php find
Code (find) Select
// Do a huge replace ;)
$iconInsert = array();
foreach ($context['icons'] as $id => $icon)
$iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);

$smcFunc['db_insert']('replace',
'{db_prefix}message_icons',
array('id_icon' => 'int', 'id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'),
$iconInsert,
array('id_icon')
);


replace with:
Code (replacee with) Select
// Do a huge replace ;)
$iconInsert = array();
foreach ($context['icons'] as $id => $icon)
if($id!=0){
$iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
} else {
$iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
}
$smcFunc['db_insert']('replace',
'{db_prefix}message_icons',
array('id_icon' => 'int', 'id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'),
$iconInsert,
array('id_icon')
);

if(!empty($iconInsert_new))
$smcFunc['db_insert']('replace',
'{db_prefix}message_icons',
array('id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'),
$iconInsert_new,
array('id_icon')
);
Title: Re: rc5 : unable to add topic icons
Post by: Illori on May 28, 2011, 02:57:20 PM
/me throws a bug tracker at emanuele
Title: Re: rc5 : unable to add topic icons
Post by: habakuk on May 28, 2011, 03:14:31 PM
Thanks much! I'll go ahead and try to apply that fix. I'll report back.

cheers
®
Title: Re: rc5 : unable to add topic icons
Post by: emanuele on May 28, 2011, 03:24:48 PM
Quote from: Illori on May 28, 2011, 02:57:20 PM
/me throws a bug tracker at emanuele
That time I was in a hurry, but thanks! ;)

http://dev.simplemachines.org/mantis/view.php?id=4731
Title: Re: [4731] rc5 : unable to add topic icons
Post by: Oldiesmann on May 31, 2011, 11:52:26 AM
Thanks for the report. I've committed the fix to SVN.