Deprecated: Creation of dynamic property

#909226
  • Resolved Ozair Webs
    Rank Math free

    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 the urlNotificationMetadata propertyin 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.

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    We aren’t able to reproduce this error from our end.

    Please head over to your WP Dashboard > Rank Math > Status & Tools > System Status and click the “Copy System Info to Clipboard” button, and paste it here so we can further analyze the issue.

    Looking forward to hearing back from you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Deprecated: Creation of dynamic property’ is closed to new replies.