mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
Inline Edit of DateTime fields - Saving Fails with Fatal Error with a non-standard TimeZone #3342
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#3342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 -
) 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
Context
Your Environment
@gitbnw commented on GitHub (Oct 17, 2018):
previous issue #5526
tried to fix here #6039
@Dillon-Brown commented on GitHub (Oct 18, 2018):
@gitbnw Fix merged, thanks!