• 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.

Calc element no longer working with php7.2

ontarget

Active Member
I am running joomla 3.9.0 and Fabrik 3.9
I have a calc element that calculates distance using the goolge maps distance matrix api which works fine when the account is on php5.6 as soon as I switch to php7.2 / php 7.0 the calc element no longer works and it simply returns 0
Here are the calc settings:
Only Calc on Save = Yes
Ajax calculation = Yes
Ajax observe fields = '{aaa_participant_claim___mode_of_transport}, {aaa_participant_claim___school_eircode}'

Here is my code - is there something in my php that is possibly deprecated?
I Appreciate any pointers!
Code:
$venue_ec = '{aaa_participant_claim___venue_ec}';
$start_ec = '{aaa_participant_claim___start_eircode}';
$school_ec = '{aaa_participant_claim___school_eircode}';
$venue_ec = str_replace(' ','',$venue_ec);
$start_ec = str_replace(' ','',$start_ec);
$school_ec = str_replace(' ','',$school_ec);

$mode = '{aaa_participant_claim___mode_of_transport_raw}';

if($mode == "car_public") {
  $station_ec = '{aaa_participant_claim___station_eircode}';
  $station_ec = str_replace(' ','',$station_ec);
  $end_ec = $station_ec;
} else if ($mode == "car") {
  $end_ec = $venue_ec;
} else if ($mode == "public_only") {
  return 0;
}

if($start_ec === '0') {return 0;}
elseif ($start_ec === "") {return 0;}

//if (strlen($start_ec) === 0)
//{
//return 0;
//}
//else if ($start_ec == "0")
//{
//return 0;
//}



//working for fastest route
$data1 = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$start_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxx&sensor=false");


$data2 = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$school_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxx&sensor=false");


$data1 = json_decode($data1);
$distance1 = 0;
$status1 = "OK";
$distance1 = $data1->rows[0]->elements[0]->distance->value;
$status1 = $data1->status;
$msg1 = $data1->error_message;

$data2 = json_decode($data2);
$distance2 = 0;
$status2 = "OK";
$distance2 = $data2->rows[0]->elements[0]->distance->value;
$status2 = $data2->status;
$msg2 = $data2->error_message;


if ($distance1 < $distance2){
    return round($distance1/1000);
} else {
    return round($distance2/1000);
}
 
Last edited:
Hi is there anything I can try or change here?
I tried changing all the " " to ' ' instead but there is no difference.
Thanks
UPDATE
I ran the js debug &fabrikdebug=1 on my form view
Code:
Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/xxxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 38

Warning: file_get_contents(https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$start_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxxxxxxxxxxxx&sensor=false): failed to open stream: no suitable wrapper could be found in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 38

Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 41

Warning: file_get_contents(https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$school_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxxxxxxxxxxxx&sensor=false): failed to open stream: no suitable wrapper could be found in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 41

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 49

Notice: Trying to get property of non-object in /home/xxxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 49

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 49

Notice: Trying to get property of non-object in /home/xxxxx/public_html/xxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 49

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 50

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 51

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 57

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 57

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 57

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 57

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 58

Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 59
0
Hope this helps
 
Last edited:
The errors seem pretty clear:

Warning: file_get_contents(https://maps.googleapis.com/maps/ap...uage=en-EN&key=xxxxxxxxxxxxxxxxx&sensor=false): failed to open stream: no suitable wrapper could be found in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 38

Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/xxxxxxx/public_html/xxxxxxx/plugins/fabrik_element/calc/calc.php(476) : eval()'d code on line 41

As it says, "https:// wrapper is disabled in the server configuration by allow_url_fopen=0". If you google that, you'll get a bunch of Stack Overflow Q&As explaining exactly what that means and how to fix it.

So you'll need to enable allow_url_fopen in php.ini, which is what allows file_get_contents() to open a URL as a file.

-- hugh
 
ontarget,
i found that php > 5 throws ALOT of warnings and notices that php 5 ignored. so if there were issues with you code in v5, on v7 they'll be exposed.
ALSO, hugh is right that changes in your php.ini config or the list of php apache modules loaded (it's often overlooked that you may be running a different php when changing php versions) will also cause issues.

this has nothing to do with fabrik though.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top