fix(agent-commerce): 決済プラグインのハンドラにタグが付かず payment_handlers が空になる問題を修正 - #6964
fix(agent-commerce): 決済プラグインのハンドラにタグが付かず payment_handlers が空になる問題を修正#6964nanasess wants to merge 1 commit into
Conversation
EC-CUBE#6915 で `Plugin\` の PSR-4 自動登録が services.yaml から services.php へ移った ことにより、services.yaml の `_instanceof` (ファイルスコープ) が決済プラグインの 具象ハンドラに届かなくなり、`agent_commerce.payment_handler` タグが付かなくなって いた。 結果として `AgentCheckoutPaymentHandlerRegistry` が空になり、UCP discovery の `payment_handlers` が `{}` を返して結合 E2E の Integration smoke が全マトリクスで 失敗していた (`checkout-e2e` は `needs` で skip)。 `PaymentMethodInterface` と同様に、コンテナ全体へ効く `Kernel::build()` の `registerForAutoconfiguration()` でタグ付けする。 検証: - 修正前後で `bin/console debug:container --tag=agent_commerce.payment_handler` が 0 件 → SamplePayment44 の ACP/UCP ハンドラ 2 件になることを確認 - ローカルの `/.well-known/ucp` が `payment_handlers: {"dev.ucp.payment.card":[{id, version}]}` を返すことを確認 - `AgentCheckoutPaymentHandlerInterface` の具象実装は src/・app/Customize に存在 しないため、コアのサービス配線への影響はない Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 6bc673e)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAgent Commerce 決済ハンドラのタグ付与を ChangesAgent Commerce 決済ハンドラ自動構成
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.4 #6964 +/- ##
==========================================
+ Coverage 77.11% 77.25% +0.14%
==========================================
Files 547 547
Lines 27163 27165 +2
==========================================
+ Hits 20946 20987 +41
+ Misses 6217 6178 -39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
#6872 に含まれているためクローズします |
概要(Overview・Refs Issue)
エージェントコマース (ACP/UCP) の決済ハンドラが、決済プラグインから自動でタグ付けされなくなっている問題を修正します。
app/config/eccube/services.yamlの_instanceofでAgentCheckoutPaymentHandlerInterfaceにagent_commerce.payment_handlerタグを付与していましたが、_instanceofはそれを記述したファイル内で定義されたサービスにしか適用されません。#6915 でPlugin\の PSR-4 自動登録がservices.yamlからservices.phpへ移ったため、決済プラグインの具象ハンドラにはタグが届かなくなっていました。refs #6915, #6837, #6843
結果として現在の 4.4 では以下が発生します。
AgentCheckoutPaymentHandlerRegistryに注入される!tagged_iterator agent_commerce.payment_handlerが空になる/.well-known/ucp) のpayment_handlersが{}になり、登録済みハンドラが広告されないcompleteで決済ハンドラを解決できない実測 (
ec-cube/samplepayment44を導入し、ACP/UCP ハンドラを 1 つずつ実装した状態):なお、この問題は #6963 で修正した redeclare fatal (全リクエストが HTTP 500) に隠れており、そちらが解消して初めて観測可能になりました。両者は別サブシステム・別起因の独立した不具合です。
方針(Policy)
_instanceofをやめ、Kernel::build()のregisterForAutoconfiguration()でコンテナ全体にタグ付けする方式へ移行します。これは同ファイルで
PaymentMethodInterface/PurchaseProcessor/ItemPreprocessor/QueryCustomizerなど既存 11 件が採用している方式で、agent commerce のハンドラだけが_instanceofを使っていた状態でした。本 PR で流儀が揃います。_instanceofを維持したままservices.php側にも複製する案は、正典が 2 箇所に分かれ再発しやすいため採りませんでした。実装に関する補足(Appendix)
プラグイン側の期待挙動について
決済プラグインが自身の
Resource/config/services.yamlで明示的にtags: ['agent_commerce.payment_handler']と書けば、本修正が無くてもタグは付きます (自ファイルスコープのため #6915 の影響を受けない)。壊れているのはインターフェイスを実装するだけで載る「ゼロ設定」の契約の方です。UcpPaymentHandlerDiscoveryRegistryの docblock も「UCP ハンドラを登録するだけで discovery にも自動的に広告される (ゼロ設定)」と記載しており、修正しないとドキュメントと実挙動が食い違ったままになります。互換性への影響
AgentCheckoutPaymentHandlerInterfaceの具象実装はsrc/にもapp/Customize/にも存在しない (インターフェイス定義と、それを消費する Registry/Discovery のみ) ため、registerForAutoconfigurationはコア既存サービスに対して no-op です。_instanceofはautoconfigure: falseのサービスにも効きますがregisterForAutoconfigurationは効きません。services.yamlのautoconfigure: falseはIgnoreRoutingNotFoundExtension/InitSubscriber/InitDriverの 3 件のみで、いずれも決済ハンドラではないため差は生じません。_instanceofは設定全体で唯一のもので、他のタグ規則を巻き込みません。テスト(Test)
ローカル (SQLite /
ec-cube/api44+ec-cube/samplepayment44を実際に導入) で確認しました。bin/console debug:container --tag=agent_commerce.payment_handlerが 0 件Plugin\SamplePayment44\Service\AgentCommerce\Acp\AcpSampleCardHandler/...\Ucp\UcpSampleCardHandler)/.well-known/ucpが"payment_handlers":{"dev.ucp.payment.card":[{"id":"dev.ucp.payment.card","version":"2026-04-08"}]}を返すことを確認 (修正前は{})php-cs-fixer --dry-run src/Eccube/Kernel.php= 0 件あわせて、本修正を取り込んだ結合 E2E ワークフロー (本体 +
api44+samplepayment44) が全ジョブ green であることを確認済みです。complete(決済実行) まで到達し、成功 / 3DS 中断・再開 / 拒否の各シナリオでハンドラが実際に実行されることを確認相談(Discussion)
DI のタグ配線を固定するテストが現状ありません。既存の
UcpPaymentHandlerDiscoveryRegistryTestは in-memory ハンドラを使う純ロジックのTestCaseのため、今回の回帰を検知できませんでした。agent_commerce.payment_handlerタグが付いたサービスが解決できることを確認する機能テストの追加を検討していますが、テスト環境にはプラグインが導入されないため、テスト用のダミーハンドラをapp/Customize相当に置く等の工夫が要ります。本 PR に含めるべきか、別 PR とすべきかご意見をいただけると助かります。マイナーバージョン互換性保持のための制限事項チェックリスト
レビュワー確認項目
Summary by CodeRabbit