-
Found the followign error in debug log file in wp-content folder: Im using 8.2 Php Version
[10-Nov-2024 08:07:31 UTC] PHP Deprecated: Creation of dynamic property Google\Service\Indexing\PublishUrlNotificationResponse::$urlNotificationMetadata is deprecated in /home/u677991802/domains/governmentjob.pk/public_html/wp-content/plugins/fast-indexing-api/vendor/google/apiclient/src/Model.php on line 120
The error in your WordPress debug log is related to PHP’s deprecation of dynamically creating properties on objects. This is because the code is attempting to assign a property that hasn’t been explicitly declared in the class definition.
The specific issue arises in this line of your file:
Google\Service\Indexing\PublishUrlNotificationResponse::$urlNotificationMetadata
Dynamic property creation has been deprecated starting with PHP 8.2. To fix this, you need to declare the property in the class explicitly.
Let’s locate and examine the line mentioned in the error (line 120) to make a proper fix.
The issue lies in the use of $this->$key = $val;, which dynamically creates properties in the object when they are not explicitly declared in the class. This behavior is deprecated in PHP 8.2.
To fix this:
Explicitly declare the property in the class.
Alternatively, use a protected or public array to store dynamic properties if necessary.
I’ll check the class definition at the beginning of the file to confirm where to declare these properties properly. The class Model defines several protected properties like $internal_gapi_mappings, $modelData, and $processed. However, it does not explicitly declare the property urlNotificationMetadata, which is dynamically created later in the code, causing the deprecation warning.
Fix
To resolve the issue, you can explicitly declare theurlNotificationMetadata property
in the class. Here’s how the class should be updated:protected $urlNotificationMetadata;
This line should be added alongside the other protected properties near the top of the class.
The ticket ‘Deprecated: Creation of dynamic property’ is closed to new replies.