[5.x]: MCP can't set `postDate` or `expiryDate` on Entries
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 73/100
Hướng nghiên cứu
Start with EntryAdapter::sharedAttributeProperties() and EntryAdapter::populate() in the MCP element adapter, then check how Entry::$postDate and Entry::$expiryDate are typed and how DateTimeHelper::toDateTime() is used elsewhere. Reproduce with elements_update and elements_create using the ISO 8601 values in the issue. Done means both date attributes can be set through MCP without the type error, with the relevant behavior covered by tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened?
Setting postDate or expiryDate through elements_create, elements_update, or elements_validate fails with -32603 "Error while executing tool". elements_create fails with asUnpublishedDraft: true too. So there's no way to schedule or expire an Entry over MCP.
I temporarily patched the SDK's CallToolHandler to log the real error:
TypeError: Cannot assign string to property craft\elements\Entry::$postDate of type ?DateTime
EntryAdapter::sharedAttributeProperties() declares both attributes as strings (format: date-time), and EntryAdapter::populate() (line 194) passes them straight to Craft::configure($element, $attributes). Entry::$postDate and Entry::$expiryDate are typed ?DateTime, so PHP rejects the string. Could the adapter run them through DateTimeHelper::toDateTime() first?
Steps to reproduce
- Connect an MCP client as an admin.
- Call
elements_updatewith{"type": "entry", "id": <id>, "attributes": {"postDate": "2026-12-01T09:00:00+00:00"}}. - Do the same with
expiryDate. - Call
elements_createwith{"type": "entry", "attributes": {"sectionId": <id>, "typeId": <id>, "title": "Test", "enabled": false, "postDate": "2026-12-01T09:00:00+00:00"}}. Then try it withoutpostDate.
Expected behavior
The Entry saves with the new date.
Actual behavior
- Steps 2 and 3 return
-32603 "Error while executing tool", even though the value is valid ISO 8601 with a UTC offset. - Step 4 returns the same error with
postDateorexpiryDate, and withasUnpublishedDraft: true. Without a date, the Entry saves. "postDate": "2026-12-01"fails schema validation: "Value does not match the required format:date-time"."postDate": nullsucceeds and sets the post date to now. I didn't expect that, and it changed the date on a live Entry.
The generic -32603 message also made this hard to track down. The agent I tested with tried 5 date formats before it gave up. With the real exception in the message, it could have told the user what was wrong.
PR #20077 loosens date input for custom Date and Time fields on 6.x, but it doesn't touch postDate or expiryDate.
Craft CMS version
5.12.0.1, and 5.x-dev (3419773)
PHP version
8.4.20
Operating system and version
DDEV 1.25.2 on macOS
Database type and version
MySQL 8.0.40
Installed plugins and versions
- CKEditor 5.9.0
- Ngôn ngữ chính
- PHP
- Star
- 3.6k
- Fork
- 714
- Merge trung bình
- 13 giờ 9 phút
- Pull request đã merge (30 ngày)
- 378
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/cms
-
bug repo:cms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
craftcms/cms#20205 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: Element index View menu: sort direction buttons only update after the table has loadedĐang mởbug repo:cms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
craftcms/cms#20203 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[5.x]: MCP returns `[]` for CKEditor field valuesCó thể đã có người làm @i-just đã nhận 2 ngày trước. Đang mởrepo:cms
craftcms/cms#20404 · 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]: Entry edit page takes ~0.4s longer to first paint for every Matrix blockCó thể đã có người làm @riasvdv đã nhận 2 ngày trước. Đang mởbug repo:cms
craftcms/cms#20401 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: Custom entry source with a single-section condition shows another source's entriesCó thể đã có người làm @brandonkelly đã nhận 3 ngày trước. Đang mởbug
craftcms/cms#20388 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
enhancement priority Sales
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
novalo-dev/Prestashop-MCP-Server#201 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
web-token/jwt-framework#757 ·
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 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Include flows spanning the full report time windowCó thể đã có người làm @somethingwithproof đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Cacti/plugin_flowview#306 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug origin: upstream priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mattytap/Mattytap-Sermons#105 ·