GoogleForCreators / web-stories-wp

Web Stories for WordPress
https://wp.stories.google
Apache License 2.0
758 stars 179 forks source link

Internal server error when saving a story #13720

Closed kojaa closed 3 weeks ago

kojaa commented 1 month ago

Bug Description

When trying to save a story, the server 500 error occurs if the publisher logo on the story remains unchanged. If the logo gets updated, the issue does not happen. This bug also didn't happen in previous versions of the plugin.

Expected Behaviour

The story should be saved without having to change the publisher logo every time.

Steps to Reproduce

Create a story, insert slide, insert publisher logo and save. Add another slide and click on the update button.

Screenshots

Video of the issue: https://www.youtube.com/watch?v=kksd3mude8k

Additional Context

swissspidy commented 1 month ago

Heya, thanks for your report! I appreciate that you took the extra step to record a video as well.

This is an unusual issue, and not something our tests or any other user have reported so far. So it could be isolated to your specific environment.

If you go to the "Request" tab, what's the value that it tries to send for the web_stories_publisher_logo?

Also, are you using an external object cache such as Memcached or Redis on your server?

swissspidy commented 1 month ago

The thing is, WordPress itself does short-circuit if the sent value is identical to what's already stored in the database. This happens here:

https://github.com/WordPress/wordpress-develop/blob/8c4be2687cc4c44e21aaf99feb167c93db31aa85/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L384-L388

The error message indicates that this check fails on your system, so I'd be curious to learn more about your setup, such as the type of database you use, and what exactly is stored on your database. I assume the value is 1073 everywhere.

Also, I see you're using some other potentially related plugins such as ACF. Does this issue still happen when you temporarily disable all other plugins?

kojaa commented 4 weeks ago

Hi and thank you for your fast response!

You have mentioned REST in your previous comment and the potential same value to be everywhere in database, which led us to check the database entries carefully. And we have found that we had duplicate meta_key entries for web_stories_publisher_logo and thumbnail_id.

Screenshot_2024-06-04_at_11 17 01

At one point, we are not sure where and how the meta key got duplicate entry which was causing the error, we assume that your plugin only expects this to be one entry. That is why we had to re-select logo every time we wanted to update the story.

Thanks again!

swissspidy commented 3 weeks ago

Interesting! I don't know how one would ever end up with duplicate meta entries... It's a bit suspicious that the meta IDs are so far apart. 🤷