List.php formData() function error

Bauer

Well-Known Member
I am using the php_events list plugin to run some code in onDeleteRows.
The list is using the Div template.

I use the $model->rowsToDelete array to determine values of various elements as a way initializing some variables used in the php code.

This line no longer works and errors out with "invalid index".
$fid = $model->rowsToDelete[0][0]->fb_member_facilities___facility_id_raw;

Suddenly (I have no idea when/why this started happening) the first index in that rowsToDelete array is no longer zero. The first index is now the Joomla user ID - which just seems to make no sense to me at all.

In debugging, I traced this as coming from line 1313 in list.php. where the _groupId is somehow being initialized as the Joomla user ID. This is the part of the list.php code that is trying to "// Check if the data has a group by applied to it" - in the formData() function.

But exactly how the _groupId always ends up as the user ID is beyond me - and it's beyond my pay grade (of zero) to fix this bug that was apparently recently introduced into the fabrik code.

I suppose I could just rewrite my onDeleteRows code to compensate for this change - but that wouldn't solve the problems that this might be introducing elsewhere - in hundreds of other Fabrik users' code - would it?
 
Try this:
PHP:
$rows = $model->rowsToDelete;
echo '<pre>rows_data: ' . var_export($rows[0], true) . '<\/pre>';
 
Try this:
PHP:
$rows = $model->rowsToDelete;
echo '<pre>rows_data: ' . var_export($rows[0], true) . '</pre>';

You don't believe me?:p
rows_data: NULL

I have some debugging in list.php - here's what is in my php error log.

8734 list.php rows is Array
(
[318] => Array
(
[0] => stdClass Object
(
[fb_member_facilities___id] => 10
[fb_member_facilities___id_raw] => 10
[fb_member_facilities___hospital_system_id_raw] => 0
[fb_member_facilities___hospital_system_id] => <ul class="fabrikRepeatData"><li></li></ul>
[fb_member_facilities___facility_type_id_raw] => 3
[fb_member_facilities___facility_type_id] => Medical Prac / OP Rehab
[fb_member_facilities___associated_parent_org_raw] => 4873
[fb_member_facilities___associated_parent_org] => <a data-loadmethod="xhr"
ETC...

There is no $model->rowsToDelete[0][0] because there is no $model->rowsToDelete[0]
There is no $rows[0]
And there is no $model->rowsToDelete[0]

There is a $rows[318][0]
There is a $model->rowsToDelete[318][0] (which is the data I need) where 318 is the Joomla userID.
It's just as I explained in my initial post! - Go figure.
If someone can duplicate this (using the Fabrik list 'div' template) I'd be very appreciative.
And I suppose I should have update from Github before whining about this - I'll try that now.
 
Thanks for the suggestions and feedback, startpoint.
I just updated from Github and the problem remains.

Maybe it's just with a div template - but I doubt it. Or maybe your code is from before this bug was introduced?
Because I know this php_events onDeleteRows code used to work just fine - it's just been a few months since I used/tested it. When did you last update from github?

If someone has the latest github update installed and a list that uses a div template, I'd appreciate confirmation that this is not 'just me'.
 
OK - I got this figured out, I think.o_O
The reason my code is erring out now is because I recently added a 'Group by' to the table.
When that happens the first key in the row (or rowsToDelete) array will be the raw value of the 'Group by' element - in my case that is the element holding the userID - so this is working as it should.

So it looks like it's a feature not a bug - and as usual, I put my foot in my mouth.:oops:
And I'm sure cheesegrits will confirm that for me once he takes off his St. Patricks's Day hat and gets back to work.:D

But I'll leave my embarrassment here just in case anyone else runs into this baffling situation. (And maybe the Wiki needs to be updated to explain this - if it isn't in there already?)
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top