Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[5.x]: Moving an asset with “Replace it” throws TypeError: volumeUid must be of type string, null given

Đang mở Phù hợp với người mới
#20,128 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

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

Từ ngày 28/10/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả 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

Bắt đầu tại AssetsController::actionMoveAsset() trong controller assets của control panel, ở nhánh mà force được đặt và asset xung đột được truy vấn bằng ->select(['elements.id']). Sau đó theo dõi lời gọi requireVolumePermissionByAsset() đến requireVolumePermission() để xác nhận volume UID là null, rồi mở rộng select để bao gồm assets.volumeId và assets.uploaderId. Hoàn thành khi: di chuyển một asset vào volume đã có file trùng tên, chọn "Replace it", thì file thực sự được di chuyển, trả về thông báo thành công và không còn ném TypeError volumeUid must be of type string, null given; tái hiện bằng hai volume cùng chứa một tên file.

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

Mô tả

bug repo:cms
What happened?
Description

When moving a file from one volume to another in Assets, if a file with the same filename exists in the other volume and you select the "replace it" option the file does not get moved but the toast says it has moved.

(Claude Code's bugfind and fix)

In AssetsController::actionMoveAsset(), when force is set, the conflicting asset is queried with ->select(['elements.id']), so volumeId is never loaded. The following requireVolumePermissionByAsset('deleteAssets', $conflictingAsset) then calls requireVolumePermission() with a null volume UID and throws a TypeError. The control panel still reports success, but nothing is moved.

Fix: also select assets.volumeId (and assets.uploaderId for the peer permission checks).

->select(['elements.id']) to ->select(['elements.id', 'assets.volumeId', 'assets.uploaderId'])

Steps to reproduce
  1. move an asset into a folder (here, a different volume) that already has an asset with the same filename, then choose “Replace it”.
Expected behavior

File is moved

Actual behavior

File is not moved and the following error is thrown: TypeError: volumeUid must be of type string, null given

Craft CMS version

5.11.5.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Ngôn ngữ chính
PHP
Star
3.6k
Fork
710
Merge trung bình
11 giờ 26 phút
Pull request đã merge (30 ngày)
324

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/cms

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

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.