[wp-trac] [WordPress Trac] #56887: wp_exif_date2ts throws notice on slash formatted date

WordPress Trac noreply at wordpress.org
Sat Oct 22 11:15:51 UTC 2022


#56887: wp_exif_date2ts throws notice on slash formatted date
---------------------------+-----------------------------
 Reporter:  domainsupport  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Date/Time      |    Version:  5.2.3
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 When an image has an exif date in the format ...

 > YYYY/MM/DD HH:MM:SS

 ... rather than ...

 > YYYY:MM:DD HH:MM:SS

 ... which is happening more and more I have noticed, the following PHP
 notices are thrown ...

 > PHP Notice:  Undefined offset: 1 in /var/www/tourist.org.uk/html/wp-
 admin/includes/image.php on line 710
 > PHP Notice:  Undefined offset: 2 in /var/www/tourist.org.uk/html/wp-
 admin/includes/image.php on line 710

 I think there are a lot of assumptions being made in wp_exif_date2ts() and
 I believe that a preg_match check like ...

 {{{#!php
 <?php
 if (preg_match('/^(?>\d){4}[:|\/](?>\d){2}[:|\/](?>\d){2}
 (?>\d){2}:(?>\d){2}:(?>\d){2}$/', $str)) {

 // Process and return exif date

 } else {
 return false;
 }
 }}}


 ... should be done instead.

 This is related to ticket [ticket:48204]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56887>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list