Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/13/2016 09:14:06 PM (3 years ago)
Author:
r-a-y
Message:

Core: Fix fatal error with bp_core_get_iso8601_date() when an invalid date string is passed.

This error occurred on the Members Directory and selecting the
"Alphabetical" filter when attempting to parse an inactive user's last
activity. Inactive users passes the "Never active" string to
bp_core_get_iso8601_date() and the DateTime class causes a fatal
error on invalid date strings, unless we catch the exception, which this
commit is now doing.

See #5757.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r11088 r11097  
    13091309        }
    13101310
    1311         $date = new DateTime( $timestamp, new DateTimeZone( 'UTC' ) );
     1311        try {
     1312            $date = new DateTime( $timestamp, new DateTimeZone( 'UTC' ) );
     1313
     1314        // Not a valid date, so return blank string.
     1315        } catch( Exception $e ) {
     1316            return '';
     1317        }
     1318
    13121319        return $date->format( DateTime::ISO8601 );
    13131320    }
Note: See TracChangeset for help on using the changeset viewer.