Update wp-background-process.php to use wp_convert_hr_to_bytes() (#30908)

Update wp-background-process.php to use wp_convert_hr_to_bytes()

Currently the code is typecasting the memory limit to an int. This assumes that the memory limit is in MB, so if you set your memory limit to 4G this will return 4194304 bytes (4.19304 MB.) Instead, we should use the native WordPress function `wp_convert_hr_to_bytes` to handle the conversion into bytes correctly.
This commit is contained in:
Noonan Web Group Limited 2022-07-05 03:23:52 +01:00 committed by GitHub
parent 9cecce207a
commit 538403306c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
`WP_Background_Process` updated to work nicely with memory_limits expressed in units other than 'M'.

View File

@ -370,7 +370,7 @@ abstract class WP_Background_Process extends WP_Async_Request {
$memory_limit = '32000M';
}
return intval( $memory_limit ) * 1024 * 1024;
return wp_convert_hr_to_bytes( $memory_limit );
}
/**