Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNina Pypchenko <22447785+nina-py@users.noreply.github.com>2020-11-17 22:39:52 +0300
committerGitHub <noreply@github.com>2020-11-17 22:39:52 +0300
commite8f5caca7e38086ed3970aed3792f42ae48c543e (patch)
tree6534af8ea6b957e69b7fb7f35d87b7e88dc746e2 /plugins/GeoIp2
parente9d657a20c655111cb7a69ebafad28e8c8482207 (diff)
DB-IP URL is automatically updated in the options (#16713)
Diffstat (limited to 'plugins/GeoIp2')
-rw-r--r--plugins/GeoIp2/GeoIP2AutoUpdater.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/GeoIp2/GeoIP2AutoUpdater.php b/plugins/GeoIp2/GeoIP2AutoUpdater.php
index 32d6af210e..9e3f5d7780 100644
--- a/plugins/GeoIp2/GeoIP2AutoUpdater.php
+++ b/plugins/GeoIp2/GeoIP2AutoUpdater.php
@@ -102,11 +102,13 @@ class GeoIP2AutoUpdater extends Task
$locUrl = Option::get(self::LOC_URL_OPTION_NAME);
if (!empty($locUrl)) {
$this->downloadFile('loc', $locUrl);
+ $this->updateDbIpUrlOption(self::LOC_URL_OPTION_NAME);
}
$ispUrl = Option::get(self::ISP_URL_OPTION_NAME);
if (!empty($ispUrl)) {
$this->downloadFile('isp', $ispUrl);
+ $this->updateDbIpUrlOption(self::ISP_URL_OPTION_NAME);
}
} catch (Exception $ex) {
// message will already be prefixed w/ 'GeoIP2AutoUpdater: '
@@ -798,4 +800,31 @@ class GeoIP2AutoUpdater extends Task
{
return Http::fetchRemoteFile($url);
}
+
+ /**
+ * Updates the DB-IP URL option value so that users see
+ * the updated link in the "Download URL" field on the plugin page
+ * instead of the one that was set when Matomo was installed months
+ * or even years ago.
+ *
+ * @param string $option The option to check and update: either
+ * self::LOC_URL_OPTION_NAME or self::ISP_URL_OPTION_NAME
+ */
+ protected function updateDbIpUrlOption(string $option): void
+ {
+ if ($option !== self::LOC_URL_OPTION_NAME && $option !== self::ISP_URL_OPTION_NAME)
+ {
+ return;
+ }
+
+ $url = trim(Option::get($option));
+
+ if (self::isDbIpUrl($url)) {
+ $latestUrl = $this->getDbIpUrlWithLatestDate($url);
+
+ if($url !== $latestUrl) {
+ Option::set($option, $latestUrl);
+ }
+ }
+ }
}