diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59ec61b..e9e98cf 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 @@ -20,7 +23,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: @@ -28,7 +31,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 @@ -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 & @@ -92,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 }} @@ -152,7 +155,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 +169,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 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", diff --git a/src/Command/AlertCommand.php b/src/Command/AlertCommand.php index bcf898b..5aebed8 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; @@ -41,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(); @@ -62,7 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $productVariant->getProduct()?->isEnabled() === true ) { $this->router->getContext()->setHost($channel->getHostname() ?? 'localhost'); - $this->sendEmail($subscription, $productVariant, $channel); + + try { + $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); $this->backInStockNotificationRepository->add($subscription); } 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/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) 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; /**