[6.x]: Commerce can't boot without `craftcms/yii2-adapter`

Đang mở
#4,402 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lukeholder đang làm issue này rồi.

Từ ngày 2/11/2026.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading HasLegacyBridges::finalizeLegacyRegistrationEvents() and the legacy services in src-yii2/services/OrderAdjustments.php and src-yii2/services/Carts.php; also check how craftcms/yii2-adapter is declared in composer.json. Reproduce on Craft 6 without the adapter and trace what loads during boot. Done means either Commerce boots without the adapter or Composer installs it as a required dependency.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

repo:commerce
What happened?

With craftcms/commerce 6.x-dev installed and enabled on a Craft 6 project that doesn't require craftcms/yii2-adapter, every request (site and control panel) fails with Class "yii\base\Component" not found.

HasLegacyBridges::finalizeLegacyRegistrationEvents() registers a booted() callback that always calls LegacyOrderAdjustments::finalizeRegistrationEvents() (and the Gateways / Purchasables equivalents). Those classes live in src-yii2/ and extend yii\base\Component. Guarding that callback with class_exists(\yii\base\Component::class) gets past it, but the legacy craft\commerce\services\Carts service is then loaded on every request and fails the same way.

Is the adapter meant to be a hard requirement of Commerce 6, or should Commerce run without it? It's in require-dev only, so a project gets it only if it requires the adapter itself. If it's required, listing it in require would let Composer install it.

Steps to reproduce
  1. Fresh Craft 6 project (6.x-dev) without craftcms/yii2-adapter.
  2. composer require craftcms/commerce:6.x-dev, then php artisan craft:plugin:install commerce (succeeds).
  3. Load any page.
Expected behavior

Commerce runs, or Composer installs the adapter as a dependency.

Actual behavior

HTTP 500 on every request: Class "yii\base\Component" not found at src-yii2/services/OrderAdjustments.php:16, then src-yii2/services/Carts.php:15.

Craft CMS version

6.x-dev (603f0e0); Commerce 6.x-dev (fa9aedd)

PHP version

8.5

Operating system and version

macOS (Laravel Herd)

Database type and version

MySQL 8

Image driver and version

—

Installed plugins and versions

craftcms/commerce 6.x-dev (plus one private plugin, not involved)

Ngôn ngữ chính
PHP
Star
242
Fork
172
Merge trung bình
21 giờ 23 phút
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của craftcms/commerce

Tất cả issue của craftcms/commerce

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.