You are here

public function HttpblEvaluatorInterface::getIpLocalStatus in http:BL 8

Get status of IP in httpbl_host table of stored hosts.

(legacy name was "_httpbl_cache_get".)

Now with belt AND suspenders! Also scrubs any duplicates.

In previous versions (D5-D7), there were reported experiences of errors due to database attempts to insert duplicate keys; the only "unique" key then was the IP address being inserted. It's long been "theoretically" impossible for this to happen, since we only insert new records after checking Project Honeypot, and we only check Project Honeypot if no record already exists locally. Yet, somehow, a rarely occurring condition could exist -- during heavy bot attacks? -- where there were attempts to add a "new" record when one, in fact, already existed for the same IP.

Version D8 now stores these records as content entities and uses core entity and storage handlers to deal with the database, agnostically. And httpl "Host" entities have a unique, serial row index and uuid, so they no longer rely on the IP address as the sole unique property.

But, in the event of those rare conditions that could cause duplicate records, this leaves the door open to letting them happen, without blowing up the database. In other words, while duplicates still theoretically can't happen, they apparently can and will, though now it will be without any database warnings.

So, when checking locally for stored Hosts (IP addresses), all those with matching IPs are gathered. It should be a rare occurance to find more than one, but they're now always counted, and if there is more than one match, the oldest ones (by index number) will be scrubbed and only the most recent record (and whatever status it contains) will be used.

Parameters

string $ip: The Host_IP to search for in local storage.

Return value

integer | null The status of a stored host found.

1 method overrides HttpblEvaluatorInterface::getIpLocalStatus()
HttpblEvaluator::getIpLocalStatus in src/HttpblEvaluator.php
Get status of IP in httpbl_host table of stored hosts.

File

src/HttpblEvaluatorInterface.php, line 79

Class

HttpblEvaluatorInterface
Provides an interface defining a HttpblEvaluate manager.

Namespace

Drupal\httpbl

Code

public function getIpLocalStatus($ip);