Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Problem bei Umstellung von PHP 5.6 auf PHP 7.1

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    am: 09. Oktober 2020, 18:29:16
    Hallo Zusammen,
    wir müssen unseren Shop Version 2.0.2.2 mittelfristig auf PHP 7 umstellen.
    Bei einem Testlauf ergaben sich da ein Fehler beim Aufruf der shopping_cart.php
    Die Seite bleibt weiß

    Der PHP Error Log gibt aus:
    PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; ot_gambioultra has a deprecated constructor in /var/www/vhosts/domain/httpdocs/includes/modules/order_total/ot_gambioultra.php on line 18, referer: https://www.domain.de/

    Die entsprechende Datei habe ich angehangen.
    Hat jemand Ideen?

    Linkback: https://www.modified-shop.org/forum/index.php?topic=41386.0

    Viol

    • Fördermitglied
    • Beiträge: 2.209
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #1 am: 09. Oktober 2020, 20:01:23

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #2 am: 10. Oktober 2020, 08:41:34
    Jap, neustes Modul ist jetzt installiert. Scheinbar gibt es ein Problem mit dem Konstruktor.
    Ich komme dem aber nicht bei.

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #3 am: 10. Oktober 2020, 09:17:35
    [...]
    Der PHP Error Log gibt aus:
    PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; ot_gambioultra has a deprecated constructor in /var/www/vhosts/domain/httpdocs/includes/modules/order_total/ot_gambioultra.php on line 18, referer: https://www.domain.de/
    [...]

    Um Obiges Problem zu beheben musst du in der geposteten Datei ca. Zeile 21 folgenden Code

    Code: PHP  [Auswählen]
        function ot_gambioultra() {

    mit diesem ersetzen, aber das dadurch auch das Problem mit der weissen Seite behoben ist glaube ich nicht.

    Code: PHP  [Auswählen]
        function __construct() {

    Gruss
    Hanspeter

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #4 am: 10. Oktober 2020, 09:48:06
    Danke für die Rückmeldung.

    Das Problem besteht allerdings immer noch. Die Datei sieht nun wie folgt aus

    Code: PHP  [Auswählen]
    <?php
    /* -----------------------------------------------------------------------------------------
       Gambio OHG
       http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))
       -----------------------------------------------------------------------------------------
       XT-Commerce - community made shopping
       http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))
       -----------------------------------------------------------------------------------------
       based on:
       (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
       (c) 2002-2003 osCommerce(ot_loworderfee.php,v 1.11 2003/02/14); www.oscommerce.com
       (c) 2003      nextcommerce (ot_loworderfee.php,v 1.7 2003/08/24); www.nextcommerce.org

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/

       

      class ot_gambioultra {
        var $title, $output;

        function __construct() {
            global $xtPrice;
          $this->code = 'ot_gambioultra';
          $this->title = MODULE_ORDER_TOTAL_GAMBIOULTRA_TITLE;
          $this->description = MODULE_ORDER_TOTAL_GAMBIOULTRA_DESCRIPTION;
          $this->enabled = ((MODULE_ORDER_TOTAL_GAMBIOULTRA_STATUS == 'true') ? true : false);
          $this->sort_order = MODULE_ORDER_TOTAL_GAMBIOULTRA_SORT_ORDER;

          $this->output = array();
        }
       
                    function nc_get_product_shipping_costs()
                    {
                            global $xtPrice;
                           
                            $products = $_SESSION['cart']->get_products();
                            $costs          = 0;
                            $infos          = array();
                           
                            for($i=0; $i<sizeof($products); $i++) {
                                    $result = xtc_db_query('
                                            SELECT
                                                    p.nc_ultra_shipping_costs AS costs,
                                                    pd.products_name                                        AS products_name
                                            FROM    
                                                    products p
                                            LEFT JOIN
                                                    products_description AS pd USING (products_id)
                                            WHERE
                                                    p.nc_ultra_shipping_costs        != 0                                                                                                                                   AND
                                                    p.products_id                                                   = "'
    . $products[$i]['id']                       .'"     AND
                                                    pd.language_id                                                  = "'
    . $_SESSION['languages_id'] .'"
                                    '
    );
                                    //echo mysql_error();
                                    //if(mysql_errno() == 0)  {
                                    if(((defined('DB_MYSQL_TYPE') && DB_MYSQL_TYPE=='mysqli') ? mysqli_errno() : mysql_errno()) == 0) {
                                            while(($row = xtc_db_fetch_array($result) )) {
                                                    //$costs        += $row['costs'] * $products[$i]['quantity'];
                                                    $costs  += $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], false, 0, true);

                                                   
                                                    //Berechnungsformel für Menge * Versandkosten
                                                    /*
                                                    $infos[] = array(
                                                                                                    'title'                         => $products[$i]['quantity'] .'x '. $row['products_name'],
                                                                                                    'price'                         => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, true),
                                                                                                    'price_plain' => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], false, 0, true)
                                                                                            );
                                                    */


                                                    //Berechnungsformel nur einmal Versandkosten pro Artikel (unabhängig von der Menge)
                                                    $infos[] = array(
                                                                                                    'title'                         => $products[$i]['quantity'] .'x '. $row['products_name'],
                                                                                                    'price'                         => $xtPrice->xtcFormat($row['costs'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, true),
                                                                                                    'price_plain' => $xtPrice->xtcFormat($row['costs'], false, 0, true)
                                                                                            );
    /*
                                                    if(MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS != 0) {
                                                            $infos[] = array(
                                                                                                            'title'                         => $products[$i]['quantity'] .'x '. $row['products_name'] .' ('.$xtPrice->xtcFormat($row['costs'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, false).')',
                                                                                                            'price'                         => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, true),
                                                                                                            'price_plain' => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], false, 0, true)
                                                                                                    );
                                                    }
                                                    else {
                                                            $infos[] = array(
                                                                                                            'title'                         => $products[$i]['quantity'] .'x '. $row['products_name'] .' ('.$xtPrice->xtcFormat($row['costs'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, true).')',
                                                                                                            'price'                         => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], true, MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, true),
                                                                                                            'price_plain' => $xtPrice->xtcFormat($row['costs'] * $products[$i]['quantity'], false, 0, true)
                                                                                                    );
                                                    }
    */
                                                 
                                            }
                                    }
                            }
                            $output = array(
                                                                            'costs' => $costs,
                                                                            'infos' => $infos
                                                            );
                            return $output;
                    }

        function process() {
          global $order, $xtPrice;
         
          //include needed functions
          require_once(DIR_FS_INC . 'xtc_calculate_tax.inc.php');
         
          if (MODULE_ORDER_TOTAL_GAMBIOULTRA_STATUS == 'true')
          {
            switch (MODULE_ORDER_TOTAL_GAMBIOULTRA_DESTINATION) {
              case 'national':
                if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
              case 'international':
                if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
              case 'both':
                $pass = true; break;
              default:
                $pass = false; break;
            }

            if($pass == true)
            {
                    $nc_ultra_data          = $this->nc_get_product_shipping_costs();
                    $nc_ultra_details = '';
                   
              $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
              $tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);

                                            if (MODULE_ORDER_TOTAL_GAMBIOULTRA_DETAILS == 'false') // without details...
                                            {
                                                    if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                                                      $order->info['tax'] += xtc_calculate_tax($nc_ultra_data['costs'], $tax);
                              $order->info['tax_groups'][TAX_ADD_TAX . "$tax_description"] += xtc_calculate_tax($nc_ultra_data['costs'], $tax);
                              $order->info['total'] += $nc_ultra_data['costs'] + xtc_calculate_tax($nc_ultra_data['costs'], $tax);
                              $gambioultra_fee=xtc_add_tax($nc_ultra_data['costs'], $tax);
                            }
                            if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                                                            $gambioultra_fee=$nc_ultra_data['costs'];
                                                            $order->info['tax'] += xtc_calculate_tax($nc_ultra_data['costs'], $tax);
                                    $order->info['tax_groups'][TAX_NO_TAX . "$tax_description"] += xtc_calculate_tax($nc_ultra_data['costs'], $tax);
                                                            $order->info['subtotal'] += $gambioultra_fee;
                                    $order->info['total'] += $gambioultra_fee;
                            }
                            if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] != 1) {
                                                            $gambioultra_fee=$nc_ultra_data['costs'];
                                                            $order->info['subtotal'] += $gambioultra_fee;
                                $order->info['total'] += $gambioultra_fee;
                            }
                            $output_title  = MODULE_ORDER_TOTAL_GAMBIOULTRA_OUTPUT_NAME . ':';
                      $this->output[] = array('title' => $output_title,
                                              'text'        => $xtPrice->xtcFormat($gambioultra_fee, true),
                                              'value' => $gambioultra_fee);
                                            }
                                            else //show details...
                                            {
                      foreach ($nc_ultra_data['infos'] as $info) {
                                                            if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                                                                    $order->info['tax'] += xtc_calculate_tax($info['price_plain'], $tax);
                                      $order->info['tax_groups'][TAX_ADD_TAX . "$tax_description"] += xtc_calculate_tax($info['price_plain'], $tax);
                                      $order->info['total'] += $info['price_plain'] + xtc_calculate_tax($info['price_plain'], $tax);
                                      $gambioultra_fee = xtc_add_tax($info['price_plain'], $tax);
                                    }
                                    if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                                                                    $gambioultra_fee = $info['price_plain'];
                                                                    $order->info['tax'] += xtc_calculate_tax($info['price_plain'], $tax);
                                            $order->info['tax_groups'][TAX_NO_TAX . "$tax_description"] += xtc_calculate_tax($info['price_plain'], $tax);
                                                                    $order->info['subtotal'] += $gambioultra_fee;
                                            $order->info['total'] += $gambioultra_fee;
                                    }
                                    if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] != 1) {
                                                                    $gambioultra_fee = $info['price_plain'];
                                                                    $order->info['subtotal'] += $gambioultra_fee;
                                        $order->info['total'] += $gambioultra_fee;
                                    }
                                    $output_title   = MODULE_ORDER_TOTAL_GAMBIOULTRA_OUTPUT_NAME . ': ';
                                    $this->output[] = array('title' => $output_title .' '. $info['title'] . ': ',
                                                      'text' => $xtPrice->xtcFormat($gambioultra_fee, true),
                                                      'value' => $gambioultra_fee);

                      }//end foreach
                                            }
    /*                         
                    $nc_ultra_details .= '<small>';
              foreach ($nc_ultra_data['infos'] as $info)
              {
                    $nc_ultra_details .= '<br />'. $info['title'] .': '. $info['price'];
              }
              $nc_ultra_details .= '</small>';
               
             
                    $output_title  = MODULE_ORDER_TOTAL_GAMBIOULTRA_OUTPUT_NAME . ':';
                    $output_title .= $nc_ultra_details;

                    $this->output[] = array('title' => $output_title,
                                      'text' => $xtPrice->xtcFormat($gambioultra_fee, true),
                                      'value' => $gambioultra_fee);
    */
                 
            }
          }
        }

        function check() {
          if (!isset($this->_check)) {
            $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_GAMBIOULTRA_STATUS'");
            $this->_check = xtc_db_num_rows($check_query);
          }

          return $this->_check;
        }

        function keys() {
          return array('MODULE_ORDER_TOTAL_GAMBIOULTRA_STATUS', 'MODULE_ORDER_TOTAL_GAMBIOULTRA_SORT_ORDER', 'MODULE_ORDER_TOTAL_GAMBIOULTRA_OUTPUT_NAME', 'MODULE_ORDER_TOTAL_GAMBIOULTRA_DETAILS', 'MODULE_ORDER_TOTAL_GAMBIOULTRA_DESTINATION', 'MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS');
        }

        function install() {
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_STATUS', 'true', '6', '1','xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_SORT_ORDER', '31', '6', '2', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_OUTPUT_NAME', 'Sperrgutzuschlag', '6', '2', now())");
                            xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_DETAILS', 'true', '6', '1','xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_DESTINATION', 'both','6', '6', 'xtc_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) values ('MODULE_ORDER_TOTAL_GAMBIOULTRA_TAX_CLASS', '0','6', '7', 'xtc_get_tax_class_title', 'xtc_cfg_pull_down_tax_classes(', now())");
        }

        function remove() {
          xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
      }
    ?>

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #5 am: 10. Oktober 2020, 10:44:39
    Ich konnte nun in einem anderen Modul einen Fehler ausmachen.
    split() wird seit PHP7 ja nicht mehr unterstützt.

    Kann mir jemand helfen folgendes auf PHP7 gängig zu bekommen?

    Code: PHP  [Auswählen]
    $tz_table = split("[:;]" , $tz_cost);

    an dieser Stelle split durch preg_split, explode oder str_split zu ersetzen funktioniert leider nicht.

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #6 am: 10. Oktober 2020, 11:24:58
    Versuch es so

    Code: PHP  [Auswählen]
    $tz_table = preg_split("/[:,]/" , $tz_cost);

    Gruss
    Hanspeter

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #7 am: 11. Oktober 2020, 13:06:07
    Nachtrag:

    oder so

    Code: PHP  [Auswählen]
    $tz_table = preg_split("/[:;]/" , $tz_cost);

    Gruss
    Hanspeter

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #8 am: 12. Oktober 2020, 08:12:24
    Vielen Dank, das hat funktioniert :-)

    Neue ein neues Problem.
    Nach der Umstellung auf PGP 7.1 verschwinden auf einmal die Breadcrumbs aus dem Shop. Alles andere scheint zu funktionieren.
    An dieser Stelle wurden jedoch keinerlei Anpassungen vorgenommen.

    Gibt es hier bei der Version 2.0.2.2 irgendetwas zu beachten?

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #9 am: 21. Oktober 2020, 18:33:45
    Wollte hier nochmal nachhaken ob es eine Idee gibt.
    Verwendet wird das Responsive Template direkt vom Hersteller hier :-)

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #10 am: 21. Oktober 2020, 22:41:48
    Nachtrag: Es fehlen nur auf einigen Seiten die Breadcrumbs. Das merkwürdige ist: sobald wieder PHP5.6 aktiviert wird sind sie wieder da.

    Markus

    • modified Team
    • Beiträge: 1.373
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #11 am: 22. Oktober 2020, 07:59:34

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Problem bei Umstellung von PHP 5.6 auf PHP 7.1
    Antwort #12 am: 22. Oktober 2020, 08:53:24
    11 Antworten
    6912 Aufrufe
    10. September 2015, 12:56:43 von jenni
    2 Antworten
    1591 Aufrufe
    10. September 2017, 12:53:00 von quinti
    26 Antworten
    5199 Aufrufe
    21. Dezember 2019, 18:01:23 von DerNachbar
    20 Antworten
    27291 Aufrufe
    10. März 2016, 10:31:44 von U.H.
               
    anything