From 3c18baf43a167d90a6b3bf64e5904f1bb0434036 Mon Sep 17 00:00:00 2001 From: Kiyoshi Yamamura Date: Thu, 10 Dec 2020 20:15:11 +0900 Subject: [PATCH 1/7] =?UTF-8?q?DB=E3=81=AE=E6=96=87=E5=AD=97=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92utf8mb4=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/doctrine.yaml | 4 ++-- src/Eccube/Controller/Install/InstallController.php | 4 ++-- src/Eccube/Entity/Product.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/config/eccube/packages/doctrine.yaml b/app/config/eccube/packages/doctrine.yaml index ae37ba2fa94..f9fb49e80c8 100644 --- a/app/config/eccube/packages/doctrine.yaml +++ b/app/config/eccube/packages/doctrine.yaml @@ -9,11 +9,11 @@ doctrine: dbal: driver: 'pdo_sqlite' server_version: "%env(DATABASE_SERVER_VERSION)%" - charset: utf8 + charset: utf8mb4 # for mysql only default_table_options: - collate: 'utf8_general_ci' + collate: 'utf8mb4_general_ci' # With Symfony 3.3, remove the `resolve:` prefix url: '%env(DATABASE_URL)%' diff --git a/src/Eccube/Controller/Install/InstallController.php b/src/Eccube/Controller/Install/InstallController.php index 70bc90d5c90..ba69bb5add2 100644 --- a/src/Eccube/Controller/Install/InstallController.php +++ b/src/Eccube/Controller/Install/InstallController.php @@ -563,9 +563,9 @@ protected function checkModules() protected function createConnection(array $params) { if (strpos($params['url'], 'mysql') !== false) { - $params['charset'] = 'utf8'; + $params['charset'] = 'utf8mb4'; $params['defaultTableOptions'] = [ - 'collate' => 'utf8_general_ci', + 'collate' => 'utf8mb4_general_ci', ]; } diff --git a/src/Eccube/Entity/Product.php b/src/Eccube/Entity/Product.php index 8321d776600..9c934e63372 100644 --- a/src/Eccube/Entity/Product.php +++ b/src/Eccube/Entity/Product.php @@ -462,28 +462,28 @@ public function hasProductClass() /** * @var string|null * - * @ORM\Column(name="note", type="string", length=4000, nullable=true) + * @ORM\Column(name="note", type="text", nullable=true) */ private $note; /** * @var string|null * - * @ORM\Column(name="description_list", type="string", length=4000, nullable=true) + * @ORM\Column(name="description_list", type="text", nullable=true) */ private $description_list; /** * @var string|null * - * @ORM\Column(name="description_detail", type="string", length=4000, nullable=true) + * @ORM\Column(name="description_detail", type="text", nullable=true) */ private $description_detail; /** * @var string|null * - * @ORM\Column(name="search_word", type="string", length=4000, nullable=true) + * @ORM\Column(name="search_word", type="text", nullable=true) */ private $search_word; From 20dbf8b737a74c5014df9ec5450c6970d5196778 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Fri, 3 Jun 2022 15:03:58 +0900 Subject: [PATCH 2/7] =?UTF-8?q?doctrine/dbal=203.x=E3=81=A7=E3=81=AFcollat?= =?UTF-8?q?ion=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/doctrine.yaml | 3 ++- src/Eccube/Controller/Install/InstallController.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/config/eccube/packages/doctrine.yaml b/app/config/eccube/packages/doctrine.yaml index f9fb49e80c8..0922dd6922f 100644 --- a/app/config/eccube/packages/doctrine.yaml +++ b/app/config/eccube/packages/doctrine.yaml @@ -13,7 +13,8 @@ doctrine: # for mysql only default_table_options: - collate: 'utf8mb4_general_ci' + charset: 'utf8mb4' + collation: 'utf8mb4_bin' # With Symfony 3.3, remove the `resolve:` prefix url: '%env(DATABASE_URL)%' diff --git a/src/Eccube/Controller/Install/InstallController.php b/src/Eccube/Controller/Install/InstallController.php index ba69bb5add2..567b554e9ad 100644 --- a/src/Eccube/Controller/Install/InstallController.php +++ b/src/Eccube/Controller/Install/InstallController.php @@ -565,7 +565,8 @@ protected function createConnection(array $params) if (strpos($params['url'], 'mysql') !== false) { $params['charset'] = 'utf8mb4'; $params['defaultTableOptions'] = [ - 'collate' => 'utf8mb4_general_ci', + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_bin', ]; } From 6ce4d3450767eb0c49e173e4bcbf484e9f8e8139 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Fri, 3 Jun 2022 15:04:19 +0900 Subject: [PATCH 3/7] =?UTF-8?q?postgresql=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=83=AB=E6=99=82=E3=81=AB=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=A8=E3=81=AA=E3=82=8B=E3=81=9F=E3=82=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/doctrine.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/eccube/packages/doctrine.yaml b/app/config/eccube/packages/doctrine.yaml index 0922dd6922f..e52cd87129c 100644 --- a/app/config/eccube/packages/doctrine.yaml +++ b/app/config/eccube/packages/doctrine.yaml @@ -9,7 +9,7 @@ doctrine: dbal: driver: 'pdo_sqlite' server_version: "%env(DATABASE_SERVER_VERSION)%" - charset: utf8mb4 + charset: 'utf8' # for mysql only default_table_options: From 7ac8bfb301c664059b6d57fdcb6e5bbb464a1556 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:56:03 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E6=99=82=E3=81=ABcharset=E3=82=92=E5=8B=95?= =?UTF-8?q?=E7=9A=84=E3=81=AB=E8=A8=AD=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.dist | 5 ++++- app/config/eccube/packages/doctrine.yaml | 4 +++- src/Eccube/Command/InstallerCommand.php | 5 +++++ src/Eccube/Controller/Install/InstallController.php | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.env.dist b/.env.dist index 42b9988580d..d532aca9562 100644 --- a/.env.dist +++ b/.env.dist @@ -21,6 +21,9 @@ DATABASE_URL=sqlite:///var/eccube.db # The version of your database engine DATABASE_SERVER_VERSION=3 + +# The charset of your database engine +DATABASE_CHARSET=utf8 ###< doctrine/doctrine-bundle ### ###> symfony/mailer ### @@ -51,4 +54,4 @@ MAILER_DSN=null://null #ECCUBE_2FA_COOKIE_NAME=eccube_2fa #ECCUBE_2FA_EXPIRE=14 -###< APPLICATION CONFIG ### \ No newline at end of file +###< APPLICATION CONFIG ### diff --git a/app/config/eccube/packages/doctrine.yaml b/app/config/eccube/packages/doctrine.yaml index e52cd87129c..fd2e627acac 100644 --- a/app/config/eccube/packages/doctrine.yaml +++ b/app/config/eccube/packages/doctrine.yaml @@ -5,11 +5,13 @@ parameters: # You should not need to change this value. env(DATABASE_URL): '' env(DATABASE_SERVER_VERSION): ~ + env(DATABASE_CHARSET): 'utf8' + doctrine: dbal: driver: 'pdo_sqlite' server_version: "%env(DATABASE_SERVER_VERSION)%" - charset: 'utf8' + charset: '%env(DATABASE_CHARSET)%' # for mysql only default_table_options: diff --git a/src/Eccube/Command/InstallerCommand.php b/src/Eccube/Command/InstallerCommand.php index 213c0f33fd1..3a4d921eebf 100644 --- a/src/Eccube/Command/InstallerCommand.php +++ b/src/Eccube/Command/InstallerCommand.php @@ -58,6 +58,7 @@ public function __construct(ContainerInterface $container) public $appDebug; public $databaseUrl; public $serverVersion; + public $databaseCharset; public $mailerDsn; public $authMagic; public $adminRoute; @@ -74,6 +75,7 @@ private function getEnvParameters() 'APP_DEBUG' => $this->appDebug, 'DATABASE_URL' => $this->databaseUrl, 'DATABASE_SERVER_VERSION' => $this->serverVersion, + 'DATABASE_CHARSET' => $this->databaseCharset, 'MAILER_DSN' => $this->mailerDsn, 'ECCUBE_AUTH_MAGIC' => $this->authMagic, 'ECCUBE_ADMIN_ROUTE' => $this->adminRoute, @@ -141,6 +143,9 @@ protected function interact(InputInterface $input, OutputInterface $output) // DATABASE_SERVER_VERSION $this->envFileUpdater->serverVersion = $this->getDatabaseServerVersion($databaseUrl); + // DATABASE_CHARSET + $this->envFileUpdater->databaseCharset = \str_starts_with($databaseUrl, 'mysql') ? 'utf8mb4' : 'utf8'; + // MAILER_DSN $mailerDsn = $this->container->getParameter('eccube_mailer_dsn'); if (empty($mailerDsn)) { diff --git a/src/Eccube/Controller/Install/InstallController.php b/src/Eccube/Controller/Install/InstallController.php index 567b554e9ad..843f2689e5b 100644 --- a/src/Eccube/Controller/Install/InstallController.php +++ b/src/Eccube/Controller/Install/InstallController.php @@ -481,6 +481,7 @@ public function complete(Request $request) 'ECCUBE_TEMPLATE_CODE' => 'default', 'ECCUBE_LOCALE' => 'ja', 'TRUSTED_HOSTS' => '^'.str_replace('.', '\\.', $request->getHost()).'$', + 'DATABASE_CHARSET' => \str_starts_with($databaseUrl, 'mysql') ? 'utf8mb4' : 'utf8', ]; $env = StringUtil::replaceOrAddEnv($env, $replacement); From 90cd90a969f6218818affc1b1ba97783f0bda6b1 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:11:26 +0900 Subject: [PATCH 5/7] =?UTF-8?q?docker-compose.yaml=E3=81=AB=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.mysql.yml | 1 + docker-compose.pgsql.yml | 1 + docker-compose.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/docker-compose.mysql.yml b/docker-compose.mysql.yml index dbdff19f635..506b23ff447 100644 --- a/docker-compose.mysql.yml +++ b/docker-compose.mysql.yml @@ -11,6 +11,7 @@ services: environment: DATABASE_URL: "mysql://dbuser:secret@mysql/eccubedb" DATABASE_SERVER_VERSION: 5.7 + DATABASE_CHARSET: 'utf8mb4' mysql: image: mysql:5.7 diff --git a/docker-compose.pgsql.yml b/docker-compose.pgsql.yml index 38ddbb798df..c7c9e89f1d1 100644 --- a/docker-compose.pgsql.yml +++ b/docker-compose.pgsql.yml @@ -11,6 +11,7 @@ services: environment: DATABASE_URL: "postgres://dbuser:secret@postgres/eccubedb" DATABASE_SERVER_VERSION: 14 + DATABASE_CHARSET: 'utf8' postgres: image: postgres:14 diff --git a/docker-compose.yml b/docker-compose.yml index 5dbb574741c..27db2dedc24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,7 @@ services: APP_DEBUG: 1 DATABASE_URL: "sqlite:///var/eccube.db" DATABASE_SERVER_VERSION: 3 + DATABASE_CHARSET: 'utf8' MAILER_DSN: "smtp://mailcatcher:1025" ECCUBE_AUTH_MAGIC: "" # TRUSTED_HOSTS: '^127.0.0.1$$,^localhost$$' From c767cd288b149c987caffb7a5c10c3932cb441f3 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 9 Jun 2022 11:14:17 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Product/ProductControllerTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Eccube/Tests/Web/Admin/Product/ProductControllerTest.php b/tests/Eccube/Tests/Web/Admin/Product/ProductControllerTest.php index 40aa73e0a23..f096494ac95 100644 --- a/tests/Eccube/Tests/Web/Admin/Product/ProductControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Product/ProductControllerTest.php @@ -1133,4 +1133,23 @@ public function testDeleteAndDeleteProductImage() $this->assertTrue(file_exists($dir.$DuplicatedImage->getFileName())); $this->assertFalse(file_exists($dir.$NotDuplicatedImage->getFileName())); } + + public function test絵文字() + { + $name = '🍣🍺'; + $crawler = $this->client->request('GET', $this->generateUrl('product_list', ['name' => $name])); + $this->assertTrue($this->client->getResponse()->isSuccessful()); + + $message = $crawler->filter('.ec-searchnavRole__counter > span')->text(); + $this->assertSame('お探しの商品は見つかりませんでした', $message); + + // 絵文字の商品を登録 + $this->createProduct($name); + + $crawler = $this->client->request('GET', $this->generateUrl('product_list', ['name' => $name])); + $this->assertTrue($this->client->getResponse()->isSuccessful()); + + $message = $crawler->filter('.ec-searchnavRole__counter > span')->text(); + $this->assertSame('1件', $message); + } } From ef94b1e3f890f376ec11f6bef1a864405a33ace3 Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Thu, 9 Jun 2022 11:32:28 +0900 Subject: [PATCH 7/7] =?UTF-8?q?charset=E3=82=92=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/unit-test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 7c7d367c9c3..95f6e106280 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -26,12 +26,15 @@ jobs: - db: mysql database_url: mysql://root:password@127.0.0.1:3306/eccube_db database_server_version: 5 + database_charset: utf8mb4 - db: pgsql database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 + database_charset: utf8 - db: sqlite3 database_url: sqlite:///var/eccube.db database_server_version: 3 + database_charset: utf8 services: mysql: @@ -79,6 +82,7 @@ jobs: APP_ENV: 'test' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} run: | bin/console doctrine:database:create bin/console doctrine:schema:create @@ -89,6 +93,7 @@ jobs: APP_ENV: 'test' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.11025' run: bin/phpunit --exclude-group cache-clear,cache-clear-install,update-schema-doctrine,plugin-service - name: PHPUnit @@ -96,6 +101,7 @@ jobs: APP_ENV: 'test' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.11025' run: | bin/phpunit --group cache-clear @@ -118,6 +124,7 @@ jobs: APP_ENV: 'test' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.11025' run: | rm -r app/Plugin/*