Making WordPress.org


Ignore:
Timestamp:
12/01/2021 05:40:03 AM (3 years ago)
Author:
dd32
Message:

Support Forums: Check that the topic date was parseable before using the resulting DateTime object, to avoid a PHP Fatal error on topic-less replies.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r11335 r11350  
    12621262        $last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true );
    12631263        if ( empty( $last_active ) ) {
    1264             if ( ! empty( $reply_id ) ) {
    1265                 $last_active = get_post_field( 'post_date', $reply_id );
    1266             } else {
    1267                 $last_active = get_post_field( 'post_date', $topic_id );
    1268             }
     1264            $last_active = get_post_field( 'post_date', $topic_id );
    12691265        }
    12701266
    12711267        // This is for translating the date components.
    12721268        $datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', $last_active );
    1273         $date     = wp_date( get_option( 'date_format' ), $datetime->getTimestamp() );
    1274         $time     = wp_date( get_option( 'time_format' ), $datetime->getTimestamp() );
     1269        if ( ! $datetime ) {
     1270            return $anchor;
     1271        }
     1272
     1273        $date = wp_date( get_option( 'date_format' ), $datetime->getTimestamp() );
     1274        $time = wp_date( get_option( 'time_format' ), $datetime->getTimestamp() );
    12751275
    12761276        return str_replace(
Note: See TracChangeset for help on using the changeset viewer.