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

Wrong export/import of Gutenberg post_content #10684

Closed
manake opened this issue Oct 17, 2018 · 4 comments
Closed

Wrong export/import of Gutenberg post_content #10684

manake opened this issue Oct 17, 2018 · 4 comments
Labels
[Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@manake
Copy link

manake commented Oct 17, 2018

Exporting Gutenberg content via get_posts and then importing via wp_insert_post doesn't work. I also do json_encode and json_decode.

The problem is that -- is converted to \\u002d\\u002d.

"post_content": "<!-- wp:slug\/some-block {\"someAttributeOfThisBlock\":\"someValue\"} \/-->\n\n<!-- wp:slug\/some-other-block {\"someProp\":1234,\"someOtherProp\":\"xyz\",\"className\":\"x-y-z-a-b\\u002d\\u002dc\"} \/-->",

@manake
Copy link
Author

manake commented Oct 17, 2018

This is not solved in 4.0 RC-1:

#9991
#9929
#7308
#9423

I still have these two problems:

  • 4.0 RC-1: className is not loaded back (Edit: It's loaded back when class names are like one two so it's only the problem with dashes it seems. Edit 2: I think it was a caching issue. When JS reloaded after I updated to 4.0 RC-1 then classes are loaded now. So only the other issue remains.)
  • 4.0 RC-1: Two dashes in className are saved in such way that export/import doesn't work.

@designsimply designsimply added the Needs Technical Feedback Needs testing from a developer perspective. label Oct 17, 2018
@designsimply
Copy link
Member

Are the steps to reproduce and code snippet at #9423 (comment) still relevant for testing for this case? I see that it was recommended in that discussion to use the forums or Slack for detailed technical questions and I also see you had further questions there about trying to double check whether it's really a bug or not.

@manake
Copy link
Author

manake commented Oct 18, 2018

This is already solved for me: #9423 (I updated my above comment before you replied which says that this is no longer the case in Gutenberg 4.0 but it is the case in 3.9. I updated to 4.0 after I wrote this ticket and then I made a correction).

So this is the only problem that remains:

  1. I can't do get_posts() and wp_insert_post() when two dashes are used next to one another in className.
  2. To me it's not usable and it's a bug.

Solution:
On exporting the post double dashes must remain this: x-y-z-a-b--c and not this: x-y-z-a-b\\u002d\\u002dc (this is with json_encode() applied so the original is probably x-y-z-a-b\u002d\u002dc).

When I manually update x-y-z-a-b\\u002d\\u002dc to x-y-z-a-b--c then I can confirm that importing works via wp_insert_post(). So, it's a problem with export only.

@youknowriad
Copy link
Contributor

I suggest creating a Trac ticket as it seems that the error is in the php functions used here.

@designsimply designsimply added [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. and removed Needs Technical Feedback Needs testing from a developer perspective. labels Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

3 participants