• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Bug in databasejoin upon failed validation in repeat group

davez

Member
Hi,

I found a little bug. I'm working on a solution, but haven't figured it out yet.

It happens on a failed validation in a repeat group where a databasejoin dropdown exists. I get the error:

Error: 1054
Unknown column 'Array' in 'where clause' SQL=SELECT DISTINCT(`wic_sites`.`id`) AS value, `sitename` AS text,REPLACE(`description`, ' ', '
') AS description FROM `wic_sites` AS `wic_sites` WHERE `wic_sites`.`id` IN (Array,Array,Array) ORDER BY text ASC

In looking in the code /plugins/fabrik_element/databasejoin/databasejoin.php there was some notes about this
Code:
  if (is_array($v))
     {
       /**
        * $$$ hugh - tweaked this a little, as IN () pitches an error in
        * MySQL, so we need to make sure we don't end up with that.  So as
        * IN (), if it worked, would produce no rows, just replace with 1=-1
        * Can't just count($v), as sometimes it's an array with a single null entry.
        */
       $v  = array_map(array($db, 'quote'), $v);
         $ins = implode(',', $v);
       if (trim($ins) === '')
       {
         $query->where('1=-1');
       }
       else
       {
         $query->where($key . ' IN (' . $ins . ')');
       }
     }
Sometimes $v is an array two-levels deep, so when it implodes, there's still an array. This only seems to happen when it's reloading the page after a failed validation.
 
I can't replicate this. I have several forms with repeat groups with joins of various types, and none of them blow up like that when failing validation.

Does it happen every time? Is it only on new records? Anything you can narrow it down to?

-- hugh
 
Here are some more details. See notes in attachment.

*It only occurs on a failed validation during edit (new works fine).
*The databasejoin is in the repeat group.
*This particular databasejoin has a WHERE statement: area = '{wic_permits___area_raw}'. I have AJAX Update set to Yes. This field wic_permits___area is a field in the main form elements, not the repeat group. So, it acts like a cascadingdropdown. I now see AJAX update is a WIP, so that might be the issue.

I tried to edit the code in the chunk above databasejoin.php, but I ran into further issues. So, I figured this is a bigger beast than I'm aware of.

My solution is to make it fully validate through AJAX, so it's not crashing for users. So, that's a fine fix for now.
 

Attachments

  • permit-form.jpg
    permit-form.jpg
    63.8 KB · Views: 28
I have a pretty identical setup, with a join in a repeat group, AJAX updating, watching an element in the main group. And I can't replicate the problem. Edit an existing record, induce a validation failure, fix the validation, resubmit, everything is fine.

Are you adding new repeat groups? Or does this happen regardless of whether you add a new repeat or just submit with the original ones?

-- hugh
 
You've got all the steps. It happens even if I don't add a new repeat group.

Well, I've tried turning on and off almost all potential options and I still get the error...with or without AJAX, with or without WHERE statement, etc.

I'll try to recreate elsewhere.
 
I just tried turning the repeating group off (in the group). And it worked fine, failed validation and did not throw a mysql error.
 
Try adding a regular dropdown in the repeat group. I unpublished my two regular dropdowns that are with the databasejoin and it prevented the failure.

Edit: Actually, the 'regular dropdowns' work. In mine, I had an advanced population field:
for ($i=1;$i<=100; $i++) {
$options[] = JHTML::_('select.option', $i, $i);
}
return $options;

If I remove that and just populate those numbers in the normal way. It works. yay!
 
Last edited:
Hmmm, that's bizarre.

I'll file that under "interesting behavior", and maybe take a look at some point.

Glad you tracked it down.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top