mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-20 01:09:56 +03:00
Fixed merge conflicts
This commit is contained in:
commit
6d78cd59e9
6 changed files with 60 additions and 4 deletions
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -21,6 +21,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
|
## [2.7.1] - 2021-05-30
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#1100](https://github.com/shlinkio/shlink/issues/1100) Fixed Shlink trying to download GeoLite2 db files even when tracking has been disabled.
|
||||||
|
|
||||||
|
|
||||||
## [2.7.0] - 2021-05-23
|
## [2.7.0] - 2021-05-23
|
||||||
### Added
|
### Added
|
||||||
* [#1044](https://github.com/shlinkio/shlink/issues/1044) Added ability to set names on API keys, which helps to identify them when the list grows.
|
* [#1044](https://github.com/shlinkio/shlink/issues/1044) Added ability to set names on API keys, which helps to identify them when the list grows.
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
"shlinkio/shlink-event-dispatcher": "^2.1",
|
"shlinkio/shlink-event-dispatcher": "^2.1",
|
||||||
"shlinkio/shlink-importer": "^2.3",
|
"shlinkio/shlink-importer": "^2.3",
|
||||||
"shlinkio/shlink-installer": "^6.0",
|
"shlinkio/shlink-installer": "^6.0",
|
||||||
"shlinkio/shlink-ip-geolocation": "^1.5",
|
"shlinkio/shlink-ip-geolocation": "^2.0",
|
||||||
"symfony/console": "^5.1",
|
"symfony/console": "^5.1",
|
||||||
"symfony/filesystem": "^5.1",
|
"symfony/filesystem": "^5.1",
|
||||||
"symfony/lock": "^5.1",
|
"symfony/lock": "^5.1",
|
||||||
|
|
|
@ -167,7 +167,7 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
'geolite2' => [
|
'geolite2' => [
|
||||||
'license_key' => env('GEOLITE_LICENSE_KEY', 'G4Lm0C60yJsnkdPi'), // Deprecated. Remove the default value
|
'license_key' => env('GEOLITE_LICENSE_KEY', 'G4Lm0C60yJsnkdPi'), // Deprecated. Remove hardcoded license on v3
|
||||||
],
|
],
|
||||||
|
|
||||||
'mercure' => $helper->getMercureConfig(),
|
'mercure' => $helper->getMercureConfig(),
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
||||||
use Laminas\ServiceManager\Factory\InvokableFactory;
|
use Laminas\ServiceManager\Factory\InvokableFactory;
|
||||||
use Shlinkio\Shlink\Common\Doctrine\NoDbNameConnectionFactory;
|
use Shlinkio\Shlink\Common\Doctrine\NoDbNameConnectionFactory;
|
||||||
use Shlinkio\Shlink\Core\Domain\DomainService;
|
use Shlinkio\Shlink\Core\Domain\DomainService;
|
||||||
|
use Shlinkio\Shlink\Core\Options\TrackingOptions;
|
||||||
use Shlinkio\Shlink\Core\Service;
|
use Shlinkio\Shlink\Core\Service;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Transformer\ShortUrlDataTransformer;
|
use Shlinkio\Shlink\Core\ShortUrl\Transformer\ShortUrlDataTransformer;
|
||||||
|
@ -64,7 +65,12 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
ConfigAbstractFactory::class => [
|
ConfigAbstractFactory::class => [
|
||||||
Util\GeolocationDbUpdater::class => [DbUpdater::class, Reader::class, LOCAL_LOCK_FACTORY],
|
Util\GeolocationDbUpdater::class => [
|
||||||
|
DbUpdater::class,
|
||||||
|
Reader::class,
|
||||||
|
LOCAL_LOCK_FACTORY,
|
||||||
|
TrackingOptions::class,
|
||||||
|
],
|
||||||
Util\ProcessRunner::class => [SymfonyCli\Helper\ProcessHelper::class],
|
Util\ProcessRunner::class => [SymfonyCli\Helper\ProcessHelper::class],
|
||||||
ApiKey\RoleResolver::class => [DomainService::class],
|
ApiKey\RoleResolver::class => [DomainService::class],
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use Cake\Chronos\Chronos;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
use MaxMind\Db\Reader\Metadata;
|
use MaxMind\Db\Reader\Metadata;
|
||||||
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
|
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
|
||||||
|
use Shlinkio\Shlink\Core\Options\TrackingOptions;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Exception\RuntimeException;
|
use Shlinkio\Shlink\IpGeolocation\Exception\RuntimeException;
|
||||||
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdaterInterface;
|
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdaterInterface;
|
||||||
use Symfony\Component\Lock\LockFactory;
|
use Symfony\Component\Lock\LockFactory;
|
||||||
|
@ -21,7 +22,8 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private DbUpdaterInterface $dbUpdater,
|
private DbUpdaterInterface $dbUpdater,
|
||||||
private Reader $geoLiteDbReader,
|
private Reader $geoLiteDbReader,
|
||||||
private LockFactory $locker
|
private LockFactory $locker,
|
||||||
|
private TrackingOptions $trackingOptions
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +32,10 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||||
*/
|
*/
|
||||||
public function checkDbUpdate(?callable $beforeDownload = null, ?callable $handleProgress = null): void
|
public function checkDbUpdate(?callable $beforeDownload = null, ?callable $handleProgress = null): void
|
||||||
{
|
{
|
||||||
|
if ($this->trackingOptions->disableTracking() || $this->trackingOptions->disableIpTracking()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$lock = $this->locker->createLock(self::LOCK_NAME);
|
$lock = $this->locker->createLock(self::LOCK_NAME);
|
||||||
$lock->acquire(true); // Block until lock is released
|
$lock->acquire(true); // Block until lock is released
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
|
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
|
||||||
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdater;
|
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdater;
|
||||||
|
use Shlinkio\Shlink\Core\Options\TrackingOptions;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Exception\RuntimeException;
|
use Shlinkio\Shlink\IpGeolocation\Exception\RuntimeException;
|
||||||
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdaterInterface;
|
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdaterInterface;
|
||||||
use Symfony\Component\Lock;
|
use Symfony\Component\Lock;
|
||||||
|
@ -28,11 +29,13 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||||
private GeolocationDbUpdater $geolocationDbUpdater;
|
private GeolocationDbUpdater $geolocationDbUpdater;
|
||||||
private ObjectProphecy $dbUpdater;
|
private ObjectProphecy $dbUpdater;
|
||||||
private ObjectProphecy $geoLiteDbReader;
|
private ObjectProphecy $geoLiteDbReader;
|
||||||
|
private TrackingOptions $trackingOptions;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->dbUpdater = $this->prophesize(DbUpdaterInterface::class);
|
$this->dbUpdater = $this->prophesize(DbUpdaterInterface::class);
|
||||||
$this->geoLiteDbReader = $this->prophesize(Reader::class);
|
$this->geoLiteDbReader = $this->prophesize(Reader::class);
|
||||||
|
$this->trackingOptions = new TrackingOptions();
|
||||||
|
|
||||||
$locker = $this->prophesize(Lock\LockFactory::class);
|
$locker = $this->prophesize(Lock\LockFactory::class);
|
||||||
$lock = $this->prophesize(Lock\LockInterface::class);
|
$lock = $this->prophesize(Lock\LockInterface::class);
|
||||||
|
@ -45,6 +48,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||||
$this->dbUpdater->reveal(),
|
$this->dbUpdater->reveal(),
|
||||||
$this->geoLiteDbReader->reveal(),
|
$this->geoLiteDbReader->reveal(),
|
||||||
$locker->reveal(),
|
$locker->reveal(),
|
||||||
|
$this->trackingOptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,4 +178,27 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||||
'record_size' => 4,
|
'record_size' => 4,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @dataProvider provideTrackingOptions
|
||||||
|
*/
|
||||||
|
public function downloadDbIsSkippedIfTrackingIsDisabled(array $props): void
|
||||||
|
{
|
||||||
|
foreach ($props as $prop) {
|
||||||
|
$this->trackingOptions->{$prop} = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->geolocationDbUpdater->checkDbUpdate();
|
||||||
|
|
||||||
|
$this->dbUpdater->databaseFileExists(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||||
|
$this->geoLiteDbReader->metadata(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideTrackingOptions(): iterable
|
||||||
|
{
|
||||||
|
yield 'disableTracking' => [['disableTracking']];
|
||||||
|
yield 'disableIpTracking' => [['disableIpTracking']];
|
||||||
|
yield 'both' => [['disableTracking', 'disableIpTracking']];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue