"Copy values from site" throws when the source CKEditor field is empty
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
issue では、src/Field.php の copyCrossSiteValue() が失敗するエントリポイントとして示されています。そこで null のソース値の処理を読み、getFieldValue() と setFieldValue() がどのように使われているかを確認します。CKEditor フィールドが空のサイトからコピーして再現します。空の値がエラーなくコピーされ、コピー先の値を置き換えれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- PHP
- スター
- 47
- フォーク
- 35
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
craftcms/ckeditor のほかの issue
-
[6.x] Inline styles (alignment, font color, background color) are stripped on save対応中かも @i-just が今日担当しました。 オープンrepo:ckeditor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
craftcms/ckeditor#676 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
repo:ckeditor
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
craftcms/ckeditor#678 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:ckeditor
難易度 3/5 1〜2日 初心者へのやさしさ 40/100
craftcms/ckeditor#665 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[6.x]: Esc in a fullscreen CKEditor field closes Preview instead of leaving fullscreen対応中かも @i-just が 15 日前に担当しました。 オープンbug repo:ckeditor
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
craftcms/ckeditor#651 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:ckeditor
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
craftcms/ckeditor#646 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
craftcms/ckeditor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Codeinwp/optimole-wp#1259 ·
メンテナーはふだん 1 日以内に返信
-
component/core domain/framework
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100