1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Calc element no longer working with php7.2

Discussion in 'Professional Support' started by ontarget, Nov 9, 2018.

  1. ontarget

    ontarget Member

    Level: Professional
    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:
    Here is my code - is there something in my php that is possibly deprecated?
    I Appreciate any pointers!
    Code (Text):
    $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: Nov 9, 2018
  2. ontarget

    ontarget Member

    Level: Professional
    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 (Text):
    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: Nov 12, 2018
  3. ontarget

    ontarget Member

    Level: Professional
    Hi can anyone help with this please?
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  5. skyrun

    skyrun Active Member

    Level: Professional
    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.
     

Share This Page