Skip to content
Snippets Groups Projects
Commit 129a173c authored by Travis Musika's avatar Travis Musika Committed by arpeggio
Browse files

Issue #3192476 by tmusika: Made Maxmind GeoLite2 DB updated weekly

parent 3a3ce43e
No related branches found
No related tags found
No related merge requests found
......@@ -235,11 +235,9 @@ class SmartIpEventSubscriber extends SmartIpEventSubscriberBase {
'#title' => $autoDbUpdateLabel,
'#description' => t(
'MaxMind GeoIP2 binary database will be automatically updated via
cron.php every Wednesday (for licensed version) and every first
Wednesday of the month (for lite or free version). MaxMind GeoIP2
updates their database every Tuesday for licensed version and every
first Tuesday of the month for lite or free version. @cron must be
enabled for this to work.', [
cron.php every Wednesday (for licensed and lite/free versions).
MaxMind GeoIP2 updates their database every Tuesday for licensed
and free versions. @cron must be enabled for this to work.', [
'@cron' => Link::fromTextAndUrl(t('Cron'), Url::fromRoute('system.cron_settings'))->toString(),
]
),
......@@ -382,9 +380,8 @@ class SmartIpEventSubscriber extends SmartIpEventSubscriberBase {
}
/**
* MaxMind GeoIP2 updates the binary database every Tuesday, and we download
* every Wednesday for licensed version. Every first Tuesday of the month for
* lite or free version, and we download every first Wednesday of the month.
* MaxMind GeoIP2 updates the binary database every Tuesday (both lite and
* licensed versions), and we download every Wednesday.
* That means that we only want to download if the current database was
* downloaded prior to the most recently available version.
*/
......@@ -395,12 +392,7 @@ class SmartIpEventSubscriber extends SmartIpEventSubscriberBase {
$autoUpdate = $config->get('db_auto_update');
$version = $config->get('version');
$lastUpdateTime = \Drupal::state()->get('smart_ip_maxmind_geoip2_bin_db.last_update_time') ?: 0;
if ($version == MaxmindGeoip2BinDb::LINCENSED_VERSION) {
$frequency = DatabaseFileUtility::DOWNLOAD_WEEKLY;
}
elseif ($version == MaxmindGeoip2BinDb::LITE_VERSION) {
$frequency = DatabaseFileUtility::DOWNLOAD_MONTHLY;
}
$frequency = DatabaseFileUtility::DOWNLOAD_WEEKLY;
if (DatabaseFileUtility::needsUpdate($lastUpdateTime, $autoUpdate, $frequency)) {
DatabaseFileUtility::downloadDatabaseFile();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment