• Resolved al3ilm

    (@al3ilm)


    Hello Support Team,

    I am experiencing an issue with the Jetpack Boost plugin related to the file functions-helpers.php located in the /app/lib/minify/ directory. The error log displays the following message:

    [18-Feb-2025 03:40:26 UTC] PHP Fatal error:  Uncaught TypeError: Unsupported operand types: int - string in /home/***/public_html/wp-content/plugins/jetpack-boost/app/lib/minify/functions-helpers.php:76
    Stack trace:
    #0 /home/***/public_html/wp-content/plugins/jetpack-boost/app/lib/minify/functions-helpers.php(32): jetpack_boost_delete_expired_files(Array, '/home/mfkvhsiie...')
    #1 /home/***/public_html/wp-includes/class-wp-hook.php(324): jetpack_boost_legacy_minify_cache_cleanup('/home/mfkvhsiie...')
    #2 /home/***/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
    #3 /home/***/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
    #4 /home/***/public_html/wp-cron.php(191): do_action_ref_array('jetpack_boost_m...', Array)
    #5 {main}
      thrown in /home/***/public_html/wp-content/plugins/jetpack-boost/app/lib/minify/functions-helpers.php on line 76
    

    It appears that the error occurs because there is an attempt to subtract a string from an integer. The original code is as follows:

    if ( ( time() - $file_age ) > fileatime( $file ) ) {
        wp_delete_file( $file );
    } elseif ( ( time() - ( 2 * $file_age ) ) > filemtime( $file ) ) {
        wp_delete_file( $file );
    }
    

    The problem arises because the variable $file_age is not explicitly cast as a numeric value before the arithmetic operation, leading to a type error when its value is not purely numeric.

    The proposed fix is to cast $file_age to an integer, ensuring that arithmetic operations are performed on valid numeric values. The corrected code is:

    if ( ( time() - (int) $file_age ) > (int) fileatime( $file ) ) {
        wp_delete_file( $file );
    } elseif ( ( time() - ( 2 * (int) $file_age ) ) > (int) filemtime( $file ) ) {
        wp_delete_file( $file );
    }
    

    I kindly request that you review this change and update the plugin accordingly in the next release to permanently resolve the issue.

    Thank you for your attention and support.

    Best regards.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey there,

    Thanks for the detailed bug report! That’s a simple bug fix, but I’m intrigued how you managed to trigger this error. There’s code in the plugin that should have unscheduled the job that calls jetpack_boost_legacy_minify_cache_cleanup with a path, but it only runs if you update the plugin through plugins.php, or the usual WordPress auto update.

    Did you upgrade the plugin manually, by downloading the zip file and replacing the directory in the plugins directory?

    You should be able to avoid this problem by deactivating the plugin and activating it again. That will fix the scheduled jobs.

    Thread Starter al3ilm

    (@al3ilm)

    Thanks.
    I’ll try it.
    I deleted the plugin and then reinstalled it.
    Awaiting results.

    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hey there, @al3ilm,

    Let us know how it goes, in case you need further help. Thanks!

    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hi there, @al3ilm,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

    Thread Starter al3ilm

    (@al3ilm)

    Excellent, the problem has been solved.

    Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @al3ilm

    Thanks for confirming. I’m going to mark this as resolved.

    If you have additional questions about Jetpack Boost in the future, feel free to open a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.