Skip to content

fix: Do not sort listeners differently depending on their type - #162

Merged
provokateurin merged 1 commit into
sabre-io:masterfrom
come-nc:fix/sort-array-and-closure-the-same
Jul 6, 2026
Merged

fix: Do not sort listeners differently depending on their type#162
provokateurin merged 1 commit into
sabre-io:masterfrom
come-nc:fix/sort-array-and-closure-the-same

Conversation

@come-nc

@come-nc come-nc commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

With array_multisort, when priority is the same it would fallback to comparing values, and PHP will sort Closures after array callables.
This is not something we want as it means turning an array callable into a Closure would potentially change its order, leading to unexpected side-effects.

I did not check the code for other uses of array_multisort.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.17%. Comparing base (4b7418f) to head (59fbd33).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #162      +/-   ##
============================================
- Coverage     99.18%   99.17%   -0.01%     
  Complexity      111      111              
============================================
  Files             7        7              
  Lines           367      364       -3     
============================================
- Hits            364      361       -3     
  Misses            3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

With array_multisort, when priority is the same it would fallback to
 comparing values, and PHP will sort Closures after array callables.
This is not something we want as it means turning an array callable into
 a Closure would potentially change its order, leading to unexpected
 side-effects.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc force-pushed the fix/sort-array-and-closure-the-same branch from 7830d23 to 59fbd33 Compare July 6, 2026 12:38
@provokateurin
provokateurin merged commit 2996366 into sabre-io:master Jul 6, 2026
4 checks passed
@provokateurin provokateurin changed the title fix: Do no sort listeners differently depending on their type fix: Do not sort listeners differently depending on their type Jul 6, 2026
@clxmstaab

Copy link
Copy Markdown

would be great this change would be covered by a test-case

phil-davis added a commit to phil-davis/event that referenced this pull request Jul 14, 2026
This tests the change in sabre-io#162 that makes sure not to sort listeners
that are of equal priority, but to preserve the order in which they
were created.

Signed-off-by: Phillip Davis <phil@jankaritech.com>
@phil-davis

Copy link
Copy Markdown
Contributor

would be great this change would be covered by a test-case

See #172

phil-davis added a commit that referenced this pull request Jul 14, 2026
This tests the change in #162 that makes sure not to sort listeners
that are of equal priority, but to preserve the order in which they
were created.

Signed-off-by: Phillip Davis <phil@jankaritech.com>
phil-davis added a commit that referenced this pull request Jul 14, 2026
This tests the change in #162 that makes sure not to sort listeners
that are of equal priority, but to preserve the order in which they
were created.

Signed-off-by: Phillip Davis <phil@jankaritech.com>
@staabm

staabm commented Jul 14, 2026

Copy link
Copy Markdown
Member

awesome - thank you @phil-davis

accidentally posted the above comment with my 2nd account ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants