Deprecation warning for creation of dynamic property

Created on 26 October 2023, about 1 year ago
Updated 21 February 2024, 10 months ago

Problem/Motivation

A deprecation warning is triggered on any page load when using the module in D10 and PHP8.2;

Deprecated function: Creation of dynamic property Drupal\twitter_profile_widget\EventSubscriber\TwitterWidgetSubscriber::$cacheContextsManager is deprecated in Drupal\twitter_profile_widget\EventSubscriber\TwitterWidgetSubscriber->__construct() (line 86 of modules/contrib/twitter_profile_widget/src/EventSubscriber/TwitterWidgetSubscriber.php).

Steps to reproduce

Install module and load any Drupal admin page with deprecation warnings enabled. It will show the warning.

Proposed resolution

Seems like the cache context manager is assigned to the wrong property since there is a cacheContexts property with the right type that is not being used in this class. Assigning the cache context manager value to the cacheContexts property fixes the issue.

Remaining tasks

Review and test.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands sanderjonk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sanderjonk
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    Composer require failure
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Thanks for reporting this!

    The proposed change will resolve the deprecation notice, but I suggest a slightly different modification for the same goal: since the class that this object is invoking is Drupal\Core\Cache\Context\CacheContextsManager, I think it makes more sense to change the property name to cacheContextsManager

  • Status changed to RTBC 10 months ago
  • πŸ‡§πŸ‡ͺBelgium zero2one

    I can confirm that patch #2 fixes the deprecation warning.

Production build 0.71.5 2024