Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2019
    Posts
    292
    Plugin Contributions
    0

    Default v1.58a with php 8.1, PHP Warning and PHP Deprecated

    Greetings. My site just upgraded from 1.57d to 1.58a, and upgraded the php version to 8.1 (finally). I received the following warning from the back end over last night. It seems the following warnings are intermittent, not sure how to trigger it.

    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/ask_a_question/header_php.php(57): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "contactname" in public_html/includes/modules/pages/ask_a_question/header_php.php on line 57.

    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/ask_a_question/header_php.php(58): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "email" in public_html/includes/modules/pages/ask_a_question/header_php.php on line 58.

    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/ask_a_question/header_php.php(59): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "telephone" in public_html/includes/modules/pages/ask_a_question/header_php.php on line 59.

    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/ask_a_question/header_php.php(60): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "enquiry" in public_html/includes/modules/pages/ask_a_question/header_php.php on line 60.

    Request URI: /index.php?main_page=checkout_success&action=create_account, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/checkout_success/header_php_guest.php(28): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "email_format" in public_html/includes/modules/pages/checkout_success/header_php_guest.php on line 28.

    Here is my temp solution for the warning above. Change code from

    Code:
        $name = zen_db_prepare_input($_POST['contactname']);
        $email_address = zen_db_prepare_input($_POST['email']);
        $telephone = zen_db_prepare_input($_POST['telephone']);
        $enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));
    To:
    Code:
        $name = zen_db_prepare_input(($_POST['contactname'] ?? ''));
        $email_address = zen_db_prepare_input(($_POST['email'] ?? ''));
        $telephone = zen_db_prepare_input(($_POST['telephone']?? ''));
        $enquiry = zen_db_prepare_input(strip_tags(($_POST['enquiry']?? '')));
    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 public_html/includes/classes/observers/class.google_recaptcha.php(40): zen_debug_error_handler()
    #1 public_html/includes/classes/traits/NotifierManager.php(87): google_recaptcha->update()
    #2 public_html/includes/modules/pages/ask_a_question/header_php.php(64): base->notify()
    #3 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "g-recaptcha-response" in public_html/includes/classes/observers/class.google_recaptcha.php on line 40.

    It is related to google google_recaptcha plug-in. Similarly, change code from

    Code:
    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
    To:

    Code:
    $resp = $recaptcha->verify(($_POST['g-recaptcha-response'] ?? ''), $_SERVER['REMOTE_ADDR']);
    Request URI: /index.php?main_page=checkout_success&action=create_account, IP address: xxxx, Language id 1
    #0 public_html/includes/modules/pages/checkout_success/header_php_guest.php(28): zen_debug_error_handler()
    #1 public_html/index.php(35): require('...')
    --> PHP Warning: Undefined array key "email_format" in public_html/includes/modules/pages/checkout_success/header_php_guest.php on line 28.

    It is related to OPC 2.5.1. Change code from

    Code:
    $email_format = $_POST['email_format'];
    To

    Code:
    $email_format = ($_POST['email_format'] ?? '');
    Request URI: /index.php?main_page=ask_a_question&action=send&pid=9, IP address: xxxx, Language id 1
    #0 [internal function]: zen_debug_error_handler()
    #1 public_html/includes/functions/functions_email.php(720): substr_count()
    #2 public_html/includes/modules/pages/ask_a_question/header_php.php(66): zen_validate_email()
    #3 public_html/index.php(35): require('...')
    --> PHP Deprecated: substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated in public_html/includes/functions/functions_email.php on line 720.

    Change code from

    Code:
    if (substr_count($email,'@') != 1) return false;
    To

    Code:
    if (substr_count(($email ?? ''),'@') != 1) return false;
    If you have a better idea to solve those warnings, please let me know.
    Last edited by njcyx; 6 Jun 2024 at 03:09 PM.

  2. #2
    Join Date
    Apr 2019
    Posts
    292
    Plugin Contributions
    0

    Default Re: v1.58a with php 8.1, PHP Warning and PHP Deprecated

    More warnings and fixes:

    Request URI: /ipn_main_handler.php?type=ec&token=EC-xxxx&PayerID=xxxx, IP address: xxxx, Language id 1
    #0 /includes/classes/OnePageCheckout.php(2379): zen_debug_error_handler()
    #1 /includes/classes/observers/class.checkout_one_observer.php(625): OnePageCheckout->setPayPalAddressCreationBypass()
    #2 /includes/classes/traits/NotifierManager.php(87): checkout_one_observer->update()
    #3 /includes/modules/payment/paypalwpp.php(2165): base->notify()
    #4 /includes/modules/payment/paypalwpp.php(2012): paypalwpp->ec_step2_finish()
    #5 /ipn_main_handler.php(85): paypalwpp->ec_step2()
    --> PHP Warning: Undefined array key "address_format_id" in /includes/classes/OnePageCheckout.php on line 2379.

    Change from
    Code:
    $this->tempAddressValues['ship']['format_id'] = $country_info['address_format_id'];
    to
    Code:
    $this->tempAddressValues['ship']['format_id'] = ($country_info['address_format_id'] ?? '');
    PHP Warning: Undefined array key "languages_id" in /includes/extra_configures/enable_error_logging.php on line 84

    Change from
    Code:
    $language_info = ', Language id ' . $_SESSION['languages_id'];
    to
    Code:
    $language_info = ', Language id ' . ($_SESSION['languages_id'] ?? '');

    Request URI: /ipn_main_handler.php, IP address: xxxx, Language id
    #0 /includes/modules/payment/paypal/paypal_functions.php(48): zen_debug_error_handler()
    #1 /includes/init_includes/init_paypal_ipn_sessions.php(34): ipn_get_stored_session()
    #2 /includes/autoload_func.php(40): require_once('/...')
    #3 /includes/application_top.php(237): require('/...')
    #4 /ipn_main_handler.php(141): require('/...')
    --> PHP Warning: Undefined array key 1 in /includes/modules/payment/paypal/paypal_functions.php on line 48.
    and
    --> PHP Warning: Undefined array key 1 in /includes/modules/payment/paypal/paypal_functions.php on line 55.

    Change from (based on version 1.5.8a, only one spot needs to be changed)
    Code:
    if (!is_array($session_stuff)) {
    to (referring to version 2.0.0rc-1)
    Code:
    if (!is_array($session_stuff) || !isset($session_stuff[1])) {
    Request URI: /ipn_main_handler.php, IP address: xxxx, Language id
    #0 [internal function]: zen_debug_error_handler()
    #1 /includes/classes/db/mysql/query_factory.php(177): mysqli_real_escape_string()
    #2 /includes/classes/db/mysql/query_factory.php(562): queryFactory->prepare_input()
    #3 /includes/classes/db/mysql/query_factory.php(513): queryFactory->getBindVarValue()
    #4 /includes/modules/payment/paypal/paypal_functions.php(48): queryFactory->bindVars()
    #5 /includes/init_includes/init_paypal_ipn_sessions.php(34): ipn_get_stored_session()
    #6 /includes/autoload_func.php(40): require_once('/...')
    #7 /includes/application_top.php(237): require('/...')
    #8 /ipn_main_handler.php(141): require('/...')
    --> PHP Deprecated: mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated in /includes/classes/db/mysql/query_factory.php on line 177.

    Change from
    Code:
    return mysqli_real_escape_string($this->link, $string);
    To
    Code:
    return mysqli_real_escape_string($this->link, ($string ?? ''));
    Request URI: /index.php?main_page=checkout_process, IP address: xxxx, Language id 1
    #0 /includes/modules/payment/paypaldp.php(1989): zen_debug_error_handler()
    #1 /includes/modules/payment/paypaldp.php(966): paypaldp->_errorHandler()
    #2 /includes/classes/payment.php(288): paypaldp->before_process()
    #3 /includes/modules/checkout_process.php(98): payment->before_process()
    #4 /includes/modules/pages/checkout_process/header_php.php(13): require('/...')
    #5 /index.php(35): require('/...')
    --> PHP Warning: Undefined variable $error_occurred in /includes/modules/payment/paypaldp.php on line 1989.

    Referring link: https://github.com/zencart/zencart/pull/1089/files

    Change from:

    Code:
    $this->_doDebug('PayPal Error Log - before_process() - DP', "In function: before_process() - Direct Payment \r\nDid first contact attempt return error? " . ($error_occurred ? "Yes" : "No") . " \r\n\r\nValue List:\r\n" . str_replace('&',"\r\n", urldecode($doPayPal->_sanitizeLog($doPayPal->_parseNameValueList($doPayPal->lastParamList)))) . "\r\n\r\nResponse:\r\n" . urldecode(print_r($response, true)));
    To:

    Code:
    $this->_doDebug('PayPal Error Log - before_process() - DP', "In function: before_process() - Direct Payment \r\n\r\nValue List:\r\n" . str_replace('&',"\r\n", urldecode($doPayPal->_sanitizeLog($doPayPal->_parseNameValueList($doPayPal->lastParamList)))) . "\r\n\r\nResponse:\r\n" . urldecode(print_r($response, true)));
    Request URI: /admin/index.php?cmd=specials&search=xxxx&sID=xxxx, IP address: xxxx, Language id 1
    #0 /admin/specials.php(452): zen_debug_error_handler()
    #1 /admin/index.php(11): require('/...')
    --> PHP Warning: Undefined array key "page" in /admin/specials.php on line 452.

    Request URI: /admin/index.php?cmd=salemaker&action=insert, IP address: xxxx, Language id 1
    #0 /admin/salemaker.php(97): zen_debug_error_handler()
    #1 /admin/index.php(11): require('/...')
    --> PHP Warning: Undefined array key "page" in /admin/salemaker.php on line 97.

    Similar fix. Change from
    Code:
    zen_redirect(zen_href_link(FILENAME_SALEMAKER, 'page=' . $_GET['page'] . '&sID=' . $_POST['sID']));
    to
    Code:
    zen_redirect(zen_href_link(FILENAME_SALEMAKER, 'page=' . ($_GET['page'] ?? '') . '&sID=' . $_POST['sID']));
    Last edited by njcyx; 11 Jun 2024 at 10:05 PM.

 

 

Similar Threads

  1. Replies: 9
    Last Post: 16 Feb 2024, 06:20 PM
  2. v157 PHP Deprecated: strstr() in zones.php
    By Philibel in forum Bug Reports
    Replies: 1
    Last Post: 18 Feb 2022, 10:12 PM
  3. v157 FedEx Module Version 1.5.4, PHP Warning and Deprecated error in logs
    By Mattie C in forum Addon Shipping Modules
    Replies: 3
    Last Post: 12 Aug 2020, 11:58 PM
  4. Replies: 4
    Last Post: 17 Jul 2015, 04:44 AM
  5. Replies: 2
    Last Post: 21 Aug 2010, 09:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR