Undefined variable: repeatCounter

Bauer

Well-Known Member
I've got a zillion of these in my php error log...
Notice: Undefined variable: repeatCounter in /home2/annperry/compcircles/public_html/plugins/fabrik_element/databasejoin/databasejoin.php on line 3057

after updating today it's line 3051

But this issue is just what I have been posting about in my last 3 threads.
There is no repeat counter being passed to this function.
 
Do you have any "multiselect join" elements (like a joins set to checkbox, or upload elements set to AJAX) in repeat groups?

That line in getLabelForValue() was originally a monkey patch for that usage case, and I think has since been deprecated, and should be handled elsewhere, as repeat groups are handled totally differently in 3.1. I've set a breakpoint on it, and will dick around with my various join test cases, see if I can tell what is still triggering it.

I'm pretty sure we can just remove that test for the data being an array in an isJoin() case, meaning we really don't need the $repeatCounter in there, but need to work out what's actually going on before I do that.

-- hugh
 
This Reports/Breakous configuration form is pretty complex. It's for the Hospital/healthcare industy. So I use 'all of the above' - 6 to 24 multi-selects in one form.- plus checkbox groups - and radiobuttons- and dropdowns -and text input The form allows users to create (up to 5) 'Breakouts' from the 'master report' data (those tables are joined to the report - and put in a a special tabbed template I created .) Each breakout allows the user to select (filter their breakout) to include certain facility types, member organizations, regions of the country, states, and job groups - min.-max ranges for fulltime employeee counts, beds, gross incomes, etc. and use PHPExcel to write it out as spreadsheets, csv, or html. There's over 20 database join elements in the form - about 3/4 of them shown/hidden at any one time depending on what the user selects. So yeah, I'm pretty much pushing Fabrik to the limits here I know - and have still yet to get any volume of data for real stress testing. We're just at that point now - after over 18 months developing (and moving the goalposts on me).

So I really feel it's crunch time and am hoping to leave her with a product that is as stable as can be expected. I appreciate you looking into this.
 
If you'd like to point me at those three other threads, I'll see what I can do. The breakpoint I put in there yesterday hasn't triggered yet, but I haven't been working on anything with much by way of joins today.

What you could do is stick a var_dump() in there, so you can at least identify which join(s) are hitting that. Probably just dump the whole element object, so ...

Code:
                // In a repeat group
                if (is_array($v))
                {
var_dump($this);exit;
                    $v = JArrayHelper::getValue($v, $repeatCounter);
                }

It'll be a Big Dump, but you should be able to pick the bones out of it and work out which element it is, confirm that it's a multiselect join in a repeat group. And hopefully some clue as to what you are doing when it hits that.

-- hugh
 
Sorry was kinda busy today
Here's the other 2 links...
http://fabrikar.com/forums/index.php?threads/juser-_load-unable-to-load-user-with-id-1.38048/
(Be sure to read my follow-up post in that thread)

http://fabrikar.com/forums/index.ph...n-plugin-not-working-for-databasejoins.38041/
I'm pretty sure these 'doubling' issues are all related to this 'repeat counter' issue with database joins in repeat groups.

I attached a text file of the the var-dump of $v as you requested (good idea).

I put the lines...
echo "END";
exit;

at the end of the PHP script that gets processed on form submission
That's how I was able to capture the entire sequence of var_dumps on screen and cut and paste it to this text file.

It's pretty much as I suspected. It looks as if the databasejoin.php script is run twice and the 2nd time through is when the errors start to occur.
But this 'doubling' thing isn't just happening here with my custom php form plugin script. (See other threads linked above)

If I leave out the var_dump in the datbasejoin.php - and add an echo or var_dump anywhere in the php script (or any of the included scripts) that I wrote - those echos or var_dumps are not shown doubled - so we KNOW it's only a problem with the databasejoin element.

Also - to assure you - I include "require _once" in any scripts I include in the code. And yes, 'Require Once' is also set as Yes in the PHP plugin configuration.
 

Attachments

  • v_var_dump.txt
    63.8 KB · Views: 180
Have you made any progress on this Hugh?
Here's a followup with some issues I had that seem to be related. (I originally was gong to post this as a new thread but think it's related to this - so I just pasted that here.)


I found 2 bugs today ? and the first (if not both) are related to this ?repeatCounter? issue that seems to plague the latest version of Fabrik.
I only happened upon this error because I threw an ?exit;? in a php form plugin I was working on.

Notice: Undefined index: fb_breakouts___id in /home/serverpath/public_html/components/com_fabrik/models/plugin-form.php on line 279

In plugin-form.php this is line 279?
$repeatGroup = count($model->formDataWithTableName[$smallerElHTMLName]);
Aghhh ? the old ?repeatGroup?

I started some basic debugging.
$smallerElHTMLName is echoed as ?fb_breakouts_id? which is the primary key of the repeat group ? so I assume this is correct.

I then var_dumped $model->formDataWithTableName at that point and this is the result?
array(4) { ["fb_reports___mng_valid"]=> string(1) "1" ["fb_reports___mng_valid_raw"]=> string(1) "1" ["fb_breakouts___use_management_"]=> string(1) "0" ["fb_breakouts___use_management__raw"]=> string(1) "0" }

Why it only has 2 variables (x2 raw) is beyond me ? but because ?fb_breakouts_id? is not there, that is what causes the error.

If I dump $model->formData ? the entire form data is shown.

So changing line 279 FROM $repeatGroup = count($model->formDataWithTableName[$smallerElHTMLName]);
...TO $repeatGroup = count($model->formData[$smallerElHTMLName]);
Got me past this error.

...And, after refreshing the page, on to another one ? which has only started occurring because I included the Email plugin in the form?
Notice: Uninitialized string offset: 0 in /home/serverpath/public_html/plugins/fabrik_element/textarea/textarea.php on line 398

This error is shown twice. In that code on line 398 in textarea.php is in this function?
public function getEmailValue($value, $data = array(), $repeatCounter = 0)

Checking those vars ? $value is an empty string - string(0) "" - (not an array as expected) ? and hence the error.
And $repeatCounter was passed as 0.

I have no solutions - just passing on this extra effort I put into trying to debug and help - hoping it can help you solve this ?repeatCounter? issue.
 
I've had to re-install my Eclipse on a new server, so I lost the break point I had set up on that. I didn't trigger it in the few days I had it set, but then, I wasn't coding much work on repat joins.

I'll stick it on there again, see if I can get it to trigger.

-- hugh
 
Thanks. I was thinking this strange error in components/com_fabrik/models/plugin-form.php on line 279 might be the key to it all.

What is the difference between $model->formDataWithTableName (which is what is called here) and $model->formData???

This error is just a 'Notice' - so usually it's not even seen, yet seems critical to the expected workings of any form plugin. If it's always returning an incomplete array list for $model->formDataWithTableName - rather than the complete list of form fields like what gets returned with $model->formData - then that would explain why that '$repeatGroup' variable is not being initialized.

This 'plugin-form.php' file is used by ALL form plugins, correct??? So it wouldn't just be an issue with database join elements but any elements that are looking for that '$repeatGroup' value.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top