Opened 3 years ago
Last modified 6 weeks ago
#56887 accepted defect (bug)
wp_exif_date2ts throws notice on slash formatted date
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.9 | Priority: | normal |
Severity: | normal | Version: | 5.2.3 |
Component: | Date/Time | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description (last modified by )
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 /.../wp-admin/includes/image.php on line 710
PHP Notice: Undefined offset: 2 in /.../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 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 48204
Change History (3)
This ticket was mentioned in PR #8884 on WordPress/wordpress-develop by @pbearne.
6 weeks ago
#2
- Keywords has-patch has-unit-tests added
#3
@
6 weeks ago
- Milestone changed from Awaiting Review to 6.9
- Owner set to pbearne
- Status changed from new to accepted
This fixes https://core.trac.wordpress.org/ticket/48204 as well
Note: See
TracTickets for help on using
tickets.
Replaced
wp_exif_date2ts
logic with the newwp_exif_datetime
function for cleaner and reusable code. Enhanced metadata to store RFC3339 formatted dates while maintaining backward compatibility. Added comprehensive PHPUnit tests for EXIF date validation and edge cases.Fixes 48204 as well
Trac ticket: 56887