Bug #34529

Handle non-mandatory DateTime objects

Added by Kevin Ulrich Moschallski about 1 year ago. Updated 10 months ago.

Status:Rejected Start date:2012-03-05
Priority:Should have Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Has patch:No Tags:
Votes: 0

Description

I yesterday got a problem with one of my models which has two DateTimeProperties which are booth not mandatory. As you may know you can't set a DateTime object to an undefined time, as it's constructed whether with the given time (+format) or without this option with the current local time.

This problem was already discussed in this thread:

http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2011-April/009207.html

The result of this thread was the suggestion to set the properties to string and not DateTime and use a custom validator.

The whole problem seems more to be PHP related than an extbase problem. One solution maybe would be to extend the DateTime class with a custom class which allows to set an undefined time which then results in NULL when any method is called on the object. But this would be a huge affort and maybe a breaking change.

So i looked at the reflection objectaccess and wrote a solution which i hope you will have a look on it. The concept is to use the property refelection to see if the param of the setter method on the object is of type DateTime. If so the value to be set is validated for DateTime. If the value is an instance of DateTime it will be set otherwise it will be obmitted. Before doing this i changed the DateTime converter to not throw an exception if the value couldn't be converted to DateTime it will now return NULL.

History

Updated by Gerrit Code Review about 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9380

Updated by Kevin Ulrich Moschallski about 1 year ago

Fixed in #33861, can be closed.

Updated by Markus Günther 10 months ago

  • Status changed from Under Review to Rejected

Has been abandoned.

Also available in: Atom PDF