From 1196cb3424f29092b453900a8b051b57c2fcaa88 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Wed, 30 Oct 2024 15:42:28 +0100 Subject: [PATCH] prevent applying str_contains on null value (#167) --- .github/workflows/codeception.yml | 19 +++++++++++-------- .github/workflows/ecs.yml | 10 +++++----- .github/workflows/php-stan.yml | 14 +++++++++----- UPGRADE.md | 2 ++ src/Manager/I18nContextManager.php | 4 ++-- tests/_envs/github.yml | 5 +++-- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index 2bcfe10..083442e 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -40,12 +40,13 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ ~11.0.0 ] + pimcore: [ ~11.2.0 ] include: - - pimcore: ~11.0.0 + - pimcore: ~11.2.0 template_tag: v11.0.0 steps: - - uses: actions/checkout@v2 + - uses: nanasess/setup-chromedriver@v2 + - uses: actions/checkout@v4 with: path: lib/test-bundle @@ -105,9 +106,11 @@ jobs: - name: Setup Chromium run: | - nohup $CHROMEWEBDRIVER/chromedriver --url-base=/wd/hub /dev/null 2>&1 & + export DISPLAY=:99 + chromedriver --url-base=/wd/hub --port=9515 & + sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & - - name: Start Webserver and Chrome + - name: Start Symfony Server run: | curl -sS https://get.symfony.com/cli/installer | bash -s -- --install-dir=$HOME/.symfony/bin ~/.symfony/bin/symfony server:start --port=8080 --dir=public --allow-http --no-tls --daemon @@ -115,10 +118,10 @@ jobs: - name: Get Composer Cache Directory id: composer-cache run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer Downloads - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -150,7 +153,7 @@ jobs: vendor/bin/codecept run --env github -c ${{ github.workspace }}/lib/test-bundle - name: Log Output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: "Logs (PHP ${{ matrix.php }}, Pimcore ${{ matrix.pimcore }}, Symfony ${{ matrix.symfony }})" diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index 91b57be..92e4519 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -39,12 +39,12 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ ~11.0.0 ] + pimcore: [ ~11.2.0 ] include: - - pimcore: ~11.0.0 + - pimcore: ~11.2.0 template_tag: v11.0.0 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: path: lib/test-bundle @@ -88,10 +88,10 @@ jobs: - name: Get Composer Cache Directory id: composer-cache run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer Downloads - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index 4277702..f596488 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -39,12 +39,12 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ ~11.0.0 ] + pimcore: [ ~11.2.0 ] include: - - pimcore: ~11.0.0 + - pimcore: ~11.2.0 template_tag: v11.0.0 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: path: lib/test-bundle @@ -88,10 +88,10 @@ jobs: - name: Get Composer Cache Directory id: composer-cache run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer Downloads - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -110,6 +110,10 @@ jobs: run: | bin/console assets:install public --relative --symlink + - name: Validate Container + run: | + bin/console lint:container + - name: Php Stan run: | bin/console cache:warmup --env=test diff --git a/UPGRADE.md b/UPGRADE.md index c3cae89..cf7d254 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,7 @@ # Upgrade Notes +## 5.1.1 +- [IMPROVEMENT] prevent applying str_contains on null value ## 5.1.0 - [FEATURE] pimcore backend: object preview button ## 5.0.6 diff --git a/src/Manager/I18nContextManager.php b/src/Manager/I18nContextManager.php index 8f8d761..a305198 100644 --- a/src/Manager/I18nContextManager.php +++ b/src/Manager/I18nContextManager.php @@ -109,10 +109,10 @@ protected function buildLocaleDefinition(RouteItemInterface $routeItem): LocaleD $languageIso = $locale; $countryIso = Definitions::INTERNATIONAL_COUNTRY_NAMESPACE; - if (str_contains($baseLocale, '_')) { + if ($baseLocale !== null && str_contains($baseLocale, '_')) { $parts = explode('_', $baseLocale); $languageIso = strtolower($parts[0]); - if (isset($parts[1]) && !empty($parts[1])) { + if (!empty($parts[1])) { $countryIso = strtoupper($parts[1]); } } diff --git a/tests/_envs/github.yml b/tests/_envs/github.yml index ca9cafc..99f9fbe 100644 --- a/tests/_envs/github.yml +++ b/tests/_envs/github.yml @@ -5,8 +5,9 @@ modules: port: 9515 restart: true wait: 1 + window_size: 1280x1024 capabilities: - chromeOptions: - args: ['--no-sandbox', '--disable-extensions', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--window-size=1024,768'] + 'goog:chromeOptions': + args: ['--no-sandbox', '--disable-extensions', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--window-size=1280,1024'] prefs: download.default_directory: '%TEST_BUNDLE_TEST_DIR%/_data/downloads' \ No newline at end of file