Skip to content

Commit

Permalink
Merge pull request #182 from lanfisis/master
Browse files Browse the repository at this point in the history
Allow Sylius 1.11
  • Loading branch information
delyriand authored Jun 21, 2022
2 parents eb07151 + bfac751 commit dbe427e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 15 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ jobs:
fail-fast: false
matrix:
php: ['7.4' ,'8.0']
sylius: ["~1.8.0", "~1.9.0", "~1.10.0"]
sylius: ["~1.8.0", "~1.9.0", "~1.10.0", "~1.11.0"]
exclude:
- php: 8.0
sylius: "~1.8.0"
- php: 8.0
sylius: "~1.9.0"
- php: 7.4
sylius: "~1.11.0"

steps:
- name: Setup PHP
Expand Down Expand Up @@ -55,16 +57,19 @@ jobs:
key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-

- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}

- name: Create Sylius-Standard project without install
run: |
composer create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard sylius "${{ matrix.sylius }}"
# Because the sylius-standard has a soft constraint
- name: Make sure to install the required version of Sylius
working-directory: ./sylius
run: |
composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}"
- name: Setup some requirements
working-directory: ./sylius
run: |
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ jobs:
restore-keys: composer2-php:${{ matrix.php }}-

- run: mkdir -p /home/runner/{.composer/cache,.config/composer}
if: steps.cache-composer.outputs.cache-hit != 'true'

- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0']
php: ['8.0']

env:
SYMFONY_ARGS: --no-tls
Expand Down Expand Up @@ -48,10 +48,6 @@ jobs:
restore-keys: composer2-php:${{ matrix.php }}-

- run: mkdir -p /home/runner/{.composer/cache,.config/composer}
if: steps.cache-composer.outputs.cache-hit != 'true'

- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
SYLIUS_VERSION=1.10.0
SYLIUS_VERSION=1.11.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"php": "~7.4|~8.0",
"ext-json": "*",
"ext-intl": "*",
"sylius/sylius": ">=1.8 <1.11"
"sylius/sylius": ">=1.8 <1.12"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down
71 changes: 71 additions & 0 deletions dist/src/Migrations/Version20220621100423.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/*
* This file is part of Monsieur Biz' Rich Editor plugin for Sylius.
*
* (c) Monsieur Biz <sylius@monsieurbiz.com>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220621100423 extends AbstractMigration
{
public function getDescription(): string
{
return 'Change length of messenger_messages.queue_name column and create missing indexes, cf https://github.com/Sylius/Sylius/issues/13838';
}

public function up(Schema $schema): void
{
if ($schema->hasTable('messenger_messages')) {
$this->addSql('ALTER TABLE messenger_messages CHANGE queue_name queue_name VARCHAR(190) NOT NULL');
if (!$this->tableHasIndexOnColumns('messenger_messages', ['queue_name'])) {
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
}
if (!$this->tableHasIndexOnColumns('messenger_messages', ['available_at'])) {
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
}
}
}

public function down(Schema $schema): void
{
if ($schema->hasTable('messenger_messages')) {
if ($this->tableHasIndexOnColumns('messenger_messages', ['queue_name'])) {
$this->addSql('DROP INDEX IDX_75EA56E0FB7336F0 ON messenger_messages');
}
if ($this->tableHasIndexOnColumns('messenger_messages', ['available_at'])) {
$this->addSql('DROP INDEX IDX_75EA56E0E3BD61CE ON messenger_messages');
}
$this->addSql('ALTER TABLE messenger_messages CHANGE queue_name queue_name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
}
}

private function tableHasIndexOnColumns(string $table, array $columns): bool
{
$indexes = $this->connection->getSchemaManager()->listTableIndexes($table);
foreach ($indexes as $index) {
foreach ($index->getColumns() as $column) {
// Another column exists in index
if (($key = array_search($column, $columns, true)) === false) {
continue 2;
}
unset($columns[$key]);
}
}

// Table has all columns in index if the given array in empty at the end
return empty($columns);
}
}

0 comments on commit dbe427e

Please sign in to comment.