Stories: add bounds check in saving, don't process an empty Story block#14460
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.
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 👍 |
|
Thank you @renanferrari 🙇 |




Fixes #13678
The problem is there seem to be Posts with empty Story blocks in their content:
Therefore, when the
findAllStoryBlocksInPostAndPerformOnEachMediaFilesJsoniterator tries to find themediaFilesattribute within the block, it fails to do so (the code is not really prepared to expect a non-existentmediaFilesattribute).This PR adds a check to avoid processing
mediaFilesfor 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
mediaFilesarray (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.txtif necessary.