-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Stories: add bounds check in saving, don't process an empty Story block #14460
Conversation
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
@renanferrari requesting your review since we were able to detect this one after your logging work done on #14185 and #14191 👍 |
You can test the changes on this Pull Request by downloading the APK here. |
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.
Hey @mzorz, thanks once again for submitting this and for keeping me in the loop on this issue!
Code looks good and I can confirm your changes prevent the app from crashing, as it was expected. However, I noticed that even though the image upload seems to complete successfully, it still doesn't show up in the post. This is what I get instead:
On this particular post, that empty media block remained there, but in another post, it was just blank:
I'm not sure if that's the unrelated error you mentioned where the post is uploaded containing a local path to the media file or if it's something else. Other than that, everything is working as expected.
Thanks for testing @renanferrari ! 🙇
TBH I'm not sure why in one case the placeholder is shown (seems to be the block is valid though) - second image shows probably a valid block and it found the image but couldn't render it somehow, wondering are you able to select the block? But yes in any case it's an unrelated problem 👍 |
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.
Thank you @renanferrari 🙇 |
Fixes #13678
The problem is there seem to be Posts with empty Story blocks in their content:
Therefore, when the
findAllStoryBlocksInPostAndPerformOnEachMediaFilesJson
iterator tries to find themediaFiles
attribute within the block, it fails to do so (the code is not really prepared to expect a non-existentmediaFiles
attribute).This PR adds a check to avoid processing
mediaFiles
for a block that simply doesn't contain any (that is, an empty block that hasn't been assigned any media files yet).To test:
Note: I noticed once the post may be uploaded containing a local path to the media file, but I haven't been able to reproduce, and is unrelated to this particular change.
Regression Notes
Uploads of media when a Story block is also on the same Post.
Tried uploading media (Image block) manually.
Added a unit test to check that if a Story block contains no
mediaFiles
array (as is the case for a Story block that has been added through the Block Picker on Gutenberg mobile), then do not try to process the array.PR submission checklist:
RELEASE-NOTES.txt
if necessary.