[wp-trac] [WordPress Trac] #54323: Too few arguments for function (closure)
WordPress Trac
noreply at wordpress.org
Wed Oct 27 17:20:22 UTC 2021
#54323: Too few arguments for function (closure)
-------------------------------------------------+-------------------------
Reporter: aristath | Owner:
| SergeyBiryukov
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.8.2
Component: Script Loader | Version:
Severity: major | Resolution:
Keywords: has-patch needs-unit-tests fixed- | Focuses: coding-
major | standards
-------------------------------------------------+-------------------------
Comment (by SergeyBiryukov):
Replying to [comment:3 jrf]:
> Two questions/remarks which are not directly related to this PR, but are
related to this code snippet:
> 1. Why is a closure being used here ? Closures can not be "unhooked", so
should never be used as a callback function in Core.
Thanks for bringing this up! Just noting that there was previously some
discussion on this in comment:9:ticket:53616. Per @aristath:
> This was also mentioned prior to merging the PR, in
https://github.com/WordPress/wordpress-
develop/pull/1482#pullrequestreview-704072508
> However, it was deemed acceptable because in this scenario, the
anonymous function enqueues a stylesheet and doesn't do anything else:
>> plugins can still just run `wp_dequeue_style` to remove the styles.
Since they can remove the styles, removing the hook itself seemed
inconsequential.
> 2. Why was this not caught be unit tests ? Or to rephrase: might it be a
good idea to add some unit tests covering this functionality ?
It would definitely be a great idea, looks like there are no tests for
`enqueue_block_styles_assets()` yet. The original changesets, [46111] and
[51471], did not have any tests either.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54323#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list