Skip to content

fix(install): sodium を必須から推奨へ移し config.platform の緩和と整合させる (refs #6940) - #7052

Open
ttokoro20240902 wants to merge 2 commits into
4.4from
fix/issue-6940-installer-sodium-recommended
Open

fix(install): sodium を必須から推奨へ移し config.platform の緩和と整合させる (refs #6940)#7052
ttokoro20240902 wants to merge 2 commits into
4.4from
fix/issue-6940-installer-sodium-recommended

Conversation

@ttokoro20240902

@ttokoro20240902 ttokoro20240902 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

概要

#6940 の項目 3「システム要件が要件ドキュメント / InstallController / composer.json で三者不一致」のうち、InstallController 側の矛盾だけを解消します。

インストーラの $requiredModules'sodium' が残っているため、sodium 非搭載環境では

[必須] sodium拡張モジュールが有効になっていません。

という danger が表示されます。一方 composer.jsonconfig.platform には #6874ff75e42403)で ext-sodium が宣言済みで、**「sodium 拡張なし環境でも Web API プラグインを導入できるようにする」**方針が取られています。表示と方針が矛盾している状態です。

コア自体は sodium を使っていません(src/ 配下の sodium_* / SODIUM_* の参照は 0 件)。sodium を要求するのは一部プラグイン(Web API 等)の依存なので、必須ではなく推奨が実態に合います。

変更内容

'sodium'$requiredModules から $recommendedModules へ移し、理由をコメントで残しました。それだけです。

checkModules()addDanger() / addInfo()表示するだけでインストールをブロックしません#6940 で確認済み)。したがって導入可否は変わらず、変わるのは表示の区分と文言のみです。

動作確認

コンテナ内で PHP_INI_SCAN_DIR から docker-php-ext-sodium.ini だけを除外し、sodium 非搭載環境を再現して checkModules() を install env で実走しました。

コード sodium danger info
変更前 なし 1 件「[必須] sodium拡張モジュールが有効になっていません。」 0 件
変更後 なし 0 件 1 件「[推奨] sodium拡張モジュールが有効になっていません。」
変更後 あり 0 件 0 件

その他:

  • vendor/bin/phpstan analyse src(level 6)… 0 件
  • vendor/bin/rector process --dry-run … 差分ゼロ
  • vendor/bin/php-cs-fixer fix … 違反なし
  • InstallControllerTest … 13 tests / 43 assertions green

本 PR に含めていないこと

#6940 は 5 項目の複合 Issue で、本 PR はそのうち項目 3 の InstallController 部分のみです。以下は範囲外なので #6940 はクローズせず refs にしています。

  • doc4.ec-cube.net の要件更新(4.4 追記、GD の見直し、bcmath 追記)※別リポジトリ
  • 項目 1 guzzlehttp/guzzlerequire からの除去
  • 項目 2 ext-pdo / ext-session / ext-phar / ext-fileinfo の宣言追加
  • 項目 4 doctrine/commonClassUtils 1 箇所)の依存削減
  • 項目 5 直接依存のメジャーバージョン追従

Refs #6940

Summary by CodeRabbit

  • 改善
    • インストール時の必須モジュールから sodium を推奨モジュールへ変更しました。
    • sodium が利用できない場合でも、インストールを継続できるようになりました。
    • bcmath を推奨モジュールとして追加しました。

インストーラの $requiredModules に 'sodium' が残っており、 sodium 非搭載環境で
「[必須] sodium拡張モジュールが有効になっていません。」という danger を出していた。

一方 composer.json の config.platform には #6874 (ff75e42) で ext-sodium を
宣言済みで、 「sodium 拡張なし環境でも Web API プラグインを導入できるようにする」
という方針が取られている。 コア自体は sodium を一切使わない (src 配下の
sodium_* / SODIUM_* の参照は 0 件) ため、 必須表示は方針と矛盾していた。

$recommendedModules へ移し、 sodium 非搭載環境では
「[推奨] sodium拡張モジュールが有効になっていません。」の info 表示に変える。
checkModules() は表示のみでインストールをブロックしないため、 導入可否は変わらない。

refs #6940
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: c1d5d8eb-52c7-421a-8b2c-3ca3d7b6119f

📥 Commits

Reviewing files that changed from the base of the PR and between fce090a and 7f19418.

📒 Files selected for processing (1)
  • src/Eccube/Controller/Install/InstallController.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Eccube/Controller/Install/InstallController.php

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

InstallController のモジュール分類を更新しました。sodium を必須モジュールから推奨モジュールへ移動し、bcmath を推奨モジュールへ追加しました。分類理由をコメントで明記しました。

Changes

インストールモジュール分類

Layer / File(s) Summary
モジュール一覧の更新
src/Eccube/Controller/Install/InstallController.php
sodium を必須モジュール一覧から削除し、推奨モジュール一覧へ追加しました。bcmath も推奨モジュール一覧へ追加しました。両モジュールの分類理由をコメントで説明しました。

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 7f194

The installer now treats sodium as recommended rather than required, changing only the warning category for environments without the extension; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: nanasess, dotani1111

Poem

うさぎが一覧を確認し
sodium は推奨の列へ
bcmath も仲間入り
コメントが理由を示し
月夜の確認、完了です

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、インストーラでsodiumを必須モジュールから推奨モジュールへ移す主要変更を明確に示しています。変更対象のbcmathには触れていませんが、タイトルが全変更を網羅する必要はないため、変更内容と整合しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-6940-installer-sodium-recommended

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.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.75%. Comparing base (6244b8f) to head (7f19418).
⚠️ Report is 62 commits behind head on 4.4.

Additional details and impacted files
@@            Coverage Diff             @@
##              4.4    #7052      +/-   ##
==========================================
- Coverage   77.75%   77.75%   -0.01%     
==========================================
  Files         597      597              
  Lines       29339    29333       -6     
==========================================
- Hits        22814    22807       -7     
- Misses       6525     6526       +1     
Flag Coverage Δ
Unit 77.75% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nanasess

Copy link
Copy Markdown
Contributor

@ttokoro20240902 InstallController の修正がスコープでしたら、 bcmath の推奨を追加するのを本PRで同時に扱うのはいかがでしょうか?

レビューでのご提案 (#7052) に対応する。sodium とは分類の理由が逆なので
コメントで書き分けた。

- sodium … コアが一切使わない。 一部プラグインのみが要求する
- bcmath … コアが 127 箇所 / 29 ファイルで使う (Order.php 17 /
  PurchaseFlow.php 9 / StockDiffProcessor.php 8 / TaxRuleService.php 6 等の
  金額計算) が, nanasess/bcmath-polyfill が同名関数を提供するため
  拡張が無くても動作する

polyfill は関数を定義するだけで拡張は登録しないので, 正常に動作する環境でも
extension_loaded('bcmath') は false を返す。必須にすると polyfill で動いている
環境に danger が出てしまうため推奨に置く。

composer.json への ext-bcmath の宣言は #6940 の項目 2 の範囲なので #7081 で扱う。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ttokoro20240902

Copy link
Copy Markdown
Contributor Author

@nanasess ご提案ありがとうございます。推奨に追加しました7f19418216)。sodium とは分類の理由が逆になるので、コメントで書き分けています。

コアは bcmath を実際に使っています。 bc* 関数の呼び出しは 127 箇所 / 29 ファイルで、上位は Order.php 17・PurchaseFlow.php 9・StockDiffProcessor.php 8・TaxRuleService.php 6・PointProcessor.php 6 と、受注金額計算の中核です。

それでも拡張は必須にできません。 nanasess/bcmath-polyfillrequire に入っていて、拡張が無い環境では同名関数を純 PHP で提供します。開発用コンテナが実際にその状態でした。

$ php -r 'var_dump(extension_loaded("bcmath"));'
bool(false)
$ php -r 'require "vendor/autoload.php"; echo (new ReflectionFunction("bcadd"))->getFileName();'
/var/www/html/vendor/nanasess/bcmath-polyfill/lib/bcmath.php

ポリフィルは関数を定義するだけで拡張を登録しないので、正常に動作している環境でも extension_loaded('bcmath')false を返します。 必須にするとそこに danger が出てしまうため、推奨(addInfo)が正しい分類だと判断しました。拡張があれば純 PHP 実装より速い、という案内になります。

なお composer.json への ext-bcmath の宣言は、#6940 の項目 2「PHP 拡張の宣言漏れ」に既に検討が書かれている分なので、本 PR では扱っていません。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants