smart_ip attempting to update the ip2location on every cron run?

Created on 28 September 2023, over 1 year ago

We're using smart_ip and smart_ip_ip2location_bin_db. On every cron run the module is supposed to evaluate whether the ip2location database needs to be updated. The download should happen not more than weekly or monthly, depending upon configuration.

I'm finding that instead, the download is attempted on every cron run, irrespective of when it was last downloaded.

In `SmartIpEventSubscriber.php` there is the following conditional:

<?php
      if ($ipVersion || DatabaseFileUtility::needsUpdate($lastUpdateTime, $autoUpdate, DatabaseFileUtility::DOWNLOAD_MONTHLY)) {
        if (empty($ipVersion)) {
          // Update IPv4 IP2Location binary database first
          $ipVersion = Ip2locationBinDb::IPV4_VERSION;
          \Drupal::state()->set('smart_ip_ip2location_bin_db.current_ip_version_queue', $ipVersion);
        }
        DatabaseFileUtility::downloadDatabaseFile($ipVersion);
      }
?>

It seems to me that $ipVersion will always evaluate to TRUE, therefore won't this conditional mean that the download is executed on every iteration?

I may have got this wrong, but it seems to be the case in my tests so would like to clarify.

💬 Support request
Status

Active

Version

4.1

Component

Code

Created by

🇬🇧United Kingdom Leo Pitt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024