PHP 8.2 - Community Input

Open to all! Ask other shopowners for help.
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

The strftime() function has been DEPRECATED as of PHP 8.1.0. Relying on this function is highly discouraged.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: PHP 8.2 - Community Input

Post by burt »

https://github.com/CE-PhoenixCart/Phoen ... ef937b1c02
&
https://github.com/CE-PhoenixCart/Phoen ... b4f00562fc

is the start of PHP8 Compat changes. Note that these changes will (probably) not solve every error, but will help in reducing the number of issues written to error-log (which will obviously make it easier to spot new issues).

In making these commits I opened every page in Phoenix [admin side & shop side] (checking the error_log as I was going along), however I did not perform every option that a page can do (eg "edit", "delete" etc etc).

--

The needed strftime changes will be addressed in a future version of Phoenix.

--

Please continue to post any issues in this thread. TY.
I am not here to build for you.
I am here to build with you. Let's help each other.
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

which changes is right on admin/includes/classes/message_stack.php
adding

Code: Select all

#[\AllowDynamicProperties]
or change line 20 from this

Code: Select all

 class messageStack {
to this

Code: Select all

class messageStack extends \stdClass{
I will post more error soon
Thank you
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: PHP 8.2 - Community Input

Post by burt »

Not this:

extends \stdClass
I am not here to build for you.
I am here to build with you. Let's help each other.
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

admin error file

Code: Select all

 PHP Deprecated:  preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/shop/public_html/admin/includes/functions/html_output.php on line 27
lines 25-35

Code: Select all

  function phoenix_normalize($attributes) {
    $parameters = [];
    foreach (preg_split('{"[^"]*"(*SKIP)(*FAIL)|\s+}', $attributes) as $parameter) {
      $pair = explode('=', $parameter, 2);
      if (!empty($pair[0])) {
        $parameters[$pair[0]] = isset($pair[1]) ? trim($pair[1], '"') : null;
      }
    }

    return $parameters;
  }
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

admin error file

Code: Select all

PHP Deprecated:  substr(): Passing null to parameter #1 ($string) of type string is deprecated in /home/shop/public_html/includes/apps/paypal/OSCOM_PayPal.php on line 238
lines from 221-231

Code: Select all

if ( $type == 'email') {
        return constant('OSCOM_APP_PAYPAL_SANDBOX_SELLER_EMAIL');
      } elseif ( $type == 'email_primary') {
        return constant('OSCOM_APP_PAYPAL_SANDBOX_SELLER_EMAIL_PRIMARY');
      } elseif ( substr($type, 0, 7) == 'payflow' ) {
        return constant('OSCOM_APP_PAYPAL_PF_SANDBOX_' . strtoupper(substr($type, 8)));
      } else {
        return constant('OSCOM_APP_PAYPAL_SANDBOX_API_' . strtoupper($type));
      }
    }

Code: Select all

PHP Deprecated:  Function utf8_encode() is deprecated in /home/shop/public_html/includes/apps/paypal/api/GetBalance.php on line 34
line 33-35

Code: Select all

    foreach ( $params as $key => $value ) {
      $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&';
    }
Last edited by Omar_one on Fri Nov 24, 2023 5:07 pm, edited 1 time in total.
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

admin error file

Code: Select all

 PHP Deprecated:  Function strftime() is deprecated in /home/shop/public_html/includes/system/versioned/1.0.8.3/date.php on line 45
lines from 43-47

Code: Select all

    public function format($format) {
      return $this->timestamp
           ? strftime($format, $this->timestamp)
           : false;
    }
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

admin error file

Code: Select all

PHP Deprecated:  Creation of dynamic property sc_fopen_wrapper::$title is deprecated in /home/shop/public_html/admin/includes/modules/security_check/sc_fopen_wrapper.php on line 19
line 18-20

Code: Select all

  public function __construct() {
      $this->title = MODULE_SECURITY_CHECK_FOPEN_WRAPPER_TITLE;
    }

Code: Select all

PHP Deprecated:  Creation of dynamic property sc_github_directory::$title is deprecated in /home/shop/public_html/admin/includes/modules/security_check/sc_github_directory.php on line 17
line 16-18

Code: Select all

public function __construct() {
      $this->title = MODULE_SECURITY_CHECK_GITHUB_TITLE;
    }
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: PHP 8.2 - Community Input

Post by Omar_one »

shop side error_log file

Code: Select all

PHP Deprecated:  strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /home/shop/public_html/includes/modules/content/header/cm_header_breadcrumb.php on line 87
lines 81-90

Code: Select all

        foreach ($breadcrumb->_trail as $i => $v) {
          $schema_breadcrumb['itemListElement'][] = [
            '@type' => 'ListItem',
            'position' => "$i",
            'item' => [
              '@id' => "{$v['link']}",
              'name' => strip_tags($v['title']),
            ],
          ];
        }

Code: Select all

PHP Deprecated:  strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /home/shop/public_html/includes/modules/header_tags/ht_twitter_product_card.php on line 36
lines 36-39

Code: Select all

 $product_description = substr(trim(preg_replace('{\s\s+}', ' ', strip_tags($product->get('description')))), 0, 197);
          if ( strlen($product_description) == 197 ) {
            $product_description .= ' ..';
          }

Code: Select all

PHP Deprecated:  Creation of dynamic property i_adverts::$advert_width is deprecated in /home/shop/public_html/includes/modules/pi/index/i_adverts.php on line 32
lines 29-34

Code: Select all

      if ( $this->enabled ) {
        $this->group = 'i_modules_' . strtolower(I_ADVERTS_GROUP ?? '');
        $this->content_width = I_ADVERTS_CONTENT_WIDTH;
        $this->advert_width = I_ADVERTS_ADVERT_WIDTH;
      }
    }
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: PHP 8.2 - Community Input

Post by raiwa »

Probably for the first case:

Code: Select all

 strip_tags($v['title']?? '')
And similar for others.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply