[wp-trac] [WordPress Trac] #48957: Call to a member function format() on boolean in wp-includes/feed.php

WordPress Trac noreply at wordpress.org
Sun Dec 15 23:35:41 UTC 2019


#48957: Call to a member function format() on boolean in wp-includes/feed.php
--------------------------+---------------------
 Reporter:  dd32          |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  5.3.2
Component:  Date/Time     |     Version:  5.3.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by dd32):

 > Would it be enough to check the returned value from
 date_create_immutable_from_format()

 I think checking the return value is in general probably enough, with the
 expectation that it'll take appropriate action to try to make sure it's
 valid.

 In this case, `max( $modified_times )` is probably enough to attempt to
 get a valid date, avoiding the `0` and `0000-00-00 00:00:00` dates if
 there's valid data available.

 The question just remains  - what kind of output should this function have
 in the event of this error condition?
 It looks like the fallback higher up in the function for
 `get_lastpostmodified()` is probably a good option, so:
 {{{
 if ( ! $datetime ) {
     // Fallback to last time any post was modified or published.
     return get_lastpostmodified( 'GMT' );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48957#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list