diff --git a/.github/workflows/quality-assurance-php.yml b/.github/workflows/quality-assurance-php.yml index 256b6c0..e716d84 100644 --- a/.github/workflows/quality-assurance-php.yml +++ b/.github/workflows/quality-assurance-php.yml @@ -15,21 +15,25 @@ jobs: secrets: COMPOSER_AUTH_JSON: ${{ secrets.PACKAGIST_AUTH_JSON }} with: - PHP_VERSION: "8.0" + PHP_VERSION: "8.2" static-code-analysis-php: uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main secrets: COMPOSER_AUTH_JSON: ${{ secrets.PACKAGIST_AUTH_JSON }} with: - PHP_VERSION: "8.0" + PHP_VERSION: "8.2" lint-php: uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main + strategy: + matrix: + php: [ "8.2", "8.3" ] with: - PHP_MATRIX: >- - ["8.0", "8.1", "8.2"] + PHP_VERSION: ${{ matrix.php }} tests-unit-php: needs: [ coding-standards-analysis-php, static-code-analysis-php ] uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-php.yml@main + strategy: + matrix: + php: [ "8.2", "8.3" ] with: - PHP_MATRIX: >- - ["8.0", "8.1", "8.2"] + PHP_VERSION: ${{ matrix.php }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 682724f..8b7b021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Degree program URL returns 404 for consuming websites. ## [1.0.2] - 2023-11-23 ### Fixed diff --git a/src/Infrastructure/QueueModule.php b/src/Infrastructure/QueueModule.php index ee7f306..5d8363f 100644 --- a/src/Infrastructure/QueueModule.php +++ b/src/Infrastructure/QueueModule.php @@ -11,6 +11,8 @@ use Fau\DegreeProgram\Common\Infrastructure\Queue\WpCronMessageBus; use Fau\DegreeProgram\Output\Infrastructure\Cache\WarmCacheMessage; use Fau\DegreeProgram\Output\Infrastructure\Cache\WarmCacheMessageHandler; +use Fau\DegreeProgram\Output\Infrastructure\Rewrite\FlushRewriteRulesMessageHandler; +use Fau\DegreeProgram\Output\Infrastructure\Rewrite\FlushRewriteRulesMessage; use Fau\DegreeProgram\Output\Infrastructure\Search\UpdateFilterablePostsMetaMessageHandler; use Fau\DegreeProgram\Output\Infrastructure\Search\UpdateFilterableTermsMessage; use Fau\DegreeProgram\Output\Infrastructure\Search\UpdateFilterableTermsMessageHandler; @@ -46,6 +48,9 @@ public function services(): array UpdateFilterableTermsMessage::class => [ $container->get(UpdateFilterableTermsMessageHandler::class), ], + FlushRewriteRulesMessage::class => [ + $container->get(FlushRewriteRulesMessageHandler::class), + ], ], ), SyncMessageBus::class => static fn(ContainerInterface $container) => new SyncMessageBus( diff --git a/src/Infrastructure/Rewrite/FlushRewriteRulesMessage.php b/src/Infrastructure/Rewrite/FlushRewriteRulesMessage.php new file mode 100644 index 0000000..fd6ab6e --- /dev/null +++ b/src/Infrastructure/Rewrite/FlushRewriteRulesMessage.php @@ -0,0 +1,29 @@ +logger->info('Rewrite rules flushed.'); + } +} diff --git a/src/Infrastructure/Rewrite/RewriteModule.php b/src/Infrastructure/Rewrite/RewriteModule.php index 7ed83ab..9cbf4e3 100644 --- a/src/Infrastructure/Rewrite/RewriteModule.php +++ b/src/Infrastructure/Rewrite/RewriteModule.php @@ -4,11 +4,15 @@ namespace Fau\DegreeProgram\Output\Infrastructure\Rewrite; +use Fau\DegreeProgram\Common\Application\Event\CacheWarmed; +use Fau\DegreeProgram\Common\Application\Queue\MessageBus; +use Fau\DegreeProgram\Output\Infrastructure\Environment\EnvironmentDetector; use Fau\DegreeProgram\Output\Infrastructure\Repository\PostsRepository; use Inpsyde\Modularity\Module\ExecutableModule; use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use Inpsyde\Modularity\Module\ServiceModule; use Psr\Container\ContainerInterface; +use Psr\Log\LoggerInterface; class RewriteModule implements ServiceModule, ExecutableModule { @@ -21,6 +25,12 @@ public function services(): array $container->get(PostsRepository::class) ), CurrentRequest::class => static fn() => new CurrentRequest(), + FlushRewriteRulesMessageHandler::class => static fn(ContainerInterface $container) => new FlushRewriteRulesMessageHandler( + $container->get(LoggerInterface::class), + ), + WhenCacheWarmed::class => static fn(ContainerInterface $container) => new WhenCacheWarmed( + $container->get(MessageBus::class), + ), ]; } @@ -31,6 +41,18 @@ public function run(ContainerInterface $container): bool [$container->get(ModifyRequestArgs::class), 'modify'] ); + if ($container->get(EnvironmentDetector::class)->isProvidingWebsite()) { + return true; + } + + add_action( + CacheWarmed::NAME, + [ + $container->get(WhenCacheWarmed::class), + 'scheduleFlushRewriting', + ] + ); + return true; } } diff --git a/src/Infrastructure/Rewrite/WhenCacheWarmed.php b/src/Infrastructure/Rewrite/WhenCacheWarmed.php new file mode 100644 index 0000000..dd7f955 --- /dev/null +++ b/src/Infrastructure/Rewrite/WhenCacheWarmed.php @@ -0,0 +1,22 @@ +messageBus->dispatch( + FlushRewriteRulesMessage::new(), + ); + } +}