Inline Edit of DateTime fields - Saving Fails with Fatal Error with a non-standard TimeZone #3342

Closed
opened 2026-02-20 16:04:07 -05:00 by deekerman · 2 comments
Owner

Originally created by @markbond1007 on GitHub (Oct 8, 2018).

Issue

If you have a user TZ set, when saving a DateTime field via inline edit a fatal error is triggered:
Fatal error: Uncaught TypeError: Argument 1 passed to TimeDate::tzUser() must be an instance of DateTime, boolean given, called in /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php on line 441 and defined in /home/web/WorkingOptions/www/include/TimeDate.php:933
Stack trace:
#0 /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php(441): TimeDate->tzUser(false)
#1 /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php(392): formatDisplayValue(Object(FP_events), '08/10/2018 15:3...', Array, 'save')
#2

With display errors off, the value in the frontend disappears (it still saves though).

As you can see the date its sending through is 08/10/2018 15:30, the line in question (see attached screenshot - bug ) is doing this:

$datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value,new DateTimeZone('UTC'));

the format being parsed is definitely not the format listed. A few lines previously there is this:
if ($method != "save") {
$value = convertDateUserToDB($value);
}

Which would indicate a conversion, however we would need this during the save process.

Expected Behavior

It should save the datetime and return the displayed datetime.

Actual Behavior

It saves the datetime, if you have display_errors = On and error_reporting=E_ALL you see the above errors listed.

Possible Fix

This needs to be amended to either include save (not sure why its excluded currently so reluctant to suggest this as a permanent fix - I have tried it and it seems to work - however not sure why its set to != 'save' in the first place).

if ($method != "save") {
$value = convertDateUserToDB($value);
}

Steps to Reproduce

  1. Set your timezone/dateformat to a non-default timezone/dateformat
  2. Inline edit a datetime field
  3. Click the save button
  4. with and without errors being enalbed and displayed you will see an issue (either a stack trace or a blank field)

Context

Your Environment

  • SuiteCRM Version used: 7.10.7
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome 69.0.3497.100
  • Environment name and version (e.g. MySQL, PHP 7): PHP7, MariaDB, Debain stretch
  • Operating System and version (e.g Ubuntu 16.04): Mac OSX 10.13.6
Originally created by @markbond1007 on GitHub (Oct 8, 2018). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> If you have a user TZ set, when saving a DateTime field via inline edit a fatal error is triggered: Fatal error: Uncaught TypeError: Argument 1 passed to TimeDate::tzUser() must be an instance of DateTime, boolean given, called in /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php on line 441 and defined in /home/web/WorkingOptions/www/include/TimeDate.php:933 Stack trace: #0 /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php(441): TimeDate->tzUser(false) #1 /home/web/WorkingOptions/www/include/InlineEditing/InlineEditing.php(392): formatDisplayValue(Object(FP_events), '08/10/2018 15:3...', Array, 'save') #2 With display errors off, the value in the frontend disappears (it still saves though). As you can see the date its sending through is 08/10/2018 15:30, the line in question (see attached screenshot - ![bug](https://user-images.githubusercontent.com/17045461/46604636-c9b66080-caee-11e8-90fb-143aedda395f.png) ) is doing this: $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value,new DateTimeZone('UTC')); the format being parsed is definitely not the format listed. A few lines previously there is this: if ($method != "save") { $value = convertDateUserToDB($value); } Which would indicate a conversion, however we would need this during the save process. #### Expected Behavior <!--- Tell us what should happen --> It should save the datetime and return the displayed datetime. #### Actual Behavior <!--- Tell us what happens instead --> <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) --> It saves the datetime, if you have display_errors = On and error_reporting=E_ALL you see the above errors listed. #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> This needs to be amended to either include save (not sure why its excluded currently so reluctant to suggest this as a permanent fix - I have tried it and it seems to work - however not sure why its set to != 'save' in the first place). if ($method != "save") { $value = convertDateUserToDB($value); } #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Set your timezone/dateformat to a non-default timezone/dateformat 2. Inline edit a datetime field 3. Click the save button 4. with and without errors being enalbed and displayed you will see an issue (either a stack trace or a blank field) #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.10.7 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome 69.0.3497.100 * Environment name and version (e.g. MySQL, PHP 7): PHP7, MariaDB, Debain stretch * Operating System and version (e.g Ubuntu 16.04): Mac OSX 10.13.6
deekerman 2026-02-20 16:04:07 -05:00
Author
Owner

@gitbnw commented on GitHub (Oct 17, 2018):

previous issue #5526
tried to fix here #6039

@gitbnw commented on GitHub (Oct 17, 2018): previous issue #5526 tried to fix here #6039
Author
Owner

@Dillon-Brown commented on GitHub (Oct 18, 2018):

@gitbnw Fix merged, thanks!

@Dillon-Brown commented on GitHub (Oct 18, 2018): @gitbnw Fix merged, thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#3342
No description provided.