I have a node with some Date Fields. The nodes data is already valid. There is nothing wrong with it visually. But if i try and save the node from the admin panel. The date fields get flagged as invalid and it wont let me save the node. Even though the Dates are 100% valid because they never changed. its using data that it had in it already. In the past the only way i could fix this is to import the database from before this issue popped up. At present i cannot do that because i would lose a lot of data. Is there anybody here that can help me figure out how to fix this issue without losing my data?

Comments

rujinxero created an issue. See original summary.

digitaltodd’s picture

I am also having this problem. I was working before, I suspect the recent update is the issue.

If the field is not required, disabled in the form, the errors occur.
When the all day check box is selected the errors occur.
The value input for field When Start date is invalid:
The value 21:15 does not match the expected format.
The value input for field When End date is invalid:
The value 21:15 does not match the expected format.

Format of the data going in.
04/27/2017 09:15pm
04/28/2017 10:00am

something is really wrong. This module is not easy to roll back because you have to delete fields using it? Do I have that right?
It looks like a pretty serious issue.

Update on this. New instances of the field work fine, and I can edit pages with this field and change times. In my case, the errors are occurring when I'm trying to create new content of this type.

thanks

Squee3P0’s picture

I'm having the same problem. Since there were no database changes in the last few updates, I was able to downgrade the module by just replacing the source code of the module without disabling or uninstalling it.

The problem appears to have been introduced in 7.x-2.10-rc2. Downgrading to 7.x-2.10-rc1 fixed the problem for me.

marco5775’s picture

I've the same problem since I've install Date 7.x-2.10.
What is the [temporary] solution ? Patch ? code to modify ?
Thanks in advance.

Squee3P0’s picture

Status: Active » Needs review
StatusFileSize
new845 bytes

The problem appears to be caused by the patch for this issue that was committed to version 7.x-2.10-rc2:
https://www.drupal.org/node/1037150

I haven't tested their case of a time only field, but I've attached a patch that fixes this issue for me and looks like it would still work for the original issue with time only fields.

Squee3P0’s picture

Component: Date API » Date Popup

Changing component since the problem is in the Date Popup sub module.

Squee3P0’s picture

Priority: Critical » Major
fdverwoerd’s picture

We had an issue with date popup and date_popup_authored on node save. Even when we changed nothing, the date would change to current date (created to now).

- When running php 5.6.10, it works ok. (without patch)
- When running php 5.3.29, the Authored on date would be set to now. With the patch from comment #5 it would stay/change properly.

Also this was in the errors array:

The value 2 2 does not match the expected format. Drupal php 5.3.

Very weird, I am still not sure what's happening. Hopefully this helps a bit.

webservant316’s picture

I've have held on updating to 7-.2.10 waiting for this patch to get installed.
What is the status? Why isn't this patch committed?

Kostya19’s picture

I had an error when trying save a disabled date field: The value 14:49:46 does not match the expected format. Patch from #5 solved this issue.

jyraya’s picture

I am evaluating the update from 2.9 to 2.10.

I have Date field using the pop-up calendar widget with as settings:

  • Data attributes to collect: Year, Month, Day, Hour and Minute
  • No end date to collect
  • Time zone handling: Site's time zone
  • No "Cache dates"
  • Number of value: 1
  • Translatable

I have contents created with the version 2.9.

When I update contents with the version 2.10 without changing the date, I did not meet the problem described here.

According to your situation, which additional modules or settings are required in order to have the problem?

jcisio’s picture

Assigned: Unassigned » jcisio
Priority: Major » Critical
Status: Needs review » Reviewed & tested by the community

Bump to critical because of data loss (node created date is lost on save).

Patch #5 fixes the problem. Bug can only be reproduced on PHP 5.3 and below: https://3v4l.org/J3FmL

$input = '2018-01-11 11:02';
print $input['time'];
var_dump(empty($input['time']));
Output for 5.4.0 - 5.6.30, 7.0.0 - 7.2.1
Warning: Illegal string offset 'time' in /in/J3FmL on line 3
2bool(true)

Output for 5.0.0 - 5.0.2, hhvm-3.10.1 - 3.22.0
2bool(true)

Output for 4.3.0 - 4.4.9, 5.0.3 - 5.3.29
2bool(false)
jcisio’s picture

StatusFileSize
new929 bytes

New patch to adhere coding standards (fixing indentation), so keep the status as RTBC.

jcisio’s picture

Title: Date field being flagged as Invalid date not actually invalid » PHP 5.3 - Date field being flagged as Invalid date not actually invalid

Change title to help people finding this issue.

damienmckenna’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Parent issue: » #2867810: Plan for Date 7.x-2.11 release
damienmckenna’s picture

Assigned: jcisio » Unassigned
webservant316’s picture

Wow, I see no logical difference between the current and the patched code. Can someone explain what is happening?

oops I see the difference in the operators now.

  • DamienMcKenna committed 33cf625 on 7.x-2.x authored by Squee3P0
    Issue #2873415 by Squee3P0, jcisio, rujinxero, digitaltodd, fdverwoerd,...
damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.