#140 ✓ resolved
Krzysztof Rudnik

bric_dev_sync crashes on elements with codeselect

Reported by Krzysztof Rudnik | March 1st, 2010 @ 03:15 PM | in 1.11.4

When syncing en element with codeselect one gets
"Invalid codeselect code (didn't return an array ref of even size)"

I've found out that
Bric/SOAP/ElementType.pm uses outdated code for codeselect verification
(Bric/SOAP/ElementType.pm line 648):

Verify the code if it's a codeselect

XXX: triplicated now... (cf. comp/widgets/profile/displayAttrs.mc

and lib/Bric/App/Callback/Profile/FormBuilder.pm)

if ($field->{widget_type} eq 'codeselect') {

            my $code = $field->{options};
            my $items = eval "$code";
            unless (ref $items eq 'ARRAY' and !(@$items % 2)) {
            throw_dp "Invalid codeselect code (didn't return an array ref of even size)";
            }
         }

I added
use Bric::App::Util qw(:elem);

and replaced these lines by
if ($field->{widget_type} eq 'codeselect') {

            my $code = $field->{options};
            my $items = eval_codeselect($code);
            unless (ref $items eq 'HASH' or ref $items eq 'ARRAY'){
           # unless (ref $items eq 'ARRAY' and !(@$items % 2)) {
            throw_dp "Invalid codeselect code (didn't return an array ref of even size)";
            }
        }

and syncing process goes cleanly.

Will this hurt me later?

Krzysztof

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Referenced by

Pages