fyi on a notice i'm getting in error_logs on a form

skyrun

Active Member
Warning: preg_match() expects parameter 2 to be string, array given in /home/skyrunftp/subdomains/testlocation/httpdocs/libraries/fabrik/fabrik/Helpers/StringHelper.php on line 1064

Notice: Array to string conversion in /home/skyrunftp/subdomains/testlocation/httpdocs/libraries/fabrik/fabrik/Helpers/StringHelper.php on line 1071

Notice: Array to string conversion in /home/skyrunftp/subdomains/testlocation/httpdocs/libraries/fabrik/fabrik/Helpers/StringHelper.php on line 1071

on my site, it's on the screen on the top of https://testlocation.skyrun.com/skytrax-manage/work-orders/form/180/826
on my production sites it's in error_log.
 
Hmm, that's coming out of getRowClass() ... but without a stack trace or debug it's hard to know which element is causing it.

Could you try adding this ...

Code:
if (is_array($value)) {
   var_dump($value);exit;
}

... as the first line in that function, load your page one time, and see if that tells you which element it is, and let me know the element type / settings.

-- hugh
 
output was:
array(1) { [0]=> string(7) "Entered" }

'Entered' is the value of an element 'status'. that element is a pretty standard databasejoin type that joins to another table.

this is the html for the form:

<select id="srms_work_orders___status" name="srms_work_orders___status[]" class="fabrikinput form-control inputbox input advancedSelect input-xlarge" size="1">
<option value="">Please select</option>
<option value="1" selected="selected">Entered</option>
<option value="10">Waiting on Approval</option>
<option value="11">Waiting Parts</option>
<option value="12">Ready to Work</option>
<option value="31">Waiting for Invoice</option>
<option value="2">In progress</option>
<option value="21">On hold</option>
<option value="3">Done</option>
<option value="4">Approved for Billing</option>
<option value="5">Billed on Stmt</option>
<option value="6">File only</option>
</select>

and fyi to make sure i did it right, i put your code here:
public static function getRowClass($value, $prefix)
{
if (is_array($value)) {
var_dump($value);exit;
};
$value = preg_replace('/[^A-Z|a-z|0-9]/', '-', $value);
... etc...
 
Yup, that's the right place.

Ah, I see what the issue may be. I fairly recently added setting the 'row class' (if you've selected that option for adding the element's value as a row class in the list) in forms as well, so it adds the 'row class' to the container. But I think in certain circumstances the $element->value I'm using for that can be a single value array.

So try this ... instead of that dump code, put this as the first lines in the code ...

Code:
        // when called in form context, could be a single value array
        if (is_array($value))
        {
            $value = empty($value) ? '' : reset($value);
        }

... which should grab that first array entry.

-- hugh
 
yep, that fixed it. thanks.

different topic, same spirit of trying to clean up my error_logs of notices. could you replace these 4 lines in
plugins/fabrik_element/fileupload/fileupload.php (around the first 15 lines):
add 'if (!defined('FU_DOWNLOAD_SCRIPT_NONE')) in front of the 4 lines starting with define("FU_DOWNLOAD_SCRIPT_NONE", '0');

PHP:
if (!defined('FU_DOWNLOAD_SCRIPT_NONE')) define("FU_DOWNLOAD_SCRIPT_NONE", '0');
if (!defined('FU_DOWNLOAD_SCRIPT_TABLE')) define("FU_DOWNLOAD_SCRIPT_TABLE", '1');
if (!defined('FU_DOWNLOAD_SCRIPT_DETAIL')) define("FU_DOWNLOAD_SCRIPT_DETAIL", '2');
if (!defined('FU_DOWNLOAD_SCRIPT_BOTH')) define("FU_DOWNLOAD_SCRIPT_BOTH", '3');

shouldn't cause issues i wouldn't think. i have my own version fileupload_enh.php that we have modified to work with groups and yours is redefining these variables and giving notices. not entirely sure why yours is running since only fileupload_enh is on the form, but putting those lines in will avoid a notice if you don't see any downside.
 
Last edited:
Done.

It would have been running because all plugins get loaded, regardless of what you use on the form. Not a Fabrik thing, it's a J! thing. Every plugin you have enabled (not just Fabrik) gets loaded, every page load. Which is why I always advise people to only enable plugins they are actually using.

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

Thank you.

Members online

Back
Top