Errors in CBSUBS log for code field

4 years 5 months ago #315418 by matt@harrington.co.nz
Errors in CBSUBS log for code field was created by matt@harrington.co.nz
Hi all,

I have a code field which works fine however I have noticed my log is full of errors when members are renewing or signing up for membership.
WARNING: Invalid argument supplied for foreach() in .../CB/Plugin/Code/CBCodeField.php(261) : eval()'d code on line 2
Trace:called in class cbpaidErrorHandler::_error_handler_callable(2, "Invalid argument supplied for foreach()", "/home/126397.cloudwaysapps.com/jgzmkbhytt/public_html/components/com_comprofiler/plugin/libraries/CB/Plugin/Code/CBCodeField.php(261) : eval()'d code", 2, array("field" => object(CB\Database\Table\FieldTable), "user" => object(CB\Database\Table\UserTable), "value" => NULL, "names" => "")) on line 2 in file CBCodeField.php(261) : eval()'d code
called in class CB\Plugin\Code\CBCodeField::{closure}(object(CB\Database\Table\FieldTable), object(CB\Database\Table\UserTable), NULL) on line 263 in file CBCodeField.php
called in class CB\Plugin\Code\CBCodeField::outputCode("$names = "";
foreach ( json_decode( '', true ) as $child ) {
$names = $names. " - ".$child['cb_familymembername'];

}

It appears using foreach on an empty json field produces this error. Can anyone help with preventing this?

Cheers, Matt

Please Log in to join the conversation.

4 years 5 months ago #315433 by krileon
Replied by krileon on topic Errors in CBSUBS log for code field
Improve your code to account for empty JSON field. A new user object for example will have no field values so such situations need to be accounted for.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: matt@harrington.co.nz

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.300 seconds

Facebook Twitter LinkedIn