LdapRecord\Models\ActiveDirectory\User dates returning as Window int #536
-
I have a project that has been working just fine. This morning I did an update to all my composer dependencies to start migrating over to PHP 8.2. After updating, I started getting a crash complaining that there is no format method on an int. For some reason, all of my dates in the User class are not being converted to a Carbon instance. I am looking at the User class and see the following: /** so the dates should be converted. Am I missing something else that is keeping these properties as integers? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Hi @jollyrogers11, To assist you, I’m going to need to see the stack trace, or a repo/script reproducing this issue, thanks! |
Beta Was this translation helpful? Give feedback.
-
Here is what I see in the log: [2023-05-30 11:51:41] production.ERROR: Call to a member function format() on int {"userId":"c38945b9-bbb8-4ec0-ad2e-65b593af396b","exception":"[object] (Error(code: 0): Call to a member function format() on int at C:\_repos\webint1\samus3\app\Http\Controllers\EmployeeInfoController.php:80) |
Beta Was this translation helpful? Give feedback.
-
The line it is crashing on contains the following: $EmployeeLDAP->accountexpires->format('m/d/Y h:i:s A') and it is complaining about trying to call the format method on an int. (It should be a Carbon instance) |
Beta Was this translation helpful? Give feedback.
-
This is output from tinker before updating:
I then run composer update directorytree/ldaprecord and it updates from version v2.17.2 => v2.20.4 Then I do the same thing in tinker:
|
Beta Was this translation helpful? Give feedback.
Hey @jollyrogers11,
This comment and issue explains the change you’re encountering here:
DirectoryTree/LdapRecord#552 (comment)
The value “9223372036854775807” is PHPs maximum number for an integer, which means that the account never expires. When checking for account expiry, the above value, zero (0), or a Carbon instance may be returned. These values must be returned to be able to determine the account expiry setting from your directory properly.
Apologies for the inconvenience!