Needs work
Project:
Drupal core
Version:
main
Component:
datetime.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 May 2021 at 15:19 UTC
Updated:
31 May 2021 at 15:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rahul-kr-sh commentedAdding initial patch please review this.
Comment #3
jonathanshawThanks for patch @rahul-kr-sh.
However your solution won't work, because an exception is not thrown if the date object has errors.
Handling the exception that is currently thrown (the @todo) is the focus of #3025642: Remove the try/catch block from DateTimeComputed::getValue().
The problem we're addressing in this issue is caused by this line:
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {Currently if is is true that $date->hasErrors() then we don't do anything, so the whole function returns NULL without warning.
Our code probably needs to become something like:
{
Comment #4
rahul-kr-sh commentedUpdated the patch.
Comment #5
jonathanshawWe need to check $date is an instance of DrupalDateTime before calling hasErrors
We need to call $date->getErrors() and use that to provide a more informative message in the exception.
I don't think we need to add code to catch the exception. Logging is being handled in #3025642: Remove the try/catch block from DateTimeComputed::getValue(), and we can make sure that issue gets committed first.
Comment #6
vsujeetkumar commented@jonathanshaw Fixed to failed tests(Due to syntax error.), Also worked on #5, Please have a look and advise.
Comment #7
vsujeetkumar commentedComment #8
jonathanshawI think this is ready now. But it should probably have test coverage.
Comment #9
jonathanshaw