Opened 6 weeks ago
Last modified 6 weeks ago
#62314 assigned enhancement
Infinite callback loop when 'priority' is not numeric in php 8.x
Reported by: | mzou23 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | 6.6.2 |
Component: | Cron API | Keywords: | changes-requested has-patch |
Focuses: | php-compatibility | Cc: |
Description
The behavior of min(array) has changed in php 8.x. Prior to php 8,
min(array('a', 1,2,3))
returns 'a'. In php 8.x, it returns 1.
This has some unexpected effects on wordpress filters. The following code
function test_action() { add_action( 'admin_enqueue_scripts', function(){}, 'a');} add_action( 'admin_enqueue_scripts', 'test_action' , 10);
which works on php 7, will result in an infinite loop on php 8.x. Strictly speaking, this is not a bug, as using 'a' instead of a numeric value for priority is incorrect. However, wordpress does not complain its use.
Here is a simple fix. Add a check in wp-includes/class-wp-hook.php, on line 83. Either change the priority to a numeric value or barf and bail out. I think something like
if( ! is_numeric($priority) ) $priority = 10;
will be safe.
Change History (2)
This ticket was mentioned in PR #7665 on WordPress/wordpress-develop by zbtirrell.
6 weeks ago
#1
- Keywords has-patch added
See: https://core.trac.wordpress.org/ticket/62314
Trac ticket: