Skip to content
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

fix/170v2: add filter to delay post saving. #173

Merged
merged 3 commits into from
Jul 5, 2024
Merged

fix/170v2: add filter to delay post saving. #173

merged 3 commits into from
Jul 5, 2024

Conversation

Sidsector9
Copy link
Member

Description of the Change

Closes #170

How to test the Change

  1. Activate classic editor.
  2. Create 2 posts with gallery and add heading. (Just to test if the PR works as expected to transform other elements to blocks).
  3. Disable the classic editor.
  4. Run the following: wp convert-to-blocks start --post_type=post
  5. Open the URL displayed in the terminal.
  6. It will start converting blocks in both the posts.
  7. Wait until terminal shows the message: "Migration finished successfully."
  8. Open both the posts and reload the page to verify if the transformed blocks are visible as expected.

Changelog Entry

Fixed - issue with saving post before the convert to blocks transform completed.

Credits

Props @mdesplenter, @Sidsector9 @dsawardekar

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@jeffpaul jeffpaul added this to the 1.4.0 milestone Jun 28, 2024
@jeffpaul jeffpaul removed their request for review June 28, 2024 15:50
Copy link
Collaborator

@dsawardekar dsawardekar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks close, needs a couple of changes.

wp_localize_script(
'convert_to_blocks_editor',
'convert_to_blocks_agent',
[
'agent' => [
'next' => $this->next(),
'next' => $this->next(),
'save_delay' => apply_filters( 'convert_to_blocks_save_delay', 500, $post_id )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sidsector9 Lets change this to 0, or there is no delay to match the legacy behaviour. For context, 500 ms adds hours to a migration that has 100k posts.

client.save();
setTimeout(() => {
client.save();
}, config.agent.save_delay);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sidsector9 Lets add a JS fallback to 0 in case the BE doesn't send this var. Sometimes this happens on large migrations when the BE stalls. If save_delay is 0, then call save directly instead of using the setTimeout.

@Sidsector9 Sidsector9 requested review from dsawardekar and removed request for dkotter July 2, 2024 08:03
@jeffpaul jeffpaul merged commit c310258 into develop Jul 5, 2024
6 of 10 checks passed
@jeffpaul jeffpaul deleted the fix/170v2 branch July 5, 2024 13:53
@dkotter dkotter modified the milestones: 1.4.0, 1.3.1 Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save is executed too fast for gallery
4 participants