Opened 3 years ago
Last modified 7 days ago
#56887 accepted defect (bug)
wp_exif_date2ts throws notice on slash formatted date
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | 5.2.3 |
| Component: | Date/Time | Keywords: | has-patch has-unit-tests needs-testing |
| 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 (6)
This ticket was mentioned in PR #8884 on WordPress/wordpress-develop by @pbearne.
6 months ago
#2
- Keywords has-patch has-unit-tests added
#3
@
6 months 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
#4
@
2 weeks ago
- Keywords needs-testing added
PR 8884 needs to be tested. Furthermore, since this pull request introduces a new wp_exif_datetime() function, I suggest changing the milestone to 7.0.
Replaced
wp_exif_date2tslogic with the newwp_exif_datetimefunction 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