Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] Fix sorting bug in sorting of tagged services by priority #45399

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

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected function sortTaggedServicesByPriority(array $services): array
{
$maxPriority = [];
foreach ($services as $service => $tags) {
$maxPriority[$service] = 0;
$maxPriority[$service] = \PHP_INT_MIN;
foreach ($tags as $tag) {
$currentPriority = $tag['priority'] ?? 0;
if ($maxPriority[$service] < $currentPriority) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public static function getContainerDefinitionsWithPriorityTags()
$definition1 = new Definition('Full\\Qualified\\Class1');
$definition2 = new Definition('Full\\Qualified\\Class2');
$definition3 = new Definition('Full\\Qualified\\Class3');
$definition4 = new Definition('Full\\Qualified\\Class4');

return [
'definition_1' => $definition1
Expand Down Expand Up @@ -199,6 +200,13 @@ public static function getContainerDefinitionsWithPriorityTags()
->setAbstract(false)
->addTag('tag1', ['attr1' => 'val1', 'attr2' => 'val2', 'priority' => 0])
->addTag('tag1', ['attr3' => 'val3', 'priority' => 40]),
'definition_4' => $definition4
->setPublic(true)
->setSynthetic(true)
->setFile('/path/to/file')
->setLazy(false)
->setAbstract(false)
->addTag('tag1', ['priority' => 0]),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@
}
]
},
"definition_4": {
"class": "Full\\Qualified\\Class4",
"public": true,
"synthetic": true,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autoconfigure": false,
"file": "\/path\/to\/file",
"tags": [
{
"name": "tag1",
"parameters": {
"priority": 0
}
}
]
},
"definition_2": {
"class": "Full\\Qualified\\Class2",
"public": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ Definitions
- Attr2: val2
- Tag: `tag2`

### definition_4

- Class: `Full\Qualified\Class4`
- Public: yes
- Synthetic: yes
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autoconfigured: no
- File: `/path/to/file`
- Tag: `tag1`
- Priority: 0

### definition_2

- Class: `Full\Qualified\Class2`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
" val1 val2 0
definition_1 val1 30 Full\Qualified\Class1
" val2
definition_4 0 Full\Qualified\Class4
definition_2 val1 val2 -20 Full\Qualified\Class2
-------------- ------- ------- ---------- ------- -----------------------

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
<tag name="tag2"/>
</tags>
</definition>
<definition id="definition_4" class="Full\Qualified\Class4" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<tags>
<tag name="tag1">
<parameter name="priority">0</parameter>
</tag>
</tags>
</definition>
<definition id="definition_2" class="Full\Qualified\Class2" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<tags>
<tag name="tag1">
Expand Down