DEV Community

nabbisen
nabbisen

Posted on • Edited on

1

EC-CUBE 4.0.3 -> 4.0.4 へのアップデート @ OpenBSD

EC-CUBE 4.0.4 が 2020 年 6 月 17 日にリリースされました。
PHP 7.4 のサポートが行われました。さらに Cookie の SameSite 属性への対応なども行われています。

OpenBSD にインストールしていた EC-CUBE を 4.0.3 -> 4.0.4 にアップデートしました。その手順を記します。
公式ドキュメントをもとにしています。

環境

  • OS: OpenBSD 6.7 amd64
  • Web サーバー: OpenBSD httpd
  • AP サーバー: PHP 7.3 (-> 一部 7.4) + PHP-FPM
  • カートシステム: EC-CUBE 4.0.3 -> 4.0.4
  • DB: MariaDB 10.4

4.0.3 -> 4.0.4 変更ファイル一覧

Github で Tag 間の差分を見ることで確認できます:
https://github.com/EC-CUBE/ec-cube/compare/4.0.3...4.0.4?w=1#files_bucket:

差分を整理して、手順用の一覧メモを作成しました:

# 変更フォルダ(= フォルダ内複数ファイル)
app/DoctrineMigrations/
app/config/eccube/
html/template/
src/Eccube/

# 変更ファイル
.dockerignore
.env.dist
.htaccess
composer.json
composer.lock
docker-compose.yml
gulpconfig.js.sample
gulpfile.js
nginx.conf.sample
package-lock.json
package.json
symfony.lock
web.config
Dockerfile
var/.htaccess
app/Customize/Resource/config/.gitkeep
app/Customize/Resource/locale/.gitkeep

# Git の変更履歴はあるが、ダウンロードパッケージには含まれないファイル群
codeception/
tests/
.editorconfig
.github/.htaccess
.github/workflows/action.yml
.gitignore
.travis.yml
README.md
Enter fullscreen mode Exit fullscreen mode

アップデート手順

1. メンテナンスモードを有効にする

$ touch eccube/.maintenance
Enter fullscreen mode Exit fullscreen mode

ファイルバックアップ時のパフォーマンスを良くするために、事前に cache をクリアしておきます。

$ cd eccube
$ # php-7.4 failed on EC-CUBE 4.0.3
$ doas -u www php-7.3 bin/console cache:clear --no-warmup
$ cd ../
Enter fullscreen mode Exit fullscreen mode

2. サイトのバックアップ

$ mkdir eccube-4.0.3-bk
$ cd eccube-4.0.3-bk

$ doas -u www mysqldump $DATABASE -u $DB_USER -p -h $DB_HOST $DATABASE > database-backup.sql
$ gzip database-backup.sql

$ doas tar cfzp eccube-4.0.3.tgz ../eccube
tar: Removing leading "../"
...

$ cd ../
Enter fullscreen mode Exit fullscreen mode

以降は eccube ディレクトリの中で実施します。

$ cd eccube
Enter fullscreen mode Exit fullscreen mode

3. EC-CUBEのソースファイルをバージョンアップしたものに置き換え

開発時のテスト用途である tests / codeception 関連は対象外です。Github の差分には現れますが、ダウンロードしたパッケージには含まれていません。同様に .git / .travis 関連や LICENSE.txt / README.md も対象外です。

ディレクトリ
$ set -l arr 'bin' 'vendor' 'dockerbuild'

$ for x in \
    'app/DoctrineMigrations' \
    'app/config/eccube' \
    'html/template' \
    'src/Eccube' \
; \
    echo $x; \
    doas rm -rf ./$x; \
    doas -u www cp -r ~/eccube-4.0.4/$x ./$x; \
    if contains $x $arr; doas chown -R $MY_USER: ./$x; end; \
end
Enter fullscreen mode Exit fullscreen mode


備考: for 文 / if 文は fish シェルの記法です。if contains による存在チェックは、事前に配列を宣言する方法と直接配列を指定する方法の 2 通りで書けます。

  1. 事前に配列を宣言する方法

    set -l arr 'bin' 'vendor'
    if contains $x $arr; doas chown -R $MY_USER: ./$x; end
    
  2. 直接配列を指定する方法

    if contains $x {'bin' 'vendor'}; doas chown -R $MY_USER: ./$x; end
    
ファイル
$ for x in \
    '.dockerignore' \
    '.env.dist' \
    'docker-compose.yml' \
    'gulpconfig.js.sample' \
    'gulpfile.js' \
    'nginx.conf.sample' \
    'package-lock.json' \
    'package.json' \
    'symfony.lock' \
    'web.config' \
    'Dockerfile' \
; \
    echo $x; \
    doas rm $x; \
    doas -u www cp ~/eccube-4.0.4/$x ./$x; \
end
Enter fullscreen mode Exit fullscreen mode

4. 個別ファイル差し替え

composer.json / composer.lock
$ for x in \
    'composer.json' \
    'composer.lock' \
; \
    echo $x; \
    doas -u www cp -f ~/eccube-4.0.4/$x ./$x; \
    if contains $x {'composer.json' 'composer.lock'}; doas chown $MY_USER: ./$x; end; \
end
Enter fullscreen mode Exit fullscreen mode
.htaccess
  • .htaccess
    • httpd.conf の条件変更: block 対象を追加 = *.sample
  • var/.htaccess
    • httpd.conf の変更対象は含まれていませんでした。
app/Customize/Resource
$ doas -u www cp -r ~/eccube-4.0.4/app/Customize/Resource ./app/Customize/
Enter fullscreen mode Exit fullscreen mode
その他(私的な都合によるもの)

'app/config/eccube' が今回の変更対象に含まれていますが 'app/config/eccube/packages/doctrine.yaml' に独自の変更を加えていたので、ファイル更新後に差替えました。

5. composer.json/composer.lockの更新

$ php-7.3 bin/console eccube:composer:require-already-installed
$ # Here, updated: php-7.3 -> php-7.4
$ doas -u www php-7.4 bin/console cache:clear --no-warmup
Enter fullscreen mode Exit fullscreen mode


補足: EC-CUBE 4.0.3 でエラーが出ていた php-7.4 によるキャッシュクリア処理が、4.0.4 にアップデートした後は成功するようになりました。
しかしその後の操作や Web ページ描画時にエラーが出たため、php-7.4 への切替えは行なえませんでした。Web ページ描画時のエラーは FileLoaderLoadException: purchaseflow.yaml" does not contain valid YAML: Unexpected characters です。別途詳細を確認する必要が残りました。

6. スキーマ更新/マイグレーション

$ php-7.3 bin/console doctrine:schema:update --force --dump-sql
$ php-7.3 bin/console doctrine:migrations:migrate
Enter fullscreen mode Exit fullscreen mode

7. プロキシの再生成

スキップしました。(4.0.2 -> 4.0.3 へのアップデート時のみ必要な手順です。)

8. フロントテンプレートファイルの更新

対象はありませんでした:
https://github.com/EC-CUBE/ec-cube/pulls?q=is%3Apr+label%3Aaffected%3Atemplate+is%3Aclosed+milestone%3A4.0.4

9. メンテナンスモードを無効にする

$ rm ./.maintenance
Enter fullscreen mode Exit fullscreen mode

10. その他

特別な操作は必要ありませんでした:

4.0.3 -> 4.0.4 のアップデートに特記事項はありません。

以上でアップデートは完了です。

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay