Make WordPress Core

Opened 14 years ago

Closed 9 years ago

#16993 closed defect (bug) (fixed)

wp-mail.php doesn't account for half-hour and quarter-hour timezones.

Reported by: neoscrib's profile neoscrib Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.1
Component: Mail Keywords: has-patch commit
Focuses: Cc:

Description

To reproduce the problem, install Wordpress and set it to post by email. Send a post from an email address which is configured to use a half-hour or quarter-hour timezone (like Afghanistan, +0430).

wp-mail.php calculates the timezone by multiplying the timezone offset by 36. This works fine for whole-hour timezones (Pacific Time -0800, -800 * 36 = -28800 seconds). For half-hour and quarter-hour time zones this does not work (Afghanistan +0430, 430 * 36 = 15480, should be 16200). The reason this happens is because an hour has 60 minutes as opposed to 100 minutes. 430 / 100 = 4.3 hours, not 4.5 hours. 450 * 36 result in 16200 minutes, but timezones are represented as hours and minutes, not fractional hours.

This results in posts that are posted via email from a half-hour or quarter-hour timezone to be posted in the future or in the past from when it was actually posted.

Attachments (2)

wp-mail-patch.txt (972 bytes) - added by neoscrib 14 years ago.
16993.diff (1.4 KB) - added by solarissmoke 14 years ago.
Use strtotime instead of regex parsing

Download all attachments as: .zip

Change History (12)

#1 @neoscrib
14 years ago

  • Keywords has-patch added

@solarissmoke
14 years ago

Use strtotime instead of regex parsing

#2 follow-up: @solarissmoke
14 years ago

The current logic is replicating what PHP's strtotime() would do internally - I don't see the point. We can just use strtotime, which can handle RFC822 timestamps (including timezone offsets). It doesn't like parenthesised timezone strings (after the +0000 bit), so we should remove those, but otherwise it works for every email header date I've seen.

#3 in reply to: ↑ 2 @neoscrib
14 years ago

Replying to solarissmoke:

The current logic is replicating what PHP's strtotime() would do internally - I don't see the point. We can just use strtotime, which can handle RFC822 timestamps (including timezone offsets). It doesn't like parenthesised timezone strings (after the +0000 bit), so we should remove those, but otherwise it works for every email header date I've seen.

That makes more sense!

#4 @nacin
12 years ago

  • Milestone changed from Awaiting Review to 3.5

Seems good to me.

#5 @DrewAPicture
12 years ago

  • Keywords punt added

#6 @nacin
12 years ago

  • Keywords 3.6-early added
  • Milestone changed from 3.5 to Future Release

#7 @SergeyBiryukov
12 years ago

  • Keywords punt removed

#8 @nacin
11 years ago

  • Component changed from Blog by Email to Mail

#9 @chriscct7
9 years ago

  • Keywords commit added; 3.6-early removed
  • Milestone changed from Future Release to 4.4
  • Severity changed from trivial to normal

#10 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 34864:

WP Mail: replace logic that was mimicking strtotime() with strtotime(). Without this, the date parsing wasn't accounting for half-hour and quarter-hour timezones.

Props neoscrib, solarissmoke.
Fixes #16993.

Note: See TracTickets for help on using tickets.