[5.x]: MCP can't set `postDate` or `expiryDate` on Entries
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 73/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- PHP
- Stelle
- 3.6k
- Fork
- 712
- Merge medio
- 13h 8m
- PR unite (30g)
- 366
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di craftcms/cms
-
bug repo:cms
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
craftcms/cms#20205 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[6.x]: Element index View menu: sort direction buttons only update after the table has loadedApertabug repo:cms
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
craftcms/cms#20203 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[5.x] MCP: `configuration.update` fails for Matrix fields with TypeError on `$propagationMethod`Apertabug repo:cms
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
craftcms/cms#20406 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[5.x]: MCP returns `[]` for CKEditor field valuesForse già presa @i-just l’ha presa oggi. Apertarepo:cms
craftcms/cms#20404 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[6.x]: Entry edit page takes ~0.4s longer to first paint for every Matrix blockForse già presa @riasvdv l’ha presa 1 giorno fa. Apertabug repo:cms
craftcms/cms#20401 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di craftcms/cms
Issue simili
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
endoflife-date/endoflife.date#11561 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue priority:low type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
crazy-goat/fdb-php#184 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nextcloud/groupfolders#5218 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nextcloud/sharelisting#624 ·
-
`wp theme mod set` prints its failure message as `Success` and exits 0Forse già presa @dhrupo l’ha presa oggi. Apertabug command:theme-mod-set status:unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
wp-cli/extension-command#570 ·