From b19629ddc79bcc592d40fd370b6fd20d101faef3 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Sat, 25 Jul 2026 17:08:08 +0900 Subject: [PATCH] =?UTF-8?q?fix(agent-commerce):=20=E6=B1=BA=E6=B8=88?= =?UTF-8?q?=E3=83=8F=E3=83=B3=E3=83=89=E3=83=A9=E3=81=AE=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E4=BB=98=E3=81=91=E3=82=92=20registerForAutoconfiguration=20?= =?UTF-8?q?=E3=81=B8=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #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) (cherry picked from commit 6bc673e4a33565faeaaa58423d0aa3506b08815a) --- app/config/eccube/services.yaml | 12 +++++------- src/Eccube/Kernel.php | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/config/eccube/services.yaml b/app/config/eccube/services.yaml index ae666313f51..18e0254779d 100644 --- a/app/config/eccube/services.yaml +++ b/app/config/eccube/services.yaml @@ -325,13 +325,11 @@ services: arguments: $accessTokenHandler: '@?Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface' - # Agent Commerce 決済ハンドラ (#6574 UCP / #6776 ACP) - # 具象ハンドラは決済プラグインが agent_commerce.payment_handler タグで寄与する。 - _instanceof: - Eccube\Service\AgentCommerce\Payment\AgentCheckoutPaymentHandlerInterface: - tags: ['agent_commerce.payment_handler'] - - # 決済ハンドラレジストリ。具象ハンドラ (決済プラグイン) は agent_commerce.payment_handler タグで寄与する。 + # Agent Commerce 決済ハンドラレジストリ (#6574 UCP / #6776 ACP) + # 具象ハンドラ (決済プラグイン) は agent_commerce.payment_handler タグで寄与する。 + # タグ付けは Kernel::build() の registerForAutoconfiguration で行う (PaymentMethodInterface と同様)。 + # services.yaml の _instanceof はファイルスコープのため、Plugin\ glob (services.php・#6915) で + # 登録される決済プラグインの具象ハンドラには届かない。 Eccube\Service\AgentCommerce\Payment\AgentCheckoutPaymentHandlerRegistry: arguments: $handlers: !tagged_iterator agent_commerce.payment_handler diff --git a/src/Eccube/Kernel.php b/src/Eccube/Kernel.php index 85eca1463c4..8dc950ff1f0 100644 --- a/src/Eccube/Kernel.php +++ b/src/Eccube/Kernel.php @@ -34,6 +34,7 @@ use Eccube\Doctrine\ORM\Mapping\Driver\TraitProxyAttributeDriver; use Eccube\Doctrine\Query\QueryCustomizer; use Eccube\Log\Logger; +use Eccube\Service\AgentCommerce\Payment\AgentCheckoutPaymentHandlerInterface; use Eccube\Service\Payment\PaymentMethodInterface; use Eccube\Service\PurchaseFlow\DiscountProcessor; use Eccube\Service\PurchaseFlow\ItemHolderPostValidator; @@ -268,6 +269,13 @@ protected function build(ContainerBuilder $container): void ->addTag(PaymentMethodPass::PAYMENT_METHOD_TAG); $container->addCompilerPass(new PaymentMethodPass()); + // Agent Commerce 決済ハンドラ (#6574 UCP / #6776 ACP) の拡張。 + // 決済プラグインの具象ハンドラは Plugin\ glob (services.php・#6915) で登録されるため、 + // services.yaml のファイルスコープな _instanceof ではタグが付かない。 + // PaymentMethodInterface と同様にコンテナ全体へ効く registerForAutoconfiguration でタグ付けする。 + $container->registerForAutoconfiguration(AgentCheckoutPaymentHandlerInterface::class) + ->addTag('agent_commerce.payment_handler'); + // PurchaseFlow の拡張 $container->registerForAutoconfiguration(ItemPreprocessor::class) ->addTag(PurchaseFlowPass::ITEM_PREPROCESSOR_TAG);