From 25a6a0c3a8d689368011fa62974a7e7979b9cd33 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 00:21:48 +0100 Subject: [PATCH 01/11] :arrow_up: remove unused coduo/php-matcher dependency - issue #3551 --- composer.json | 1 - symfony.lock | 6 ------ 2 files changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 4cb2e4c9d..c5d2e4cdf 100644 --- a/composer.json +++ b/composer.json @@ -97,7 +97,6 @@ "bobdenotter/configuration-notices": "^1.2", "bobdenotter/weatherwidget": "^1.1", "bolt/newswidget": "^1.3", - "coduo/php-matcher": "^5.0", "dama/doctrine-test-bundle": "^6.6.0", "nyholm/psr7": "^1.4", "ondram/ci-detector": "^4.1", diff --git a/symfony.lock b/symfony.lock index 132d45ee2..7439c5acd 100644 --- a/symfony.lock +++ b/symfony.lock @@ -46,12 +46,6 @@ "cocur/slugify": { "version": "v4.0.0" }, - "coduo/php-matcher": { - "version": "4.0.0" - }, - "coduo/php-to-string": { - "version": "3.0.0" - }, "composer/ca-bundle": { "version": "1.2.6" }, From fa74e7b7078d0e386c701fef4fc640f9979d05c2 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 08:43:03 +0100 Subject: [PATCH 02/11] remove about --- templates/pages/about.html.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/pages/about.html.twig b/templates/pages/about.html.twig index d795f8951..1f62346b6 100644 --- a/templates/pages/about.html.twig +++ b/templates/pages/about.html.twig @@ -80,7 +80,6 @@
  • PHPUnit.
  • phpspec.
  • Cypress.
  • -
  • PHP Matcher.
  • PHP Stan.
  • Easy Coding Standard.
  • Blackfire.
  • From d9b7da31ea7ca423678e0d870bb8b1aa3ad5b8e9 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:43:42 +0100 Subject: [PATCH 03/11] add artifact on failure --- .github/workflows/api_tests.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/api_tests.yaml b/.github/workflows/api_tests.yaml index 89d7658ec..2c13a4328 100644 --- a/.github/workflows/api_tests.yaml +++ b/.github/workflows/api_tests.yaml @@ -37,3 +37,9 @@ jobs: run: curl -fkI -u apiuser:apiuser%1 http://localhost:8088/api/fields - name: check API user gets relations run: curl -fkI -u apiuser:apiuser%1 http://localhost:8088/api/relations + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: logs + path: var/log + From c421a75fb9c92ad129b866bac86d2fb27ac2e644 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:14:56 +0100 Subject: [PATCH 04/11] load fixture --- .github/workflows/api_tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api_tests.yaml b/.github/workflows/api_tests.yaml index 2c13a4328..b913e1b32 100644 --- a/.github/workflows/api_tests.yaml +++ b/.github/workflows/api_tests.yaml @@ -28,6 +28,7 @@ jobs: sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/ ./bin/console doctrine:database:create ./bin/console doctrine:schema:create + ./bin/console doctrine:fixtures:load -n symfony server:start --no-tls --port=8088 -d - name: create api user run: php bin/console bolt:add-user apiuser apiuser%1 api@example.org API --roles=ROLE_WEBSERVICE From 80cf4c9c3de6508e20b5f7b309e0663de1ae1248 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:26:45 +0100 Subject: [PATCH 05/11] Fix PHP Stan error --- src/Doctrine/Functions/Rand.php | 2 +- src/Doctrine/Query/Cast.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Doctrine/Functions/Rand.php b/src/Doctrine/Functions/Rand.php index 2056ae348..3ce195cb3 100644 --- a/src/Doctrine/Functions/Rand.php +++ b/src/Doctrine/Functions/Rand.php @@ -33,7 +33,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); - if ($lexer->lookahead['type'] !== Lexer::T_CLOSE_PARENTHESIS) { + if ($lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS) { $this->expression = $parser->SimpleArithmeticExpression(); } diff --git a/src/Doctrine/Query/Cast.php b/src/Doctrine/Query/Cast.php index e8c34baa0..44d176f74 100644 --- a/src/Doctrine/Query/Cast.php +++ b/src/Doctrine/Query/Cast.php @@ -30,19 +30,19 @@ public function getSql(SqlWalker $sqlWalker): string // alternatively, test if true: $this->first->dispatch($sqlWalker)==='b2_.value', // b4_.value for /bolt/new/showcases if ($this->first->dispatch($sqlWalker) === 'b2_.value' || - $this->first->dispatch($sqlWalker) === 'b4_.value') { + $this->first->dispatch($sqlWalker) === 'b4_.value') { return $this->first->dispatch($sqlWalker); } } - if (! mb_strpos($backend_driver, 'sqlite') && $this->second === 'TEXT') { + if (!mb_strpos($backend_driver, 'sqlite') && $this->second === 'TEXT') { $this->second = 'CHAR'; } return sprintf('CAST(%s AS %s)', $this->first->dispatch($sqlWalker), $this->second - ); + ); } public function parse(Parser $parser): void @@ -52,7 +52,7 @@ public function parse(Parser $parser): void $this->first = $parser->ArithmeticPrimary(); $parser->match(Lexer::T_AS); $parser->match(Lexer::T_IDENTIFIER); - $this->second = $parser->getLexer()->token['value']; + $this->second = $parser->getLexer()->token->value; $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } From 7d4e7b8e6578a2c9d8a623e3bd7490e357405ab7 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:37:26 +0100 Subject: [PATCH 06/11] Fix API Test --- src/Entity/Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Field.php b/src/Entity/Field.php index d6f99797a..3154bde2c 100644 --- a/src/Entity/Field.php +++ b/src/Entity/Field.php @@ -80,7 +80,7 @@ class Field implements FieldInterface, TranslatableInterface private $version; /** - * @ORM\ManyToOne(targetEntity="Bolt\Entity\Content", inversedBy="fields", fetch="EAGER") + * @ORM\ManyToOne(targetEntity="Bolt\Entity\Content", inversedBy="fields") * @ORM\JoinColumn(nullable=false) * @Groups("api_write") */ From 1393b88302ae581aefcdfb73c07d98a4b237c6bc Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:55:06 +0100 Subject: [PATCH 07/11] revert change in api test workflow --- .github/workflows/api_tests.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/api_tests.yaml b/.github/workflows/api_tests.yaml index b913e1b32..89d7658ec 100644 --- a/.github/workflows/api_tests.yaml +++ b/.github/workflows/api_tests.yaml @@ -28,7 +28,6 @@ jobs: sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/ ./bin/console doctrine:database:create ./bin/console doctrine:schema:create - ./bin/console doctrine:fixtures:load -n symfony server:start --no-tls --port=8088 -d - name: create api user run: php bin/console bolt:add-user apiuser apiuser%1 api@example.org API --roles=ROLE_WEBSERVICE @@ -38,9 +37,3 @@ jobs: run: curl -fkI -u apiuser:apiuser%1 http://localhost:8088/api/fields - name: check API user gets relations run: curl -fkI -u apiuser:apiuser%1 http://localhost:8088/api/relations - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: logs - path: var/log - From ea9b764e3621221560f02af9a90f23548510ee59 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:23:07 +0100 Subject: [PATCH 08/11] review change, change with query --- src/Api/Extensions/ContentExtension.php | 23 ++++++++++++++++++----- src/Entity/Field.php | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Api/Extensions/ContentExtension.php b/src/Api/Extensions/ContentExtension.php index abb51291b..386c31000 100644 --- a/src/Api/Extensions/ContentExtension.php +++ b/src/Api/Extensions/ContentExtension.php @@ -34,8 +34,12 @@ public function __construct(Config $config) })->values(); } - public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?string $operationName = null): void - { + public function applyToCollection( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + ?string $operationName = null + ): void { /* * Note: We're not distinguishing between `viewless` and `viewless_listing` here. In the * context of the API it makes no sense to say "You can get a list, but not the details" @@ -51,8 +55,14 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator } } - public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, ?string $operationName = null, array $context = []): void - { + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + ?string $operationName = null, + array $context = [] + ): void { if ($resourceClass === Content::class) { $this->filterUnpublishedViewlessContent($queryBuilder); } @@ -78,7 +88,10 @@ private function filterUnpublishedViewlessContent(QueryBuilder $queryBuilder): v private function filterUnpublishedViewlessFields(QueryBuilder $queryBuilder): void { $rootAlias = $queryBuilder->getRootAliases()[0]; - $queryBuilder->join($rootAlias . '.content', 'c', Join::WITH, 'c.status = :status'); + + $queryBuilder->join($rootAlias . '.content', 'c'); + $queryBuilder->andWhere('c.status = :status'); + $queryBuilder->setParameter('status', Statuses::PUBLISHED); //todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed. diff --git a/src/Entity/Field.php b/src/Entity/Field.php index 3154bde2c..d6f99797a 100644 --- a/src/Entity/Field.php +++ b/src/Entity/Field.php @@ -80,7 +80,7 @@ class Field implements FieldInterface, TranslatableInterface private $version; /** - * @ORM\ManyToOne(targetEntity="Bolt\Entity\Content", inversedBy="fields") + * @ORM\ManyToOne(targetEntity="Bolt\Entity\Content", inversedBy="fields", fetch="EAGER") * @ORM\JoinColumn(nullable=false) * @Groups("api_write") */ From da9fe824c11e3b698c0d68fb98121fc96362f857 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:34:04 +0100 Subject: [PATCH 09/11] add MySQL for API test --- .github/workflows/api_tests.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/api_tests.yaml b/.github/workflows/api_tests.yaml index 89d7658ec..ce8ba875f 100644 --- a/.github/workflows/api_tests.yaml +++ b/.github/workflows/api_tests.yaml @@ -8,8 +8,25 @@ jobs: strategy: matrix: php-version: [ '8.1', '8.2', '8.3', '8.4' ] + database: + - 'sqlite:///%kernel.project_dir%/var/data/bolt.sqlite' + - 'mysql://bolt:bolt@127.0.0.1/bolt?serverVersion=5.7&charset=utf8mb4' name: curl tests + services: + mysql: + image: mysql:5.7 + ports: + - "3306:3306" + env: + MYSQL_DATABASE: bolt + MYSQL_USER: bolt + MYSQL_PASSWORD: bolt + MYSQL_ROOT_PASSWORD: bolt + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + runs-on: ubuntu-latest + env: + DATABASE_URL: ${{matrix.database}} steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 From a46a8f596d79ed454888a6c37cc80f932762cdcc Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 22:18:28 +0100 Subject: [PATCH 10/11] add doctrine/lexer dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index c5d2e4cdf..cf0edab74 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "doctrine/doctrine-bundle": "^2.4", "doctrine/doctrine-fixtures-bundle": "^3.4", "doctrine/doctrine-migrations-bundle": "^3.2", + "doctrine/lexer": "^2 || ^3", "doctrine/orm": "^2.10", "drupol/composer-packages": "^2.0", "embed/embed": "^3.4", From 5227b1f2bd739ed48289294f15b1b2dd00fa053a Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 12 Mar 2025 22:22:41 +0100 Subject: [PATCH 11/11] create db only for sqlite --- .github/workflows/api_tests.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/api_tests.yaml b/.github/workflows/api_tests.yaml index ce8ba875f..a5d21e878 100644 --- a/.github/workflows/api_tests.yaml +++ b/.github/workflows/api_tests.yaml @@ -40,12 +40,15 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install composer dependencies run: composer install --prefer-dist --no-progress + - name: Initialise folders + run: sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/ + - name: create the database + run: ./bin/console doctrine:database:create + if: ${{ startsWith('sqlite', matrix.database) }} - name: Initialise the database - run: | - sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/ - ./bin/console doctrine:database:create - ./bin/console doctrine:schema:create - symfony server:start --no-tls --port=8088 -d + run: ./bin/console doctrine:schema:create + - name: Starting server + run: symfony server:start --no-tls --port=8088 -d - name: create api user run: php bin/console bolt:add-user apiuser apiuser%1 api@example.org API --roles=ROLE_WEBSERVICE - name: check API user gets content