PHP Deprecated: Creation of dynamic property ups::$quotes
Hello All,
Running ZC 1.5.8a on php8.2.4. The UPS shipping module is causing a TON of depreciation logs.
PHP Deprecated: Creation of dynamic property ups::$quotes
PHP Deprecated: Creation of dynamic property ups::$_upsActionCode is deprecated
PHP Deprecated: Creation of dynamic property ups::$_upsResComCode
etc...
Is there a solution for this?
Thank you,
John
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Or use PHP 8.1 until this is fixed.
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Since the module still works, is it possible to suppress depreciation logs related to UPS?
Thanks again,
John
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
PHP 8.2 did away with log suppression and the deprecated issues with the ups.php shipping method are due to those class-based variables not being predefined.
You could go through each of the $this->varname usages in the module and make sure that each variable is predefined within the class,
e.g.
Code:
class ups {
public
$quotes; // needs to be public
protected
$_upsActionCode,
$_upsResComCode;
}
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
So that is working... sort of. I just copied and pasted in your example like so...
class ups extends base {
public
$quotes; // needs to be public
protected
$_upsActionCode,
$_upsResComCode;
This works, but when I add to the protected list $_upsPackageWeight it breaks. Clearly i'm no good working in classes. I'm going to keep at it though and see if i can figure out where these need to be added.
Thanks again,
John
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
GOT IT! Well so far... lol. I was making each protected $_var; instead of $_var, ... always with the punctuation. ;) Thank you very much.
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Congratulations on the update! Happy to have helped.
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Quote:
Originally Posted by
lat9
PHP 8.2 did away with log suppression
Where is that documented? Php 8.0 removed suppression of error type messages, but not all suppression. See this portion of the php manual: https://www.php.net/manual/en/langua...rorcontrol.php
Quote:
Originally Posted by
lat9
the deprecated issues with the ups.php shipping method are due to those class-based variables not being predefined.
Which can be "temporarily" allowed without associated dynamic property log generation by using:
#[\AllowDynamicProperties]
As described: https://www.php.net/manual/en/class....properties.php
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Thanks for the clarification, @mc12345678. For any PHP deprecation, though, it's best to address the issue before the deprecation turns into an error.
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Quote:
Originally Posted by
mc12345678
mc...Can you provide additional detail? Placing #[\AllowDynamicProperties] just before the class declaration doesn't seem to help me. Is there anything else that needs to be done to temporarily kill the error messages? My webhost went from PHP 8.0 to 8.2 and I'm getting tons of error logs associated with this problem in the query_factory class. I'm in zc 1.5.7c and not quite ready to deploy 1.5.8a.
Sample log:
[16-Feb-2024 17:18:38 America/New_York] Request URI: /index.php?main_page=index, IP address: xxx
#0 /domain/includes/classes/db/mysql/query_factory.php(586): zen_debug_error_handler()
#1 /domain/includes/classes/db/mysql/query_factory.php(202): queryFactoryResult->__construct()
#2 /domain/includes/init_includes/init_database.php(52): queryFactory->Execute()
#3 /domain/includes/application_top.php(189): require('/...')
#4 /domain/index.php(25): require('/...')
--> PHP Deprecated: Creation of dynamic property queryFactoryResult::$link is deprecated in /domain/includes/classes/db/mysql/query_factory.php on line 586.
Thank you.
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Quote:
Originally Posted by
Dave224
mc...Can you provide additional detail? Placing #[\AllowDynamicProperties] just before the class declaration doesn't seem to help me. Is there anything else that needs to be done to temporarily kill the error messages? My webhost went from PHP 8.0 to 8.2 and I'm getting tons of error logs associated with this problem in the query_factory class. I'm in zc 1.5.7c and not quite ready to deploy 1.5.8a.
Sample log:
[16-Feb-2024 17:18:38 America/New_York] Request URI: /index.php?main_page=index, IP address: xxx
#0 /domain/includes/classes/db/mysql/query_factory.php(586): zen_debug_error_handler()
#1 /domain/includes/classes/db/mysql/query_factory.php(202): queryFactoryResult->__construct()
#2 /domain/includes/init_includes/init_database.php(52): queryFactory->Execute()
#3 /domain/includes/application_top.php(189): require('/...')
#4 /domain/index.php(25): require('/...')
--> PHP Deprecated: Creation of dynamic property queryFactoryResult::$link is deprecated in /domain/includes/classes/db/mysql/query_factory.php on line 586.
Thank you.
You say or reference the query_class, but that file has two classes declared in it, the reported issue is with the class towards the bottom of the file which is the queryFactoryResult class.
It is my understanding though I haven't again gone to test this, that the alliance to add dynamic properties is a power class allowance not a first at top of file allowance. Otherwise, one could add it to the first of many files loaded to assemble the store and it would apply across all. That to would complicate troubleshooting and development if the single inclusion applied to all of the code.
Of course upgrading to the latest software, downgrading the php version, and then other code changes might be a reasonable sequence to how to approach resolution of a significant number of different deported issues. For one that is breweries reported, the fix should be simple (famous last words).
Re: PHP Deprecated: Creation of dynamic property ups::$quotes
Quote:
Originally Posted by
Dave224
My webhost went from PHP 8.0 to 8.2 and I'm getting tons of error logs associated with this problem
One of the things that's getting more and more strict in ongoing PHP versions is this issue of creating variables on-the-fly without first declaring them (by stating they exist or giving them a value).
You're going to find a number of places where that's been happening, because prior to PHP was actually built to intentionally allow that. So that's why you see a lot of original Zen Cart code doing that.
Part of the reason for PHP getting more strict about this stuff is that it helps make it run faster and manage memory better. It also makes PHP more like "other" languages, for better or for worse.
In short, if you're staying on v1.5.7 then you'll need to downgrade your PHP version as well.