Skip to content

Commit cd9d7b2

Browse files
authored
Update IpToCountryRepository.php
1 parent 2fcc1e0 commit cd9d7b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Model/IpToCountryRepository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ public function __construct(
4848
public function getCountryCode($ip)
4949
{
5050
if (!isset($this->ipToCountry[$ip])) {
51+
$this->ipToCountry[$ip] = false;
5152
if (function_exists('geoip_country_code_by_name')) {
5253
$this->ipToCountry[$ip] = geoip_country_code_by_name($ip);
53-
} else {
54+
}
55+
if (!$this->ipToCountry[$ip]) {
5456
$longIp = ip2long($ip);
5557
$collection = $this->ipToCountryCollectionFactory->create();
5658
$collection->addFielToFilter('ip_from', ["gteq" => $longIp])
@@ -74,4 +76,4 @@ public function getVisitorCountryCode()
7476
$this->remoteAddress->getRemoteAddress()
7577
);
7678
}
77-
}
79+
}

0 commit comments

Comments
 (0)