diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 6481002a..afb4e2b0 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -9,36 +9,28 @@ jobs: recipe: - runs-on: ubuntu-latest - - env: - SYMFONY_ENDPOINT: http://127.0.0.1/ + name: Flex recipe (PHP ${{ matrix.php }}, Sylius ${{ matrix.sylius }}) + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4' ,'8.0', '8.1'] - sylius: ["~1.9.0", "~1.10.0", "~1.11.0", "~1.12.0"] + php: ['8.0', '8.1', '8.2'] + sylius: ['~1.11.0', '~1.12.0'] include: - - php: '8.1' - sylius: '~1.12.0' - sylius_paypal: '~1.5.0' - exclude: - - php: 8.1 - sylius: "~1.9.0" - - php: 8.0 - sylius: "~1.9.0" - - php: 7.4 - sylius: "~1.11.0" - - php: 7.4 - sylius: "~1.12.0" + - php: '8.1' + sylius: '~1.12.0' + sylius_paypal: '~1.5.0' + - php: '8.2' + sylius: '~1.12.0' + sylius_paypal: '~1.5.0' + steps: - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - name: Set project php-version run: | @@ -48,13 +40,6 @@ jobs: with: path: plugin - # Run the server at the start so it can download the recipes! - - name: Run standalone symfony flex server - run: | - echo ${{ github.token }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - docker run --rm --name flex -d -v $PWD/plugin/recipes:/var/www/flex/var/repo/private/monsieurbiz/sylius-search-plugin -p 80:80 docker.pkg.github.com/monsieurbiz/docker/symfony-flex-server:latest contrib official - docker ps - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - uses: actions/cache@v1 @@ -64,9 +49,6 @@ jobs: key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }} restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}- - - name: Update composer - run: sudo composer self-update - - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} @@ -92,20 +74,13 @@ jobs: working-directory: ./sylius run: | composer config --no-plugins allow-plugins true - composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' - composer config extra.symfony.allow-contrib true - composer config secure-http false - composer config --unset platform.php + composer config --no-plugins extra.symfony.allow-contrib true + composer config --no-plugins secure-http false + composer config --no-plugins --unset platform.php + composer config --no-plugins extra.symfony.docker false + composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' - - name: Require plugin without install + - name: Require plugin & install all dependencies working-directory: ./sylius run: | - composer require --no-install --no-scripts monsieurbiz/sylius-search-plugin="*@dev" - - - name: Composer install - working-directory: ./sylius - run: | - composer install - - - name: Show flex server logs - run: docker logs --tail 100 flex + composer require monsieurbiz/sylius-search-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index ea02b814..184a4043 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -10,12 +10,13 @@ jobs: security: + name: Security check (PHP ${{ matrix.php }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] + php: [ '8.0', '8.1', '8.2' ] steps: - uses: actions/checkout@v2 @@ -24,7 +25,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - name: Set project php-version run: | diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 17fed329..9f1c9a9c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,13 +8,13 @@ on: jobs: php: - + name: Quality tests (PHP ${{ matrix.php }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: ['8.0', '8.1'] + php: [ '8.0', '8.1', '8.2' ] env: SYMFONY_ARGS: --no-tls @@ -25,13 +25,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '14' + node-version: '16' - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: date.timezone=UTC - name: Set project php-version run: | @@ -51,9 +50,6 @@ jobs: - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - name: Update composer - run: sudo composer self-update - - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} diff --git a/Makefile b/Makefile index df152cf8..82231675 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=search +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusSearchPlugin\\Migrations export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin COMPOSE=docker-compose @@ -140,7 +141,7 @@ test.container: ## Lint the symfony container ${CONSOLE} lint:container test.yaml: ## Lint the symfony Yaml files - ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config --parse-tags + ${CONSOLE} lint:yaml --parse-tags ../../src/Resources/config test.schema: ## Validate MySQL Schema ${CONSOLE} doctrine:schema:validate @@ -215,7 +216,7 @@ consume.reindex: ## Consume reindex messages during 10min ${CONSOLE} messenger:consume async_search --time-limit=600 -vv doctrine.diff: ## Doctrine diff - ${CONSOLE} doctrine:migration:diff + ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}" doctrine.migrate: ## Doctrine diff ${CONSOLE} doctrine:migration:migrate diff --git a/composer.json b/composer.json index 73bd2d8e..a8125fac 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,12 @@ }, "extra": { "symfony": { - "require": "^4.4" + "require": "^4.4", + "docker": false, + "endpoint": [ + "https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", + "flex://defaults" + ] }, "branch-alias": { "dev-master": "2.0-dev" diff --git a/recipes/1.0/config/packages/monsieurbiz_sylius_search_plugin.yaml b/recipes/1.0/config/packages/monsieurbiz_sylius_search_plugin.yaml deleted file mode 100644 index 97fe01bc..00000000 --- a/recipes/1.0/config/packages/monsieurbiz_sylius_search_plugin.yaml +++ /dev/null @@ -1,24 +0,0 @@ -imports: - - { resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/config.yaml" } - -monsieur_biz_sylius_search: - files: - search: '%kernel.project_dir%/vendor/monsieurbiz/sylius-search-plugin/src/Resources/config/elasticsearch/queries/search.yaml' - instant: '%kernel.project_dir%/vendor/monsieurbiz/sylius-search-plugin/src/Resources/config/elasticsearch/queries/instant.yaml' - taxon: '%kernel.project_dir%/vendor/monsieurbiz/sylius-search-plugin/src/Resources/config/elasticsearch/queries/taxon.yaml' - documentable_classes : - - 'App\Entity\Product\Product' - grid: - limits: - taxon: [9, 18, 27] - search: [9, 18, 27] - default_limit: - taxon: 9 - search: 9 - instant: 10 - sorting: - taxon: ['name', 'price', 'created_at'] - search: ['name', 'price', 'created_at'] - filters: - apply_manually: false # Will refresh the filters depending on applied filters after you apply it manually - use_main_taxon: true # Use main taxon for the taxon filter, else use the taxons diff --git a/recipes/1.0/config/routes/monsieurbiz_sylius_search_plugin.yaml b/recipes/1.0/config/routes/monsieurbiz_sylius_search_plugin.yaml deleted file mode 100644 index 6ad0857e..00000000 --- a/recipes/1.0/config/routes/monsieurbiz_sylius_search_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -monsieurbiz_search_plugin: - resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/routing.yaml" diff --git a/recipes/1.0/manifest.json b/recipes/1.0/manifest.json deleted file mode 100644 index acb378dd..00000000 --- a/recipes/1.0/manifest.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "bundles": { - "MonsieurBiz\\SyliusSearchPlugin\\MonsieurBizSyliusSearchPlugin": [ - "all" - ] - }, - "copy-from-recipe": { - "config/": "%CONFIG_DIR%/" - }, - "copy-from-package": { - "src/Resources/templates/": "templates/" - }, - "env": { - "MONSIEURBIZ_SEARCHPLUGIN_ES_HOST": "localhost", - "MONSIEURBIZ_SEARCHPLUGIN_ES_PORT": "9200" - } -} diff --git a/recipes/2.0/config/packages/monsieurbiz_sylius_search_plugin.yaml b/recipes/2.0/config/packages/monsieurbiz_sylius_search_plugin.yaml deleted file mode 100644 index 759ac0d9..00000000 --- a/recipes/2.0/config/packages/monsieurbiz_sylius_search_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/config.yaml" } diff --git a/recipes/2.0/config/routes/monsieurbiz_sylius_search_plugin.yaml b/recipes/2.0/config/routes/monsieurbiz_sylius_search_plugin.yaml deleted file mode 100644 index ea7b6f92..00000000 --- a/recipes/2.0/config/routes/monsieurbiz_sylius_search_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -monsieurbiz_search_plugin: - resource: "@MonsieurBizSyliusSearchPlugin/Resources/config/routing.yaml" diff --git a/recipes/2.0/manifest.json b/recipes/2.0/manifest.json deleted file mode 100644 index 40fc3e92..00000000 --- a/recipes/2.0/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "bundles": { - "Jane\\Bundle\\AutoMapperBundle\\JaneAutoMapperBundle": [ - "all" - ], - "MonsieurBiz\\SyliusSearchPlugin\\MonsieurBizSyliusSearchPlugin": [ - "all" - ] - }, - "copy-from-recipe": { - "config/": "%CONFIG_DIR%/" - }, - "copy-from-package": { - "src/Resources/templates/": "templates/" - }, - "env": { - "MONSIEURBIZ_SEARCHPLUGIN_ES_HOST": "${ELASTICSEARCH_HOST:-localhost}", - "MONSIEURBIZ_SEARCHPLUGIN_ES_PORT": "${ELASTICSEARCH_PORT:-9200}", - "MONSIEURBIZ_SEARCHPLUGIN_ES_URL": "http://${MONSIEURBIZ_SEARCHPLUGIN_ES_HOST}:${MONSIEURBIZ_SEARCHPLUGIN_ES_PORT}/", - "MONSIEURBIZ_SEARCHPLUGIN_MESSENGER_TRANSPORT_DSN": "doctrine://default" - } -} diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index 49e5f0cc..9cf4de25 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -101,10 +101,11 @@ public function postAction(Request $request): RedirectResponse $query = (array) $request->request->all()['monsieurbiz_searchplugin_search'] ?? []; $query = $query['query'] ?? ''; + // With Apache a URL with a encoded slash (%2F) is provoking a 404 error on the server level return $this->redirect( $this->generateUrl( 'monsieurbiz_search_search', - ['query' => urlencode($query)] + ['query' => str_replace('%2F', '/', urlencode($query))] ) ); } diff --git a/src/Resources/views/Search/_filters.html.twig b/src/Resources/views/Search/_filters.html.twig index b183f236..fc435738 100644 --- a/src/Resources/views/Search/_filters.html.twig +++ b/src/Resources/views/Search/_filters.html.twig @@ -8,8 +8,8 @@ {{ 'monsieurbiz_searchplugin.filters.no_filter'|trans }} {% else %} - {% set encodedQuery = app.request.attributes.get('_route_params').query|default('')|url_encode %} - {% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge(app.request.query.all)|merge({query: encodedQuery})) %} + {% set searchQuery = app.request.attributes.get('_route_params').query|default('') %} + {% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge(app.request.query.all)|merge({query: searchQuery})) %}