-
Notifications
You must be signed in to change notification settings - Fork 81
Block editor: ensure meta data is saved before publishing. #1763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Internal reference: p1749025385229489-slack-C04TJ8P900J
45d7c48
to
ddb3d66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that post metadata (like content warnings) is saved via the block editor before publishing to avoid federation errors when other plugins update meta immediately before publication.
- Adds a reusable
useSetMeta
hook for updating post meta - Replaces direct
useEntityProp
/useSelect
usage with named imports and handlers - Updates preview/select calls to use the aliased
editorStore
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/editor-plugin/plugin.js | Introduce useSetMeta hook; swap to editorStore |
build/editor-plugin/plugin.js | Mirror hook changes in the built output |
build/editor-plugin/plugin.asset.php | Bump asset version |
.github/changelog/fix-conflict-sidebar-meta-updates | Add changelog entry |
Comments suppressed due to low confidence (3)
src/editor-plugin/plugin.js:31
- The new
useSetMeta
hook introduces logic for meta updates but lacks unit or integration tests. Consider adding tests to verify that updating meta values persists as expected.
function useSetMeta( metaKey, postType ) {
src/editor-plugin/plugin.js:32
- The hook
useEntityProp
is used but not imported. Addimport { useEntityProp } from '@wordpress/core-data';
at the top of the file.
const [ meta, setMeta ] = useEntityProp( 'postType', postType || 'default', 'meta' );
src/editor-plugin/plugin.js:47
- The
useSelect
hook is used but not imported. Addimport { useSelect } from '@wordpress/data';
at the top of the file.
const postType = useSelect( ( select ) => select( editorStore ).getCurrentPostType(), [] );
const handleContentWarningChange = ( value ) => { | ||
setContentWarning( value ); | ||
}; | ||
|
||
const handleMaxImageAttachmentsChange = ( value ) => { | ||
setMaxImageAttachments( value ); | ||
}; | ||
|
||
const handleVisibilityChange = ( value ) => { | ||
setContentVisibility( value ); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the setter functions in the onChange handlers directly? I'm not sure the wrappers are needed? The setters' function names are also less ambiguous.
I did some more debugging last night, after I was finally able to reproduce the bug. It felt odd to me that it was only |
It fixed it for me too. Let's ship it! I'll close this PR for now. |
Proposed changes:
This solves federation issues for some posts, on sites using other plugins that may update post meta right before post publication, like Jetpack and its newsletter feature.
In this scenario, we would run into the following error that was blocking federation:
Publishing failed. Could not update the meta value of activitypub_content_warning in database.
In order to fix this, we ensure that the content warning meta is properly saved upon publication.
Other information:
Internal reference: p1749025385229489-slack-C04TJ8P900J
Testing instructions:
This is better tested on a site where the Jetpack plugin is installed, connected to WordPress.com, and where you've toggled the Newsletter feature on. All WordPress.com simple sites satisfy those requirements.
https://mastodon.social/@pfefferle/114502331086451476
.Create
event in the outbox.Changelog entry
Changelog Entry Details
Significance
Type
Message