Repository navigation
Commit 05c489b
Run equal-priority hooks from different classes in the order added
When static hooks from different classes for the same method had equal
priority (i.e. the default 100), getHooks() merged them class by class
and the class merged last took the base priority key. The run order of
such hooks therefore depended only on which class first had any static
hook. For example, an after hook to User::viewable added from ready.php
could run before PagePermissions' Page::viewable hook that provides the
viewable() method, so it saw a null return value and its result was then
overwritten.
Each hook now has a sequence number assigned when added. When hooks from
multiple sources are merged, they are sorted by priority, then (for equal
priority) static hooks before local hooks as before, then in the order
added. Ordering of hooks within a single class and method is unchanged.
Adds WireHooks tests for a subclass after hook to a hook-provided method
and for equal-priority ordering between parent class, subclass and local
hooks.
Reported in processwire/processwire-issues#2011
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent d4dbc13 commit 05c489b
2 files changed
Lines changed: 67 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
188 | 199 | | |
189 | 200 | | |
190 | 201 | | |
| |||
307 | 318 | | |
308 | 319 | | |
309 | 320 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
319 | 327 | | |
320 | 328 | | |
321 | 329 | | |
| |||
335 | 343 | | |
336 | 344 | | |
337 | 345 | | |
338 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
339 | 353 | | |
340 | | - | |
| 354 | + | |
341 | 355 | | |
342 | 356 | | |
343 | 357 | | |
| |||
819 | 833 | | |
820 | 834 | | |
821 | 835 | | |
822 | | - | |
| 836 | + | |
823 | 837 | | |
| 838 | + | |
824 | 839 | | |
825 | 840 | | |
826 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
171 | 208 | | |
172 | 209 | | |
173 | 210 | | |
| |||
284 | 321 | | |
285 | 322 | | |
286 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
0 commit comments