From d2e8c9caed7e2b705ccb9d9f8e18be2d8eb1d5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Weyhaupt?= Date: Thu, 11 Dec 2025 10:51:16 +0100 Subject: [PATCH 01/11] fix(email): reinforcement of the validator and skip invalid address when sending alerts --- src/Command/AlertCommand.php | 44 ++++++++++++++++++++--------------- src/Form/SubscriptionType.php | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/Command/AlertCommand.php b/src/Command/AlertCommand.php index bcf898b..f14591c 100644 --- a/src/Command/AlertCommand.php +++ b/src/Command/AlertCommand.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Mime\Exception\RfcComplianceException; use Symfony\Component\Routing\RouterInterface; use Webgriffe\SyliusBackInStockNotificationPlugin\Entity\SubscriptionInterface; use Webgriffe\SyliusBackInStockNotificationPlugin\Repository\SubscriptionRepositoryInterface; @@ -44,27 +45,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int //I think that this load in the long time can be a bottle necklace $subscriptions = $this->backInStockNotificationRepository->findBy(['notify' => false]); foreach ($subscriptions as $subscription) { - $channel = $subscription->getChannel(); - $productVariant = $subscription->getProductVariant(); - if ($productVariant === null || $channel === null) { - $this->backInStockNotificationRepository->remove($subscription); - $this->logger->warning( - 'The back in stock subscription for the product does not have all the information required', - ['subscription' => var_export($subscription, true)], - ); + try { + $channel = $subscription->getChannel(); + $productVariant = $subscription->getProductVariant(); + if ($productVariant === null || $channel === null) { + $this->backInStockNotificationRepository->remove($subscription); + $this->logger->warning( + 'The back in stock subscription for the product does not have all the information required', + ['subscription' => var_export($subscription, true)], + ); - continue; - } + continue; + } - if ( - $this->availabilityChecker->isStockAvailable($productVariant) && - $productVariant->isEnabled() && - $productVariant->getProduct()?->isEnabled() === true - ) { - $this->router->getContext()->setHost($channel->getHostname() ?? 'localhost'); - $this->sendEmail($subscription, $productVariant, $channel); - $subscription->setNotify(true); - $this->backInStockNotificationRepository->add($subscription); + if ( + $this->availabilityChecker->isStockAvailable($productVariant) && + $productVariant->isEnabled() && + $productVariant->getProduct()?->isEnabled() === true + ) { + $this->router->getContext()->setHost($channel->getHostname() ?? 'localhost'); + $this->sendEmail($subscription, $productVariant, $channel); + $subscription->setNotify(true); + $this->backInStockNotificationRepository->add($subscription); + } + } catch (RfcComplianceException $e) { + // Invalid email address, continue to the next one + $this->logger->warning($e->getMessage()); } } diff --git a/src/Form/SubscriptionType.php b/src/Form/SubscriptionType.php index 4c60ddd..a2ed9f6 100644 --- a/src/Form/SubscriptionType.php +++ b/src/Form/SubscriptionType.php @@ -25,7 +25,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('email', EmailType::class, [ 'constraints' => [ new NotBlank([], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']), - new Email([], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']), + new Email(['mode' => Email::VALIDATION_MODE_STRICT], null, null, null, ['webgriffe_sylius_back_in_stock_notification_plugin']), ], ]) ->add('product_variant_code', HiddenType::class) From 862332ae14f9bbdf26fb5ea99f5e6a2baa2d15f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Weyhaupt?= Date: Tue, 10 Mar 2026 07:45:49 +0100 Subject: [PATCH 02/11] fix(email): refacto try catch and log --- src/Command/AlertCommand.php | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Command/AlertCommand.php b/src/Command/AlertCommand.php index f14591c..ed18951 100644 --- a/src/Command/AlertCommand.php +++ b/src/Command/AlertCommand.php @@ -45,32 +45,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int //I think that this load in the long time can be a bottle necklace $subscriptions = $this->backInStockNotificationRepository->findBy(['notify' => false]); foreach ($subscriptions as $subscription) { - try { - $channel = $subscription->getChannel(); - $productVariant = $subscription->getProductVariant(); - if ($productVariant === null || $channel === null) { - $this->backInStockNotificationRepository->remove($subscription); - $this->logger->warning( - 'The back in stock subscription for the product does not have all the information required', - ['subscription' => var_export($subscription, true)], - ); + $channel = $subscription->getChannel(); + $productVariant = $subscription->getProductVariant(); + if ($productVariant === null || $channel === null) { + $this->backInStockNotificationRepository->remove($subscription); + $this->logger->warning( + 'The back in stock subscription for the product does not have all the information required', + ['subscription' => var_export($subscription, true)], + ); - continue; - } + continue; + } - if ( - $this->availabilityChecker->isStockAvailable($productVariant) && - $productVariant->isEnabled() && - $productVariant->getProduct()?->isEnabled() === true - ) { - $this->router->getContext()->setHost($channel->getHostname() ?? 'localhost'); + if ( + $this->availabilityChecker->isStockAvailable($productVariant) && + $productVariant->isEnabled() && + $productVariant->getProduct()?->isEnabled() === true + ) { + $this->router->getContext()->setHost($channel->getHostname() ?? 'localhost'); + + try { $this->sendEmail($subscription, $productVariant, $channel); - $subscription->setNotify(true); - $this->backInStockNotificationRepository->add($subscription); + } catch (RfcComplianceException $e) { + $this->logger->warning('Invalid email address, continue to the next one: ' . $e->getMessage()); + continue; } - } catch (RfcComplianceException $e) { - // Invalid email address, continue to the next one - $this->logger->warning($e->getMessage()); + $subscription->setNotify(true); + $this->backInStockNotificationRepository->add($subscription); } } From 7afa2f1c7a3e7b935d52b09d5a4f0f1a7c776e93 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 10 Mar 2026 09:22:25 +0100 Subject: [PATCH 03/11] Fix comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Command/AlertCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/AlertCommand.php b/src/Command/AlertCommand.php index ed18951..d771156 100644 --- a/src/Command/AlertCommand.php +++ b/src/Command/AlertCommand.php @@ -42,7 +42,7 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - //I think that this load in the long time can be a bottle necklace + // I think that this load in the long time can be a bottleneck $subscriptions = $this->backInStockNotificationRepository->findBy(['notify' => false]); foreach ($subscriptions as $subscription) { $channel = $subscription->getChannel(); From 02e5cf28e9a3e564e28e830e76f017ad7f106b50 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 09:49:39 +0100 Subject: [PATCH 04/11] Build with latest Sylius --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59ec61b..c88a3cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: matrix: php: [ "8.1", "8.2", "8.3" ] symfony: [ "^5.4", "^6.4" ] - sylius: [ "1.12.16", "1.13.1"] + sylius: [ "^1.12", "^1.13"] node: [ "18.x", "20.x" ] mysql: [ "8.0" ] env: From 11505f89e3711c8f259cc735cafc42300cd70224 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 09:49:51 +0100 Subject: [PATCH 05/11] Fix ecs --- src/Command/AlertCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Command/AlertCommand.php b/src/Command/AlertCommand.php index d771156..5aebed8 100644 --- a/src/Command/AlertCommand.php +++ b/src/Command/AlertCommand.php @@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // I think that this load in the long time can be a bottleneck $subscriptions = $this->backInStockNotificationRepository->findBy(['notify' => false]); foreach ($subscriptions as $subscription) { - $channel = $subscription->getChannel(); + $channel = $subscription->getChannel(); $productVariant = $subscription->getProductVariant(); if ($productVariant === null || $channel === null) { $this->backInStockNotificationRepository->remove($subscription); @@ -68,6 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->sendEmail($subscription, $productVariant, $channel); } catch (RfcComplianceException $e) { $this->logger->warning('Invalid email address, continue to the next one: ' . $e->getMessage()); + continue; } $subscription->setNotify(true); From e345fb79601721698294cdf0e3e9e9f519212a64 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 09:58:41 +0100 Subject: [PATCH 06/11] Update actions versions --- .github/workflows/build.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c88a3cf..ebc56cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -152,7 +152,7 @@ jobs: run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun - name: Upload Behat logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: Behat logs @@ -166,9 +166,7 @@ jobs: PHP_VERSION: 8.2 steps: - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 From a65599d625ea3889a770fb4a3ea75ca68c6dce46 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 10:05:44 +0100 Subject: [PATCH 07/11] Adapts build --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ebc56cb..104881b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,9 @@ on: types: [ created ] workflow_dispatch: ~ +env: + DOCKER_API_VERSION: '1.44' + jobs: tests: runs-on: ubuntu-latest @@ -56,7 +59,7 @@ jobs: run: php -v | head -n 1 | awk '{ print $2 }' > .php-version - name: Install certificates - run: symfony server:ca:install + run: symfony server:ca:install || true - name: Run Chrome Headless run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & @@ -169,7 +172,7 @@ jobs: uses: actions/checkout@v4 - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2f with: php-version: "${{ env.PHP_VERSION }}" extensions: intl From 5f287d25d511e6b86ad2e4e33cb7af164aa9aab0 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 10:11:58 +0100 Subject: [PATCH 08/11] Temporarily ignore security advisories --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 104881b..e58ff58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,7 +95,7 @@ jobs: run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction - name: Install PHP dependencies - run: composer install --no-interaction --no-plugins + run: composer install --no-interaction --no-plugins --no-security-blocking env: SYMFONY_REQUIRE: ${{ matrix.symfony }} From 8eb9ccdf411638d8292f7fbc5d4bd86a7c74a585 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 10:17:14 +0100 Subject: [PATCH 09/11] Require soft dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index e4cc22e..8916baa 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "symfony/framework-bundle": "^5.4 || ^6.0", "symfony/http-foundation": "^5.4 || ^6.0", "symfony/http-kernel": "^5.4 || ^6.0", + "symfony/mime": "^5.4 || ^6.0", "symfony/options-resolver": "^5.4 || ^6.0", "symfony/routing": "^5.4 || ^6.0", "symfony/translation-contracts": "^2.0", From c48c3642339b5603ec0218a2eab79a20f1c81b33 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 11:41:39 +0100 Subject: [PATCH 10/11] Fix phpstan --- src/Controller/SubscriptionController.php | 2 +- src/Repository/SubscriptionRepositoryInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/SubscriptionController.php b/src/Controller/SubscriptionController.php index 87f1bce..bb7b8d0 100644 --- a/src/Controller/SubscriptionController.php +++ b/src/Controller/SubscriptionController.php @@ -12,7 +12,7 @@ use Sylius\Component\Inventory\Checker\AvailabilityCheckerInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Sylius\Component\Mailer\Sender\SenderInterface; -use Sylius\Component\Resource\Factory\FactoryInterface; +use Sylius\Resource\Factory\FactoryInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Repository/SubscriptionRepositoryInterface.php b/src/Repository/SubscriptionRepositoryInterface.php index 48aecb5..3853e20 100644 --- a/src/Repository/SubscriptionRepositoryInterface.php +++ b/src/Repository/SubscriptionRepositoryInterface.php @@ -5,7 +5,7 @@ namespace Webgriffe\SyliusBackInStockNotificationPlugin\Repository; use Doctrine\ORM\QueryBuilder; -use Sylius\Component\Resource\Repository\RepositoryInterface; +use Sylius\Resource\Doctrine\Persistence\RepositoryInterface; use Webgriffe\SyliusBackInStockNotificationPlugin\Entity\SubscriptionInterface; /** From 56597116029c1dfb81890ed799219a19447ed31c Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Tue, 10 Mar 2026 12:29:48 +0100 Subject: [PATCH 11/11] Typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e58ff58..e9e98cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,7 +172,7 @@ jobs: uses: actions/checkout@v4 - name: Setup PHP - uses: shivammathur/setup-php@v2f + uses: shivammathur/setup-php@v2 with: php-version: "${{ env.PHP_VERSION }}" extensions: intl