Problem/Motivation
I'm seeing,
Deprecated function: Creation of dynamic property Drupal\queue_stats\Plugin\QueueStatistic\EstimatedTimeToFinish::$container is deprecated in Drupal\queue_stats\Plugin\QueueStatistic\EstimatedTimeToFinish->__construct() (line 47 of modules/composer/queue_stats/src/Plugin/QueueStatistic/EstimatedTimeToFinish.php).
Steps to reproduce
I'm seeing this when using migrate_preview module to preview a migration, but the dependency injection needs to be fixed in any case.
Proposed resolution
Instead of passing the container object from create() to __construct() and then using that to obtain the plugin.manager in getValue(), get the plugin.manager in create() and pass that.
Remaining tasks
make a MR.
Issue fork queue_stats-3558615
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3558615-dependency-injection
changes, plain diff MR !5
Comments
Comment #2
benstallings commentedComment #4
benstallings commentedComment #5
benstallings commentedUpon further investigation, this seems to result in a circular reference. Someone who has a better grasp on the code should take a look.
Comment #6
benstallings commentedComment #7
achtonThanks for reporting this and for the merge request. Your circular reference finding was the key:
QueueStatisticManagercreated every statistic plugin in its constructor, so a plugin that gets the manager injected asks for a service that is still being built. #3434069: Automated Drupal 11 compatibility fixes for queue_stats fixes it by creating the plugins on first use. It includes the dependency injection from this issue and yourreturn 0;, and you are credited there. Closing as a duplicate.Comment #8
achton