• Ov3rfly

    (@ov3rfly)


    When adding the cache date to html output, the plugin uses WordPress 5.3.0+ functions and breaks on older WordPress versions:

    [19-May-2025 09:55:23 UTC] PHP Fatal error: Uncaught Error: Call to undefined function current_datetime() in .../wp-content/plugins/wp-fastest-cache/inc/cache.php:1130

    Seems to be this change in code.

    As the plugin is marked compatible WordPress 3.3 or higher, it should add shims for the pre 5.3.0 missing functions current_datetime -> wp_timezone -> wp_timezone_string

    WP Fastest Cache 1.3.7

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Emre Vona

    (@emrevona)

    We haven’t updated this data in a long time. Now, at least version 5.3 will be required.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Too bad, the plugin works fine here also in older classic 4.9.x WordPress installations before the current_datetime change in plugin.

    As it seems it would be enough to add these few lines to the plugin to maintain existing pre 5.3.0 WordPress compatibility:

    /* Shims for WordPress 5.3.0+ functions in wp-includes/functions.php */
    if ( !function_exists( 'current_datetime' ) ) {
    function current_datetime() {
    return new DateTimeImmutable( 'now', wp_timezone() );
    }
    }
    if ( !function_exists( 'wp_timezone' ) ) {
    function wp_timezone() {
    return new DateTimeZone( wp_timezone_string() );
    }
    }
    if ( !function_exists( 'wp_timezone_string' ) ) {
    function wp_timezone_string() {
    $timezone_string = get_option( 'timezone_string' );
    if ( $timezone_string ) {
    return $timezone_string;
    }
    $offset = (float) get_option( 'gmt_offset' );
    $hours = (int) $offset;
    $minutes = ( $offset - $hours );
    $sign = ( $offset < 0 ) ? '-' : '+';
    $abs_hour = abs( $hours );
    $abs_mins = abs( $minutes * 60 );
    $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
    return $tz_offset;
    }
    }
    Plugin Author Emre Vona

    (@emrevona)

    but it is too old version.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Edited: Last update date yesterday was only for translated versions of 4.9.26 and previous branches, see e.g. german WordPress changelog.

    • This reply was modified 1 year ago by Ov3rfly. Reason: Removed, last update yesterday was only for translated versions of 4.9.x
    • This reply was modified 1 year ago by Ov3rfly. Reason: Edited
    Plugin Author Emre Vona

    (@emrevona)

    ok I will fix it and let you know.

    Plugin Author Emre Vona

    (@emrevona)

    I fixed the issue. Can you delete wp fastest cache and download the following version to get the latest changes please?

    https://downloads.wp.xz.cn/plugin/wp-fastest-cache.zip

    Thread Starter Ov3rfly

    (@ov3rfly)

    Your new linked version works fine again also on older classic 4.9.x WordPress installations. But currently it still shows 1.3.7 as version number, that could be confusing. Thanks for the quick update!

    Plugin Author Emre Vona

    (@emrevona)

    I haven’t released a new version yet. I will release it in 30 days.

    You’re welcome 🙂 If you vote, it would make me so happy.
    https://ww.wp.xz.cn/support/plugin/wp-fastest-cache/reviews/

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘PHP Fatal error … undefined function current_datetime()’ is closed to new replies.