Skip to content

[Bug] Date attributes produce invalid UNIX timestamps on 32-bit PHP #801

@striker4150

Description

@striker4150

Environment:

  • LDAP Server Type: ActiveDirectory
  • PHP Version: 8.1 (32-bit)

Describe the bug:

In my Laravel 10.x project, I am getting a PHP Fatal error: Uncaught TypeError: DateTime::setTimestamp(): Argument #1 ($timestamp) must be of type int, float given. I investigated the bug, and it seems that 32-bit PHP does not handle the DateTime conversion properly.

Ever since #602, when the Utility functions were removed with the introduction of LdapRecord v3, the Utilities::convertWindowsTimeToUnixTime() function has been replaced with the code (int) ($value / 10000000) - 11644473600. The Utilities::convertWindowsTimeToUnixTime() function used to guarantee that an int was returned, but the new code does not have this guarantee, and returns a double on 32-bit PHP.

Perhaps it could be changed to use the code (int) (round($windowsTime / 10000000) - 11644473600) from the old Utilities::convertWindowsTimeToUnixTime() function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions