[ic] Admin New Entry Problem
Stefan Hornburg (Racke)
racke at linuxia.de
Thu Dec 14 05:22:24 EST 2006
Peter wrote:
> On 12/11/2006 09:15 PM, Cameron B. Prince wrote:
>> I'm having a problem with the Admin's New Entry function. This is using a
>> default standard catalog on IC v5.4.1 with MySQL. When you edit a table that
>> uses the autonumber counter files as a key, such as products, you can
>> duplicate the problem by clicking New Entry. Leave the pre-filled key intact
>> and click Ok to create the new entry. You will see that you are returned to
>> the flex_editor but instead of it having the next key pre-filled, all the
>> fields are empty.
>>
>> You can click New Entry again to create another item, but you will find that
>> the counter has been incremented twice. I updated the meta for the New Entry
>> menu item and added a ui_return_to=admin/flex_select to cause the Ok to take
>> you back to the edit page rather than having the empty flex_editor but was
>> surprised to find the counter was still incremented twice after creating a
>> new entry.
>
> I've seen this exact issue and never had the time to look into it. If I
> get the time I'll be happy to look into it, or if someone either (1)
> finds the problem themselves and gives me an idea where to look so I
> don't have to spend all day and a half tracking it down or (2) pays me
> to do it then I'll be likely to commit a fix for it in the near future,
> otherwise may not happen for a while (I'm pretty swamped with other
> things that take priority). That's speaking for me, someone else may
> fix it.
>
> FWIW this problem goes back at least as far as 5.2.0 and is not specific
> to MySQL (I get the same problem with PostgreSQL). It's not specific to
> standard, either, I see it in Foundation-based sites.
>
>> 1) Is there a logical reason that I'm not realizing for incrementing the
>> counter twice? If not, how can this be prevented?
>
> Probably not, it's just a minor bug.
The counter is really incremented twice:
1. flex_editor
unless ($db->config('AUTO_SEQUENCE')) {
$db->config('AUTO_NUMBER', '000001')
unless $db->config('AUTO_NUMBER');
$CGI->{item_id} = $db->autonumber();
}
2. [table-editor]
if($opt->{ui_new_item} and ! $opt->{notable}) {
if( ! $db->config('_Auto_number') and ! $db->config('AUTO_SEQUENCE')) {
$db->config('AUTO_NUMBER', '000001');
$key = $db->autonumber($key);
}
else {
$key = '';
$opt->{mv_data_auto_number} = 1;
$key_message = errmsg('(new key will be assigned if left blank)');
}
}
The code looks slightly different, so I wonder whether we can just drop the
code in flex_editor without regressions. It appears superfluous to me.
Bye
Racke
--
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team
More information about the interchange-users
mailing list