Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slash encoding for Apache #212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 18 additions & 43 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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 }}

Expand All @@ -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"
4 changes: 2 additions & 2 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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 }}

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 0 additions & 24 deletions recipes/1.0/config/packages/monsieurbiz_sylius_search_plugin.yaml

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions recipes/1.0/manifest.json

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions recipes/2.0/manifest.json

This file was deleted.

3 changes: 2 additions & 1 deletion src/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/views/Search/_filters.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
{{ 'monsieurbiz_searchplugin.filters.no_filter'|trans }}
</div>
{% 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})) %}
<form name="filters-form" method="get" action="{{ path }}">

{% for filter in result.filters %}
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/views/Search/_tabs.html.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% if documentableRegistries|length > 1%}
<div class="ui pointing secondary menu">
{% set encodedQuery = app.request.attributes.get('_route_params').query|default('')|url_encode %}
{% set searchQuery = app.request.attributes.get('_route_params').query|default('') %}
{% set firstDocumentable = documentableRegistries|first %}
{% for documentableRegistry in documentableRegistries %}
{% if documentableRegistry.indexCode == firstDocumentable.indexCode %}
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({query: encodedQuery})) %}
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({query: searchQuery})) %}
{% else %}
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({query: encodedQuery})|merge({document_type: documentableRegistry.indexCode})) %}
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({query: searchQuery})|merge({document_type: documentableRegistry.indexCode})) %}
{% endif %}
{% set isActive = documentableRegistry.indexCode == documentable.indexCode %}
<a
Expand Down
Loading