Skip to:
Content

BuddyPress.org

Opened 15 years ago

Closed 13 years ago

#2240 closed defect (bug) (fixed)

Unix epoch is not accepted in date field values [Has Patch]

Reported by: francescolaffi's profile francescolaffi Owned by:
Milestone: 1.5 Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords: has-patch dev-feedback
Cc: francescolaffi

Description

either in registration or edit profile date fields unix time epoch (1-1-1970) is said to be invalid / not processed. 0 is a valid strtotime return value, but the validation code check every field with empty() so it says it is not valid.

patching should be easy, I'll upload diff soon

Attachments (7)

epoch_patch.diff (6.9 KB) - added by francescolaffi 15 years ago.
proposed patch
patch_2240_on_r2978_trunk.diff (6.8 KB) - added by francescolaffi 15 years ago.
2240.003.diff (5.3 KB) - added by cnorris23 14 years ago.
Made to work with #2947. Otherwise replace $date with $field->data->value
2240.004.diff (4.6 KB) - added by cnorris23 14 years ago.
2240.005.diff (2.8 KB) - added by cnorris23 13 years ago.
2240.006.patch (1.4 KB) - added by r-a-y 13 years ago.
2240.007.diff (4.2 KB) - added by cnorris23 13 years ago.

Download all attachments as: .zip

Change History (34)

@francescolaffi
15 years ago

proposed patch

#1 @francescolaffi
15 years ago

  • Keywords has-patch dev-feedback added

#2 @cnorris23
15 years ago

  • Keywords reporter-feedback added

So are you saying that you're entering "0" as the date, instead of "1-1-1970"?

#3 @francescolaffi
15 years ago

  • Keywords reporter-feedback removed

I'm selecting 1 jan 1970 from the dropdown fields in registration or edit profile page, then the core convert it to a timestamp with strtotime function for better handling and storing in the db. The problem is that the timestamp of 1-1-1970 is 0 and the core validate all values with empty function, so 0 is not accepted.

#4 @cnorris23
15 years ago

Ah, I see. I thought you were saying you were entering 0, which would be a fringe case. This is definitely a problem since it's basically saying you couldn't have possibly been born that day :). From your patch, it looks like tested this on BP trunk. Is this also an issue in the 1.2.x branch?

#5 @francescolaffi
15 years ago

Yes also 1.2 branch has this issue. If a dev set the milestone to 1.2.4 the patch can be easily changed for that.

#6 @cnorris23
15 years ago

I would go ahead and update the patch for the 1.2.x branch, and set the milestone for 1.2.4. The devs can punt it if they don't feel it should go in.

#7 follow-up: @DJPaul
15 years ago

  • Keywords has-patch removed
  • Milestone set to 1.3

Patch needs updating and issue confirming in trunk.

#8 in reply to: ↑ 7 @francescolaffi
15 years ago

Ok I'll update it

#9 @francescolaffi
15 years ago

  • Keywords has-patch added
  • Summary changed from Unix epoch is not accepted in date field values to Unix epoch is not accepted in date field values [Has Patch]

#10 @paulhastings0
14 years ago

  • Summary changed from Unix epoch is not accepted in date field values [Has Patch] to [patch] Unix epoch is not accepted in date field values [Has Patch]

#11 follow-up: @boonebgorges
14 years ago

What if we just stored the date in 2010-11-23 20:04:25 type format instead of in unix seconds? That seems easier than trying to write replacements for core PHP functions like empty()

#12 in reply to: ↑ 11 @francescolaffi
14 years ago

  • Owner francescolaffi deleted
  • Status changed from new to assigned

Replying to boonebgorges:

What if we just stored the date in 2010-11-23 20:04:25 type format instead of in unix seconds? That seems easier than trying to write replacements for core PHP functions like empty()

@boone: Yep that sound a good solution
With regret I remove myself as owner, this year in uni is more difficult than expected and I'll not have time to write another patch :(

#13 @DJPaul
14 years ago

  • Milestone changed from 1.3 to 1.4
  • Priority changed from major to normal

#14 @DJPaul
14 years ago

  • Keywords needs-patch added; unix epoch date field dev-feedback has-patch removed
  • Summary changed from [patch] Unix epoch is not accepted in date field values [Has Patch] to Unix epoch is not accepted in date field values [Has Patch]

#15 @r-a-y
14 years ago

Also see #2963.

#17 @cnorris23
14 years ago

Per boone's suggestion I've changed the date from a Unix time stamp to a MySQL time stamp. I've added in some backwards compatibility for existing Unix timestamps, and some minor comment cleanup. The succeeding patch was made to work with #2947.

@cnorris23
14 years ago

Made to work with #2947. Otherwise replace $date with $field->data->value

#18 @cnorris23
14 years ago

  • Keywords has-patch added; needs-patch removed

#19 @cnorris23
14 years ago

  • Keywords needs-patch added; has-patch removed

This patch needs updating based on changes in [3651]. This is more for me, so I'll remember to update the patch... hopefully tonight.

@cnorris23
14 years ago

#20 @cnorris23
14 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

Patch updated for current trunk.

#21 @boonebgorges
13 years ago

  • Milestone changed from 1.6 to 1.5
  • Severity set to normal

Bringing to 1.5 since there's a patch, though I reserve the right to punt!

#22 @cnorris23
13 years ago

Haha! It's been a while since the patch was refreshed, so unless you beat me to it, I'll take a look at it tonight.

@cnorris23
13 years ago

#23 @cnorris23
13 years ago

Updated for current trunk

@r-a-y
13 years ago

#24 @r-a-y
13 years ago

Confirmed that this issue still exists.

I think the easiest solution is to convert the value to date() as cnorris23 has it in bp-xprofile-screens.php.

006.patch adds this same logic to bp-members-signup.php.

#25 @cnorris23
13 years ago

Updated patch to include bp-members-signup.php instances.

@cnorris23
13 years ago

#26 @r-a-y
13 years ago

Good catch on the other strtotime reference in bp-members-signup.php, cnorris23.
Was a late night!

#27 @boonebgorges
13 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [5131]) Switches date picker xprofile fields to save in MySQL date format rather than UNIX timestamp, to prevent problems with UNIX epoch. Fixes #2240. Props cnorris23, r-a-y

Note: See TracTickets for help on using tickets.