diff --git a/.travis.yml b/.travis.yml index 294799a..3ad37c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,19 +21,20 @@ env: - SYMFONY_DEPRECATIONS_HELPER=weak - DACHCOM_TEST_SECTION=codeception - SYMFONY_VERSION=^4.0 + - PIMCORE_PHP_ERROR_REPORTING=32767 # E_ALL matrix: include: - - name: "PHPStan Static Analysis (Pimcore 6.3.x, Symfony ^4.0, PHP 7.3)" + - name: "PHPStan Static Analysis (Pimcore 6.5.x, Symfony ^4.0, PHP 7.4)" sudo: required - php: 7.3 + php: 7.4 env: - - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" - DACHCOM_TEST_SECTION=phpstan - - name: "PHP ECS (Pimcore 6.3.x, Symfony ^4.0, PHP 7.3)" + - name: "PHP ECS (Pimcore 6.5.x, Symfony ^4.0, PHP 7.4)" sudo: required - php: 7.3 + php: 7.4 env: - - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" - DACHCOM_TEST_SECTION=ecs - name: "Codeception Tests (Pimcore 6.0.x, Symfony ^4.3, PHP 7.3)" sudo: required @@ -53,25 +54,33 @@ matrix: env: - SYMFONY_VERSION="~4.3.0" - PIMCORE_SKELETON_BRANCH="tags/v2.2.0" - - name: "Codeception Tests (Pimcore 6.3.x, Symfony ^4.0, PHP 7.2)" + - name: "Codeception Tests (Pimcore 6.3.x, Symfony ^4.0, PHP 7.3)" sudo: required - php: 7.2 + php: 7.3 env: - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" - - name: "Codeception Tests (Pimcore 6.3.x, Symfony ^4.0, PHP 7.3)" + - name: "Codeception Tests (Pimcore 6.5.x, Symfony ^4.0, PHP 7.3)" sudo: required php: 7.3 env: - - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" - - name: "Codeception Tests (Pimcore 6.3.x, Symfony ^3.4, PHP 7.3)" + - PIMCORE_PHP_ERROR_REPORTING=30711 # E_ALL & ~E_NOTICE & ~E_STRICT: remove this after 6.5.2 + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" + - name: "Codeception Tests (Pimcore 6.5.x, Symfony ^3.4, PHP 7.3)" sudo: required php: 7.3 env: - SYMFONY_VERSION=^3.4 - - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" + - PIMCORE_PHP_ERROR_REPORTING=30711 # E_ALL & ~E_NOTICE & ~E_STRICT: remove this after 6.5.2 + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" + - name: "Codeception Tests (Pimcore 6.5.x, Symfony ^4.0, PHP 7.4)" + sudo: required + php: 7.4 + env: + - PIMCORE_PHP_ERROR_REPORTING=30711 # E_ALL & ~E_NOTICE & ~E_STRICT: remove this after 6.5.2 + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" allow_failures: - env: - - PIMCORE_SKELETON_BRANCH="tags/v2.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.5.0" - DACHCOM_TEST_SECTION=ecs fast_finish: true diff --git a/README.md b/README.md index 07a51b1..f1589b3 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ This Bundle helps you mastering this challenges and gives you the freedom to ela | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|-----------------------------------|----------------------------|--------------|----------------|------------| -| **3.x** | `6.0` - `6.3` | `3.4`, `^4.0` | 18.07.2019 | Feature Branch | dev-master | +| **3.x** | `6.0` - `6.3`, `6.5` | `3.4`, `^4.0` | 18.07.2019 | Feature Branch | dev-master | | **2.4** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 24.05.2019 | Bugfix only | 2.4 | ### Installation ```json "require" : { - "dachcom-digital/i18n" : "~3.1.0" + "dachcom-digital/i18n" : "~3.2.0" } ``` @@ -56,8 +56,10 @@ Does actually the same as the update command and preferred in CI-Workflow: ### Preparation - If you're using `system` as your `locale_adapter`, which is the default, you need to enable all required locales in pimcore system settings - Always be sure that every document translation is connected via the [localization tool](https://www.pimcore.org/docs/5.0.0/Multi_Language_i18n/Localize_your_Documents.html). +- If you're using the country detection, you need a valid maxmind geoip [data provider](docs/10_GeoControl.md) ## Further Information +- [Geo IP/Control](docs/10_GeoControl.md): Enable GeoIP Data Provider. - [Zones](docs/20_Zones.md): Learn more about i18n zones and how to manage them. - [Href-Lang](docs/25_HrefLang.md): Find out more about the href-lang tag generator. - [Language Configuration](docs/26_Languages.md): Configure languages. diff --git a/UPGRADE.md b/UPGRADE.md index 42f2ec9..77fb442 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -6,6 +6,12 @@ After every update you should check the pimcore extension manager. Just click the "update" button or execute the migration command to finish the bundle update. +#### Update from Version 3.1.x to Version 3.2.0 +- **[ENHANCEMENT]**: Pimcore 6.5.0 ready +- **[ENHANCEMENT]**: PHP 7.4 Support +- **[IMPORTANT]**: Because of unfixed major issues within Pimcore 6.4.x, we're unable to support this version. We recommend to directly upgrade to pimcore 6.5! +- **[IMPORTANT]**: GeoLite Database is not available automatically due new download restrictions by maxmind. Read more about it [here](./docs/10_GeoControl.md), [here](https://github.com/pimcore/pimcore/issues/5512) and [here](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/) + #### Update from Version 3.1.0 to Version 3.1.1 - **[ENHANCEMENT]**: Use locale instead of languageIso in [Document PathGenerator](https://github.com/dachcom-digital/pimcore-i18n/issues/41) - **[NEW FEATURE]**: Respect [LinkGenerator](https://github.com/dachcom-digital/pimcore-i18n/issues/15) diff --git a/composer.json b/composer.json index 0e49df5..7913ba1 100755 --- a/composer.json +++ b/composer.json @@ -13,13 +13,11 @@ "role": "Developer" } ], - "autoload": { "psr-4": { "I18nBundle\\": "src/I18nBundle" } }, - "extra": { "pimcore": { "bundles": [ @@ -27,8 +25,11 @@ ] } }, + "conflict": { + "pimcore/pimcore": "6.4.*" + }, "require": { - "pimcore/pimcore": "^6.0.0" + "pimcore/pimcore": "^6.0" }, "require-dev": { "codeception/codeception": "~2.4.0", diff --git a/docs/10_GeoControl.md b/docs/10_GeoControl.md new file mode 100644 index 0000000..f21e1d9 --- /dev/null +++ b/docs/10_GeoControl.md @@ -0,0 +1,14 @@ +# Geo Control + +> The Data provider is only required if you want to use the country detection! +> +Follow the [official instructions](https://dev.maxmind.com/geoip/geoipupdate/) for obtaining and updating the GeoIP database. +Store the database file at the location of your choice, the default location used by _geoipupdate_ is `/usr/share/GeoIP/GeoLite2-City.mmdb` + +Set the path to the database file in your `parameters.yml` to enable the geo support in Pimcore: + +```yaml +pimcore.geoip.db_file: /usr/share/GeoIP/GeoLite2-City.mmdb +``` + +To keep the BC, I18n also will check the project path `var/config/GeoLite2-City.mmdb` for legacy reasons. \ No newline at end of file diff --git a/src/I18nBundle/DependencyInjection/Configuration.php b/src/I18nBundle/DependencyInjection/Configuration.php index beb6c03..b24e0c3 100644 --- a/src/I18nBundle/DependencyInjection/Configuration.php +++ b/src/I18nBundle/DependencyInjection/Configuration.php @@ -64,7 +64,7 @@ public function getConfigTreeBuilder() ->prototype('array') ->children() ->integerNode('id')->isRequired()->end() - ->scalarNode('name')->end() + ->scalarNode('name')->defaultValue(null)->end() ->arrayNode('domains') ->prototype('scalar')->end() ->end() diff --git a/src/I18nBundle/DependencyInjection/I18nExtension.php b/src/I18nBundle/DependencyInjection/I18nExtension.php index 953b04b..ab38848 100644 --- a/src/I18nBundle/DependencyInjection/I18nExtension.php +++ b/src/I18nBundle/DependencyInjection/I18nExtension.php @@ -29,5 +29,14 @@ public function load(array $configs, ContainerBuilder $container) $configManagerDefinition->addMethodCall('setConfig', [$config]); $container->setParameter('i18n.registry_availability', $config['registry']); + + // set geo db path (including legacy path) + if ($container->hasParameter('pimcore.geoip.db_file') && !is_null($container->getParameter('pimcore.geoip.db_file'))) { + $geoIpDbFile = $container->getParameter('pimcore.geoip.db_file'); + } else { + $geoIpDbFile = realpath(PIMCORE_CONFIGURATION_DIRECTORY . '/GeoLite2-City.mmdb'); + } + + $container->setParameter('i18n.geo_ip.db_file', is_string($geoIpDbFile) ? $geoIpDbFile : ''); } } diff --git a/src/I18nBundle/EventListener/ContextSwitchDetectorListener.php b/src/I18nBundle/EventListener/ContextSwitchDetectorListener.php index d6fe67c..5cede57 100644 --- a/src/I18nBundle/EventListener/ContextSwitchDetectorListener.php +++ b/src/I18nBundle/EventListener/ContextSwitchDetectorListener.php @@ -119,7 +119,14 @@ public static function getSubscribedEvents() */ public function onKernelRequest(GetResponseEvent $event) { - if ($this->pimcoreConfig['cache']['enabled'] === true) { + $fullPageEnabled = false; + if (isset($this->pimcoreConfig['cache']) && isset($this->pimcoreConfig['cache']['enabled'])) { + $fullPageEnabled = $this->pimcoreConfig['cache']['enabled']; + } elseif (isset($this->pimcoreConfig['full_page_cache']) && isset($this->pimcoreConfig['full_page_cache']['enabled'])) { + $fullPageEnabled = $this->pimcoreConfig['full_page_cache']['enabled']; + } + + if ($fullPageEnabled === true) { return; } diff --git a/src/I18nBundle/Helper/UserHelper.php b/src/I18nBundle/Helper/UserHelper.php index 197575d..d80d990 100644 --- a/src/I18nBundle/Helper/UserHelper.php +++ b/src/I18nBundle/Helper/UserHelper.php @@ -12,12 +12,21 @@ class UserHelper */ protected $requestStack; + /** + * @var string + */ + protected $geoIpDbPath; + /** * @param RequestStack $requestStack + * @param string $geoIpDbPath */ - public function __construct(RequestStack $requestStack) - { + public function __construct( + RequestStack $requestStack, + string $geoIpDbPath + ) { $this->requestStack = $requestStack; + $this->geoIpDbPath = $geoIpDbPath; } /** @@ -43,17 +52,14 @@ public function guessLanguage() */ public function guessCountry() { - $masterRequest = $this->requestStack->getMasterRequest(); - - $geoDbFile = realpath(PIMCORE_CONFIGURATION_DIRECTORY . '/GeoLite2-City.mmdb'); $record = null; - $country = null; $userCountry = false; + $masterRequest = $this->requestStack->getMasterRequest(); - if (file_exists($geoDbFile)) { + if (file_exists($this->geoIpDbPath)) { try { - $reader = new Reader($geoDbFile); + $reader = new Reader($this->geoIpDbPath); if ($masterRequest->server->has('HTTP_CLIENT_IP') && !empty($masterRequest->server->get('HTTP_CLIENT_IP'))) { $ip = $masterRequest->server->get('HTTP_CLIENT_IP'); @@ -67,6 +73,7 @@ public function guessCountry() $record = $reader->city($ip); $country = $record->country->isoCode; } catch (\Exception $e) { + // fail silently. } } diff --git a/src/I18nBundle/Resources/config/services/helper.yml b/src/I18nBundle/Resources/config/services/helper.yml index 535168b..f215ff6 100644 --- a/src/I18nBundle/Resources/config/services/helper.yml +++ b/src/I18nBundle/Resources/config/services/helper.yml @@ -9,6 +9,9 @@ services: I18nBundle\Helper\CookieHelper: ~ - I18nBundle\Helper\UserHelper: ~ + I18nBundle\Helper\RequestValidatorHelper: ~ - I18nBundle\Helper\RequestValidatorHelper: ~ \ No newline at end of file + I18nBundle\Helper\UserHelper: + arguments: + $requestStack: '@request_stack' + $geoIpDbPath: '%i18n.geo_ip.db_file%' diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index d2c1c9b..1b5545f 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -6,6 +6,7 @@ include __DIR__ . '/../../../vendor/autoload.php'; define('PIMCORE_KERNEL_CLASS', '\DachcomBundle\Test\App\TestAppKernel'); +define('PIMCORE_TEST', true); Bootstrap::setProjectRoot(); Bootstrap::bootstrap(); @@ -20,4 +21,11 @@ define('TESTS_PATH', __DIR__); } -define('PIMCORE_TEST', true); +if (!isset($_SERVER['REQUEST_URI'])) { + $_SERVER['REQUEST_URI'] = ''; +} + +if (!isset($_SERVER['HTTP_USER_AGENT'])) { + $_SERVER['HTTP_USER_AGENT'] = ''; +} + diff --git a/tests/_etc/config/bundle/symfony/config_full_page_cache.yml b/tests/_etc/config/bundle/symfony/config_full_page_cache.yml index 452ff53..e87a74f 100755 --- a/tests/_etc/config/bundle/symfony/config_full_page_cache.yml +++ b/tests/_etc/config/bundle/symfony/config_full_page_cache.yml @@ -5,5 +5,7 @@ i18n: translations: ~ pimcore: + full_page_cache: + enabled: true cache: enabled: true diff --git a/tests/_etc/config/bundle/system.yml.template b/tests/_etc/config/bundle/system.yml.template index dd707f5..72104f9 100755 --- a/tests/_etc/config/bundle/system.yml.template +++ b/tests/_etc/config/bundle/system.yml.template @@ -48,9 +48,14 @@ pimcore: browser_api_key: '' cache: exclude_cookie: '' - enabled: true + enabled: false lifetime: null exclude_patterns: '' + full_page_cache: + enabled: false + lifetime: null + exclude_patterns: '' + exclude_cookie: '' httpclient: adapter: Socket proxy_host: '' diff --git a/tests/_etc/travis/install b/tests/_etc/travis/install index fae4f1d..9fae562 100755 --- a/tests/_etc/travis/install +++ b/tests/_etc/travis/install @@ -43,13 +43,10 @@ do cp $K ${DACHCOM_INSTALL_CONFIG_FILES[$K]}; done - ## load GeoLite2 - -wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz -gzip -d GeoLite2-City.mmdb.gz -mv -nv GeoLite2-City.mmdb var/config/ - +git clone -b 4.0.1 --single-branch https://github.com/geocoder-php/geoip2-provider +cp ./geoip2-provider/Tests/fixtures/GeoLite2-City.mmdb var/config/ +rm -rf geoip2-provider ## install composer dependencies rm composer.lock diff --git a/tests/_support/App/Pimcore/TestConfig.php b/tests/_support/App/Pimcore/TestConfig.php new file mode 100644 index 0000000..ab356a6 --- /dev/null +++ b/tests/_support/App/Pimcore/TestConfig.php @@ -0,0 +1,22 @@ +addCompilerPass(new ServiceChangePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -100000); $container->addCompilerPass(new MakeServicesPublicPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -100000); $container->addCompilerPass(new MonologChannelLoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); } diff --git a/tests/_support/DependencyInjection/ServiceChangePass.php b/tests/_support/DependencyInjection/ServiceChangePass.php new file mode 100644 index 0000000..415dd52 --- /dev/null +++ b/tests/_support/DependencyInjection/ServiceChangePass.php @@ -0,0 +1,28 @@ +hasDefinition('Pimcore\Config')) { + return; + } + + $testService = new Definition(TestConfig::class); + $testService->setPublic(true); + + $container->setDefinition(TestConfig::class, $testService); + $container->getDefinition(Pimcore\Config::class)->setClass(TestConfig::class); + } +} diff --git a/tests/_support/Helper/PimcoreBackend.php b/tests/_support/Helper/PimcoreBackend.php index bff09bd..29293d7 100644 --- a/tests/_support/Helper/PimcoreBackend.php +++ b/tests/_support/Helper/PimcoreBackend.php @@ -335,6 +335,10 @@ public function haveTwoConnectedDocuments(Page $sourceDocument, Page $targetDocu */ public function haveAUnPublishedDocument(Document $document) { + if (method_exists($document, 'setMissingRequiredEditable')) { + $document->setMissingRequiredEditable(false); + } + $document->setPublished(false); try { @@ -423,7 +427,7 @@ public function submitDocumentToXliffExporter(Document $document) 'type' => 'xliff' ]); - $this->assertContains(['successs' => true], json_decode($pimcoreCore->_getResponseContent(), true)); + $this->assertContains(['success' => true], json_decode($pimcoreCore->_getResponseContent(), true)); } /** @@ -476,7 +480,6 @@ protected function generateHardlink(Page $source, $key = 'hardlink-test', $local return $hardlink; } - /** * API Function to create a link document * @@ -504,8 +507,6 @@ protected function generateLink(Page $source, $key = 'link-test', $locale = null return $link; } - - /** * API Function to create a site document * diff --git a/tests/_support/Helper/PimcoreCore.php b/tests/_support/Helper/PimcoreCore.php index 782ac3d..cd63810 100644 --- a/tests/_support/Helper/PimcoreCore.php +++ b/tests/_support/Helper/PimcoreCore.php @@ -233,7 +233,6 @@ protected function setConfiguration($configuration = null) $resource = $bundleClass . '/_etc/config/bundle/symfony/' . $configuration; $fileSystem->dumpFile($runtimeConfigDirConfig, file_get_contents($resource)); - } /** diff --git a/tests/functional.default.country.suite.dist.yml b/tests/functional.default.country.suite.dist.yml index 6dd149a..5284405 100644 --- a/tests/functional.default.country.suite.dist.yml +++ b/tests/functional.default.country.suite.dist.yml @@ -1,4 +1,5 @@ actor: FunctionalTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: diff --git a/tests/functional.default.suite.dist.yml b/tests/functional.default.suite.dist.yml index 90fd61f..d681724 100644 --- a/tests/functional.default.suite.dist.yml +++ b/tests/functional.default.suite.dist.yml @@ -1,4 +1,5 @@ actor: FunctionalTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: diff --git a/tests/functional.full_page_cache.suite.dist.yml b/tests/functional.full_page_cache.suite.dist.yml index f0890ba..8c2a9d2 100644 --- a/tests/functional.full_page_cache.suite.dist.yml +++ b/tests/functional.full_page_cache.suite.dist.yml @@ -1,4 +1,5 @@ actor: FunctionalTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: diff --git a/tests/functional.zone.extended.suite.dist.yml b/tests/functional.zone.extended.suite.dist.yml index d7c7dfe..35add1e 100644 --- a/tests/functional.zone.extended.suite.dist.yml +++ b/tests/functional.zone.extended.suite.dist.yml @@ -1,4 +1,5 @@ actor: FunctionalTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: diff --git a/tests/functional.zone.simple.suite.dist.yml b/tests/functional.zone.simple.suite.dist.yml index 7dedb8d..b6fbc8b 100644 --- a/tests/functional.zone.simple.suite.dist.yml +++ b/tests/functional.zone.simple.suite.dist.yml @@ -1,4 +1,5 @@ actor: FunctionalTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: diff --git a/tests/unit.suite.dist.yml b/tests/unit.suite.dist.yml index 7ab507d..08186e2 100644 --- a/tests/unit.suite.dist.yml +++ b/tests/unit.suite.dist.yml @@ -1,4 +1,5 @@ actor: UnitTester +error_level: 'getenv("PIMCORE_PHP_ERROR_REPORTING")' modules: enabled: - \DachcomBundle\Test\Helper\PimcoreCore: