stevebauman / location

Detect a users location by their IP Address.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing timezone information when using the MaxMind driver

craigpaul opened this issue · comments

When using the MaxMind driver in your package, I've encountered an issue where the timezone field becomes null during the processing of the IP. This problem specifically occurs in the hydrate method of the driver when transferring information from the Fluent object to the Position object.

The underscore in the property name seems to be the root cause, as the actual property on the Fluent class is named timezone without the underscore. To address this issue in my application, I implemented a temporary workaround by overriding the driver's hydrate method as follows:

/**
 * {@inheritdoc}
 */
protected function hydrate(Position $position, Fluent $location): Position
{
    $position = parent::hydrate($position, $location);

    $position->timezone = $location->timezone;

    return $position;
}

I believe a fix for this issue could involve updating the driver and related tests, and I can put up a pull request if this approach aligns with the project's goals. Please let me know if you have any thoughts or feedback on this proposed solution.

Thank you for your time and consideration.

Hi @craigpaul, thanks for the post!

Will definitely accept a PR if you send one over 🙏

Awesome! Thanks @stevebauman! I'll send that over tonight when I get back home 😄