Skip to content

feat: EC-CUBE 4.4への対応#5

Open
KenTanaka wants to merge 10 commits into
EC-CUBE:mainfrom
KenTanaka:feat-4.4
Open

feat: EC-CUBE 4.4への対応#5
KenTanaka wants to merge 10 commits into
EC-CUBE:mainfrom
KenTanaka:feat-4.4

Conversation

@KenTanaka

@KenTanaka KenTanaka commented Jul 14, 2026

Copy link
Copy Markdown

概要

データバックアッププラグインを EC-CUBE 4.4(Symfony 7.4 / Doctrine DBAL 3.0 / PHP 8.2+) に対応させ、コードを Databackup42Databackup44 に改名します。4.3 とは非互換(属性必須・DBAL 3・PHP 8.2+)のため、新規 4.4 ブランチへの取り込みです。

参考: 4.3→4.4 マイグレーション手順 (doc #346) / 参照 Recommend-plugin #67

変更内容

1. EC-CUBE 4.4 対応(コア移行)

  • Annotations → PHP 属性: Controller の @Route/@Template#[Route]/#[Template]Sensio 依存除去)
  • 型宣言の明示: メソッド引数・戻り値型、配列の PHPDoc(array<int, string> / list<array<string, mixed>> 等)
  • constructor property promotion / readonly: Controller・Service を private readonly
  • Doctrine DBAL 3.0:
    • getSchemaManager()createSchemaManager()
    • query()executeQuery()
    • fetchAll()fetchAllAssociative()
    • \PDO::FETCH_NUMfetchNumeric()
    • テーブル/カラム名に quoteIdentifier() を適用
  • PHPUnit 11: phpunit.xml.dist<source>/<extensions> 形式へ
  • コード名: namespace / composer code / version: 4.4.0 / ルート名・テンプレート参照を Databackup44 に統一

2. Docker Compose によるテスト環境

  • docker-compose.yml + dev/mysql/pgsql オーバーレイ、dockerbuild/
  • EC-CUBE 4.4 イメージ(ghcr.io/ec-cube/ec-cube-php:8.2-apache-4.4)でプラグインを自動導入・有効化し PHPUnit を実行可能
  • 管理画面ログイン用に APP_ENV=dev 起動+dev 用 Cookie 設定(cookie_secure:false/cookie_samesite:lax)を上書き

3. 静的解析・整形ツール

  • phpstan.neon.dist(level 6)/ Resource/rector.php / Resource/.php-cs-fixer.dist.php を追加(.php 設定は本体の Plugin\: サービス検出で 500 を避けるため Resource/ 配下に配置)
  • rector / php-cs-fixer を適用し、phpstan level 6 での検査を前提にした構成にする
  • CLAUDE.md に開発・テスト手順、アーキテクチャ、移行・配置の注意を記載

4. CI(.github/workflows/ci.yaml ほか)

  • マトリクスを EC-CUBE 4.4 / PHP 8.2–8.5 / MySQL8・PostgreSQL に更新、checkout@v4$GITHUB_OUTPUT 化(MySQL 5.7 は除外)
  • --ignore-platform-req=ext-redis: Symfony 7.4 の symfony/cache が古い php-redis と衝突して本体 composer install が失敗するのを回避(redis は未使用)
  • phpunit 前に cache:warmup: 有効プラグインのルートはコンテナのコンパイル時に確定するため、phpunit プロセスの遅延コンパイルだと RouteNotFoundException が断続的に発生する問題を解消
  • static-analysis ジョブ: php-cs-fixer / rector / phpstan を SQLite・PHP 8.5 の1構成で実行
  • release.yml: 配布パッケージから開発・テスト用ファイル(docker-compose / dockerbuild / CLAUDE.md / phpstan / rector / php-cs-fixer)を除外

テスト

  • EC-CUBE 4.4 + Docker(SQLite)で PHPUnit(管理画面表示・バックアップ実行)を実行
  • CI マトリクス: 4.4 × PHP 8.2/8.3/8.4/8.5 × MySQL8/PostgreSQL
  • 静的解析ジョブ: php-cs-fixer / rector dry-run / phpstan level 6
  • 配布パッケージ(release.yml 相当)から開発用ファイルが除外されることを確認

Summary by CodeRabbit

  • 新機能

    • EC-CUBE 4.4、PHP 8.2以降、MySQL 8.4、PostgreSQLに対応した開発環境を追加。
    • 管理画面からデータベースのバックアップを利用可能にしました。
  • 改善

    • HTTP環境での管理画面ログインを改善。
    • バックアップ処理の互換性と安全性を向上。
  • テスト・品質

    • 自動テスト前のキャッシュ準備を追加。
    • コード整形、静的解析、コード変換のチェックを追加。
  • ドキュメント

    • EC-CUBE 4.4向けの導入・開発・テスト手順を更新。

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Databackup4 を Databackup44 として EC-CUBE 4.4、PHP 8.2以降、Symfony 7.4、Doctrine DBAL 3 に対応させました。Docker開発環境、CI、静的解析、PHPUnit設定、リリース手順、関連ドキュメントも更新しています。

Changes

Databackup44 移行

Layer / File(s) Summary
プラグイン識別子とDBAL 3実装
composer.json, Controller/..., Service/...
プラグイン名・名前空間を Databackup44 に変更し、属性ルーティング、型宣言、DBAL 3 のスキーマ・フェッチAPIを導入しています。
ローカル実行環境
docker-compose*.yml, dockerbuild/*
MySQL 8.4、PostgreSQL 18、EC-CUBE、MailcatcherのCompose構成と、プラグイン導入・有効化・キャッシュクリアの起動手順を追加しています。
CIとリリースパッケージ
.github/workflows/*
EC-CUBE 4.4、PHP 8.2〜8.5、MySQL 8/PostgreSQLを対象にし、キャッシュ更新、PHPUnit前のウォームアップ、静的解析ジョブを追加しています。リリース時の実行環境と除外対象も更新しています。
品質検査とテスト設定
Resource/*, phpstan.neon.dist, phpunit.xml.dist, Tests/*, .gitignore
PHP-CS-Fixer、Rector、PHPStanの設定を追加し、PHPUnit設定とDatabackup44向けテストを更新しています。
開発手順と移行資料
README.md, CLAUDE.md
対応バージョン、ブランチ運用、開発環境、キャッシュクリア、PHPUnit実行手順を記載しています。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Poem

ぴょんと跳ねれば 44
DBALの道を駆け抜けて
キャッシュを温め テストへ進む
Dockerの巣から CIが鳴く
にんじん色のコードを祝おう 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed EC-CUBE 4.4対応とコード名・CI・設定更新という変更内容を端的に表しており、主旨に合っています。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/release.yml (1)

16-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tests ディレクトリの削除漏れの可能性があります。

各種テスト用や開発用の設定ファイルが除外されていますが、もしリリース版のパッケージにテストコードを含めない運用であれば、Tests ディレクトリも除外リストに加えることを推奨します。

💡 修正案
           # 開発・テスト用ファイルは配布パッケージに含めない
           rm -rf $GITHUB_WORKSPACE/docker-compose*.yml $GITHUB_WORKSPACE/dockerbuild
+          rm -rf $GITHUB_WORKSPACE/Tests
           rm -f $GITHUB_WORKSPACE/CLAUDE.md $GITHUB_WORKSPACE/phpstan.neon.dist
           rm -f $GITHUB_WORKSPACE/Resource/rector.php "$GITHUB_WORKSPACE/Resource/.php-cs-fixer.dist.php"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml around lines 16 - 19, Update the release
cleanup commands in the workflow to remove the Tests directory from the package,
alongside the existing development and test files. Preserve the current
exclusions and use the workspace path consistently.
Controller/Admin/Databackup4Controller.php (1)

65-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

未使用の $event パラメータの削除

PHPMD で警告されている通り、クロージャ内で $event が使用されていません。PHP では使用しない引数を省略できるため、削除することでコードがすっきりし、静的解析の警告も解消できます。

♻️ 提案する変更
-            $eventDispatcher->addListener(KernelEvents::TERMINATE, function (TerminateEvent $event) use ($backupBaseDir, $fs) {
+            $eventDispatcher->addListener(KernelEvents::TERMINATE, function () use ($backupBaseDir, $fs) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Controller/Admin/Databackup4Controller.php` at line 65, Remove the unused
$event parameter from the KernelEvents::TERMINATE listener closure registered
via addListener, while preserving the existing $backupBaseDir and $fs captures
and listener behavior.

Source: Linters/SAST tools

phpunit.xml.dist (1)

32-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

カバレッジの除外対象に vendornode_modules を追加することを検討してください。

php-cs-fixerrector の設定と同様に、万が一プラグイン配下に vendornode_modules ディレクトリが存在した場合、それらがカバレッジ計測の対象となってしまい、実行時間の増大やメモリ不足エラーの原因になるのを防ぐことができます。

💡 修正案
         <exclude>
             <directory suffix=".php">./Tests</directory>
             <directory suffix=".php">./Resource</directory>
+            <directory suffix=".php">./vendor</directory>
+            <directory suffix=".php">./node_modules</directory>
         </exclude>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@phpunit.xml.dist` around lines 32 - 35, phpunit.xml.dist のカバレッジ除外設定に vendor と
node_modules ディレクトリを追加してください。既存の Tests と Resource
の除外は維持し、プラグイン配下にこれらの依存ディレクトリがある場合もカバレッジ対象外になるよう設定します。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 42-51: Update the MySQL and PostgreSQL service database
environment values in the CI workflow to use the fixed database name eccube_db
instead of the undefined matrix.dbname reference, matching the database_url
configuration.

---

Nitpick comments:
In @.github/workflows/release.yml:
- Around line 16-19: Update the release cleanup commands in the workflow to
remove the Tests directory from the package, alongside the existing development
and test files. Preserve the current exclusions and use the workspace path
consistently.

In `@Controller/Admin/Databackup4Controller.php`:
- Line 65: Remove the unused $event parameter from the KernelEvents::TERMINATE
listener closure registered via addListener, while preserving the existing
$backupBaseDir and $fs captures and listener behavior.

In `@phpunit.xml.dist`:
- Around line 32-35: phpunit.xml.dist のカバレッジ除外設定に vendor と node_modules
ディレクトリを追加してください。既存の Tests と Resource
の除外は維持し、プラグイン配下にこれらの依存ディレクトリがある場合もカバレッジ対象外になるよう設定します。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55867bd2-737e-4c42-8140-0f9cace9571b

📥 Commits

Reviewing files that changed from the base of the PR and between a21c9f1 and 11c8626.

📒 Files selected for processing (19)
  • .github/workflows/ci.yaml
  • .github/workflows/release.yml
  • .gitignore
  • CLAUDE.md
  • Controller/Admin/Databackup4Controller.php
  • README.md
  • Resource/.php-cs-fixer.dist.php
  • Resource/rector.php
  • Service/Databackup4Service.php
  • Tests/Web/Databackup4AdminControllerTest.php
  • composer.json
  • docker-compose.dev.yml
  • docker-compose.mysql.yml
  • docker-compose.pgsql.yml
  • docker-compose.yml
  • dockerbuild/dev-framework.yaml
  • dockerbuild/grant_to_dbuser.sql
  • phpstan.neon.dist
  • phpunit.xml.dist

Comment thread .github/workflows/ci.yaml
Comment on lines +42 to +51
MYSQL_DATABASE: ${{ matrix.dbname }}
ports:
- 3306:3306
- 3308:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: ${{ matrix.dbname }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

マトリクス変数 dbname が未定義です。

strategy.matrixinclude 内で dbname が定義されていないため、matrix.dbname は空として評価されてしまいます。これにより、データベースが正しく作成されずテストが失敗する原因となります。

database_url 内の指定に合わせて、固定値の eccube_db を指定してください。

🐛 修正案
       mysql8:
         image: mysql:8
         env:
           MYSQL_ROOT_PASSWORD: password
-          MYSQL_DATABASE: ${{ matrix.dbname }}
+          MYSQL_DATABASE: eccube_db
         ports:
           - 3308:3306
         options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
       postgres:
         image: postgres:14
         env:
           POSTGRES_USER: postgres
           POSTGRES_PASSWORD: password
-          POSTGRES_DB: ${{ matrix.dbname }}
+          POSTGRES_DB: eccube_db
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
MYSQL_DATABASE: ${{ matrix.dbname }}
ports:
- 3306:3306
- 3308:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: ${{ matrix.dbname }}
MYSQL_DATABASE: eccube_db
ports:
- 3308:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: eccube_db
🧰 Tools
🪛 actionlint (1.7.12)

[error] 42-42: property "dbname" is not defined in object type {database_charset: string; database_server_version: number; database_url: string; db: string; eccube_version: number; php: number; plugin_code: string}

(expression)


[error] 51-51: property "dbname" is not defined in object type {database_charset: string; database_server_version: number; database_url: string; db: string; eccube_version: number; php: number; plugin_code: string}

(expression)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yaml around lines 42 - 51, Update the MySQL and
PostgreSQL service database environment values in the CI workflow to use the
fixed database name eccube_db instead of the undefined matrix.dbname reference,
matching the database_url configuration.

Source: Linters/SAST tools

working-directory: ../
run: |
rm -rf $GITHUB_WORKSPACE/.github
rm -rf $GITHUB_WORKSPACE/Tests

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testsは除外のままでよいと思いますが、何かパッケージにいれる理由がありますでしょうか。

@ttokoro20240902

Copy link
Copy Markdown

@KenTanaka
CIで静的チェックが赤なのでご確認いただけますでしょうか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants