msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

Incorrect birth date for emtpy value

Open gorets opened this issue 4 years ago • 2 comments

https://github.com/microsoftgraph/msgraph-sdk-php/blob/72192f38679c7def0daac0cf53648cdebcf96256/src/Beta/Microsoft/Graph/Model/Contact.php#L64

API responsed null for undefined Day of birth. For this case, msgraph-sdk-php will return the current date.

Solution: need additional check value !== null AB#10295

gorets avatar Jul 20 '21 12:07 gorets

Hello @gorets, thanks for reporting the issue. I can see there is a check on https://github.com/microsoftgraph/msgraph-sdk-php/blob/72192f38679c7def0daac0cf53648cdebcf96256/src/Beta/Microsoft/Graph/Model/Contact.php#L65

To check if the key contains null before creating a new DateTime() object. Are experiencing any unexpected behavior?

SilasKenneth avatar Jul 21 '21 06:07 SilasKenneth

Hello @gorets, thanks for reporting the issue. I can see there is a check on https://github.com/microsoftgraph/msgraph-sdk-php/blob/72192f38679c7def0daac0cf53648cdebcf96256/src/Beta/Microsoft/Graph/Model/Contact.php#L65

To check if the key contains null before creating a new DateTime() object. Are experiencing any unexpected behavior?

No, this solution don't resolve problem. If input value is null, we going to the else and execute new \DateTime(null) and received current date.

Recommended solution: if (array_key_exists("birthday", $this->_propDict) && !is_null($this->_propDict["birthday"])) { }

gorets avatar Jul 21 '21 07:07 gorets

Resolved in latest v1 release

Ndiritu avatar Oct 06 '22 07:10 Ndiritu