Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#54367 closed defect (bug) (duplicate)

Remove closure hooked to `render_block` within `enqueue_block_styles_assets()`

Reported by: desrosj's profile desrosj Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.8.1
Component: Script Loader Keywords:
Focuses: Cc:

Description

Follow up to #54323.

The core standard is to avoid using anonymous functions for filter and action hook callbacks. One was added in [51471], but it should be converted to a normal function.

Change History (4)

#1 follow-up: @jrf
2 years ago

If it helps, I can do a scan of the complete src to check if any others may have slipped in.

#2 in reply to: ↑ 1 ; follow-up: @SergeyBiryukov
2 years ago

Replying to jrf:

If it helps, I can do a scan of the complete src to check if any others may have slipped in.

Yes, please! As noted in comment:8:ticket:54323, there are at least two other instances added in [51902].

#3 in reply to: ↑ 2 @jrf
2 years ago

Replying to SergeyBiryukov:

Replying to jrf:

If it helps, I can do a scan of the complete src to check if any others may have slipped in.

Yes, please! As noted in comment:8:ticket:54323, there are at least two other instances added in [51902].

Here you go (scanned with a draft/unfinished sniff I have locally, but which isn't in WPCS yet):

FILE: src\wp-admin\edit-form-blocks.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 34 | ERROR | Using a closure as the callback for add_filter() is forbidden as
    |       | unhooking it is nearly impossible (at this time - see trac ticket
    |       | 46635)
--------------------------------------------------------------------------------


FILE: src\wp-admin\includes\class-wp-upgrader.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  854 | ERROR | Using a closure as the callback for add_action() is forbidden
      |       | as unhooking it is nearly impossible (at this time - see trac
      |       | ticket 46635)
  876 | ERROR | Using a closure as the callback for add_action() is forbidden
      |       | as unhooking it is nearly impossible (at this time - see trac
      |       | ticket 46635)
 1135 | ERROR | Using a closure as the callback for add_action() is forbidden
      |       | as unhooking it is nearly impossible (at this time - see trac
      |       | ticket 46635)
--------------------------------------------------------------------------------


FILE: src\wp-admin\options-privacy.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 23 | ERROR | Using a closure as the callback for add_filter() is forbidden as
    |       | unhooking it is nearly impossible (at this time - see trac ticket
    |       | 46635)
--------------------------------------------------------------------------------


FILE: src\wp-admin\privacy-policy-guide.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 22 | ERROR | Using a closure as the callback for add_filter() is forbidden as
    |       | unhooking it is nearly impossible (at this time - see trac ticket
    |       | 46635)
--------------------------------------------------------------------------------


FILE: src\wp-includes\script-loader.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 2469 | ERROR | Using a closure as the callback for add_filter() is forbidden
      |       | as unhooking it is nearly impossible (at this time - see trac
      |       | ticket 46635)
--------------------------------------------------------------------------------


FILE: src\wp-includes\sitemaps\class-wp-sitemaps-renderer.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 256 | ERROR | Using a closure as the callback for add_filter() is forbidden as
     |       | unhooking it is nearly impossible (at this time - see trac
     |       | ticket 46635)
--------------------------------------------------------------------------------

#4 @hellofromTonya
2 years ago

  • Milestone 5.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#54028 was previously opened for using closure as a callback to the Hooks API. Closing this ticket as duplicate to move the effort to one ticket.

Note: See TracTickets for help on using tickets.