[FIX] dev:di:info duplicates plugin info#16474
[FIX] dev:di:info duplicates plugin info#16474magento-engcom-team merged 2 commits intomagento:2.2-developfrom coderimus:fix/dev-di-info-duplicated-info
Conversation
|
Hi @coderimus. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
| $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = []; | ||
| $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod; | ||
| } | ||
| $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod ; |
There was a problem hiding this comment.
$this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod ; ->
$this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][$pluginMethod] = 1
Please avoid duplication by reversing array. Please check if it is possible to remove if while avoiding PHP notice.
| $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = []; | ||
| } | ||
|
|
||
| if (!in_array($pluginMethod, $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance])) { |
There was a problem hiding this comment.
Hi @orlangur ,
What do you think about this modification? I implemented this second condition just because it looks like a cheapest and still technologically possible solution. Also, this method is totally isolated and used only for this command.
There was a problem hiding this comment.
Too wordy and not elegant as to me but still good enough :) Asymptotic complexity became poor but should not be noticeable.
Good job with tiniest possible diff 👍
|
Hi @orlangur, thank you for the review. |
|
Hi @coderimus. Thank you for your contribution. Please, consider to port this solution to 2.3 release line. |
Description
Hello,
Looks like the execution of
dev:di:infoduplicates info about plugins by for the or the Preference if the same plugin class and its type were introduced in plugins by class name section.For example, execute

php bin/magento dev:di:info "Magento\Sales\Model\Order"and the output result will bewith provided fix it will look like this
The problem is seems to be in this method:
It checks whether value exists in array or not. And if it exists it will be added +1 time. But it may logically to add an item once if it not exists.
Fixed Issues (if relevant)
N/A
Manual testing scenarios
execute
dev:di:infocommand for class and check "Plugins for the Preference:" section. Seems to have duplicated info.Contribution checklist