Skip to content

Plugin Prioritizing(SortOrder) #9297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gionkoch opened this issue Apr 18, 2017 · 3 comments
Closed

Plugin Prioritizing(SortOrder) #9297

gionkoch opened this issue Apr 18, 2017 · 3 comments
Labels
bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@gionkoch
Copy link

The SortOrder Property of a Plugin(Interceptor) doesn't seem to work properly. The sortOrder isn't taken into account or not how it should according to the Documentation.

Preconditions

  1. Magento CE 2.1.0
  2. PHP 7.0.8
  3. Nginx 1.10.1

Steps to reproduce

  1. Create two plugins for the same class with sortOrder="10" for PluginA and sortOrder="20" for PluginB
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<type name="\Magento\Customer\Controller\Account\Logout">
		<plugin name="Vendor_Module_PluginA" type="\Vendor\ModuleA\Plugin\LogoutPlugin" sortOrder="10" />
	</type>
</config>

and

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<type name="\Magento\Customer\Controller\Account\Logout">
		<plugin name="Vendor_Module_PluginB" type="\Vendor\ModuleB\Plugin\LogoutPlugin" sortOrder="20" />
	</type>
</config>
  1. Use after as interceptor for the method

Expected result

  1. The code of PluginA should be executed after PluginB

Actual result

  1. The code of PluginB is executed after PluginA
@DavidLambauer
Copy link
Contributor

Do I missunderstand the docs or does it says

Following the execution of the observed method, plugins will be executed from greatest to lowest sortOrder.

This means, Plugins with the execution after will be executed from greatest to lowest. Therefore the behavior would be correct.

@gionkoch
Copy link
Author

Do I missunderstand the docs or does it says

Following the execution of the observed method, plugins will be executed from greatest to lowest sortOrder.

This means, Plugins with the execution after will be executed from greatest to lowest. Therefore the behavior would be correct.

The behaviour does not work correctly.
Plugin A has sortOrder 10, while Plugin B has sortOrder 20. Therefore PluginA::afterXYZ() should be executed after PluginB::afterXYZ().
But currently PluginB::afterXYZ() is, on the contrary to the documentation, executed last.

@magento-engcom-team magento-engcom-team added 2.1.x bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch labels Oct 4, 2017
@magento-engcom-team
Copy link
Contributor

@gionkoch, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

magento-devops-reposync-svc pushed a commit that referenced this issue Oct 21, 2024
[Arrows]:Update Coding Standard in CE and EE composer and Widget category tree is not rendered correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

4 participants