Opened 2 years ago
Last modified 2 years ago
#62314 assigned enhancement
Infinite callback loop when 'priority' is not numeric in php 8.x
| Reported by: | mzou23 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Cron API | Version: | 6.6.2 |
| Severity: | minor | Keywords: | changes-requested has-patch |
| Cc: | Focuses: | php-compatibility |
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.
2 years ago
#1
- Keywords has-patch added
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
See: https://core.trac.wordpress.org/ticket/62314
Trac ticket: