-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Infinite loop when registered plugin locks post saving #53401
Comments
Hi, @dlh01 Have you tried moving the logic inside the Adjusted exampleconst {
i18n: { __ },
plugins: {
registerPlugin,
},
element: {
useEffect,
},
data: {
useSelect,
useDispatch,
},
} = wp;
function TitleChecker() {
const hasTitle = useSelect((select) => select('core/editor').getEditedPostAttribute('title').length > 0, []);
const { lockPostSaving, unlockPostSaving } = useDispatch('core/editor');
const { createWarningNotice, removeNotice } = useDispatch('core/notices');
useEffect(() => {
if ( ! hasTitle ) {
lockPostSaving('title-empty-lock');
createWarningNotice(
__('Please enter a headline before publishing.', 'my-textdomain'),
{ id: 'title-empty-lock', isDismissible: false },
);
}
return () => {
unlockPostSaving('title-empty-lock');
removeNotice('title-empty-lock');
};
}, [hasTitle]);
// On the site where this issue occurred, a <PluginPrePublishPanel> was rendered here.
return null;
}
registerPlugin('empty-title-check', { render: TitleChecker }); |
Thanks @Mamaduka! My intention at the moment is only to raise to the editor team that an integration that works in 6.2 causes a crash in 6.3. If whatever caused this change on the editor side isn't considered a regression, then we can close this issue. |
Thanks for the clarification, @dlh01. I think recent changes highlighted the issue with the integration code, like in the example. Trying to bring back the "old behavior" will just hide that fact, and the code might break during a different release. Cc @jsnajdr, @tyxla, what do you think? P.S. I can see the same error message when using the code with WP 6.2.2. Error message from orignal code |
@dlh01 I've checked the code and I believe @Mamaduka is right. In short, what @Mamaduka suggested should resove the bug. With the original version of the code (without wrapping the Even if you use plain That's why we usually |
Alright. If it wasn't supposed to work, we'll fix it now. Thanks for taking a look! |
Yes, the error is caused by missing
complains about exactly that. While rendering The error started to be reported happening most likely after upgrade to React 18, after switch to its concurrent mode, and re-implementation of |
Description
While testing the WordPress 6.3 release candidates, I encountered an infinite loop in the post editor that began in a component that was registered via
registerPlugin()
.I think the loop begins with a call to
lockPostSaving()
, although I don't know why it happens after that call. The loop begins almost immediately and prevents the editor from rendering.The component is in use now on sites running WordPress 6.2, so I believe that whatever has caused this change is new to 6.3.
Step-by-step reproduction instructions
Activating the test theme mentioned below and attempting to load the post editor should demonstrate the issue.
Screenshots, screen recording, code snippet
I've created a test theme that can be activated to replicate the infinite loop: test-theme.zip
I've also posted the theme files in a Gist: https://gist.github.com/dlh01/c99a48d888ca77a0f98a9209da37532d
The relevant portion of the component:
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: