"Copy values from site" throws when the source CKEditor field is empty
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Issue xác định copyCrossSiteValue() trong src/Field.php là điểm vào bị lỗi. Đọc cách xử lý giá trị nguồn null tại đó và kiểm tra cách getFieldValue() và setFieldValue() được sử dụng; tái hiện lỗi bằng cách sao chép từ một site có trường CKEditor để trống. Công việc hoàn tất khi giá trị trống được sao chép mà không xảy ra lỗi và thay thế giá trị đích.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Copying a CKEditor field's value from another site fails with an error when that field is empty on the source site:
Error: Call to a member function getChunks() on null
#0 craft\ckeditor\Field::copyCrossSiteValue() (src/Field.php:1399)
#1 craft\controllers\ElementsController::actionCopyValuesFromSite() (src/controllers/ElementsController.php:653)
copyCrossSiteValue() reads the source value with $from->getFieldValue($this->handle) (typed FieldData|null in the docblock) and calls $fromValue->getChunks(false) on it without a null check. HtmlField::normalizeValue() returns null for an empty field ('', <p></p>, <p><br></p> or <p> </p>), so the request errors and nothing is copied.
Steps to reproduce
- Set up two sites, and add a CKEditor field that's translated per site to an entry type enabled for both.
- Save an entry with the field empty on site A and filled in on site B.
- Open the entry on site B and use "Copy values from site" to copy that field from site A.
Expected behavior
The empty value is copied to site B.
Actual behavior
The request fails with Call to a member function getChunks() on null, and the field on site B keeps its old value.
Possible fix
Return early when the source value is null:
$fromValue = $from->getFieldValue($this->handle);
if ($fromValue === null) {
$to->setFieldValue($this->handle, null);
return;
}
Craft CMS version
5.12.1
Plugin version
5.9.0 (the same code is in 5.10.0 and on the 5.x branch)
PHP version
8.4
Operating system and version
Linux (Docker)
Database type and version
MySQL 8
Image driver and version
No response
Installed plugins and modules
No response
- Ngôn ngữ chính
- PHP
- Star
- 47
- Fork
- 35
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của craftcms/ckeditor
-
[6.x] Inline styles (alignment, font color, background color) are stripped on saveCó thể đã có người làm @i-just đã nhận hôm nay. Đang mởrepo:ckeditor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
craftcms/ckeditor#676 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
repo:ckeditor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
craftcms/ckeditor#678 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug repo:ckeditor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 40/100
craftcms/ckeditor#665 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: Esc in a fullscreen CKEditor field closes Preview instead of leaving fullscreenCó thể đã có người làm @i-just đã nhận 15 ngày trước. Đang mởbug repo:ckeditor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
craftcms/ckeditor#651 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug repo:ckeditor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
craftcms/ckeditor#646 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của craftcms/ckeditor
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Codeinwp/optimole-wp#1259 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
component/core domain/framework
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100