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: Gallery crashes on contributor roles #19060

Merged
merged 1 commit into from Dec 11, 2019

Conversation

jorgefilipecosta
Copy link
Member

Description

Currently, the gallery block is crashing on contributor roles. This PR fixes this problem by ensuring the upload mechanism only executes if, in fact, we have images to upload.

How has this been tested?

With a contributor user, I added a gallery block and verified it does not crashes (although the user can not do anything).
I tried to drag & drop images to the editor and verified it was not possible.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Block] Gallery Affects the Gallery Block - used to display groups of images labels Dec 11, 2019
@jorgefilipecosta jorgefilipecosta merged commit ee3e0b2 into master Dec 11, 2019
@jorgefilipecosta jorgefilipecosta deleted the fix/gallery-crashes-on-contributor-roles branch December 11, 2019 12:27
if ( Platform.OS === 'web' && every( images, ( { url } ) => isBlobURL( url ) ) ) {
if (
Platform.OS === 'web' &&
images && images.length > 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but: If we spread a condition across multiple lines, each part should be on its own line:

- images && images.length > 0 &&
+ images &&
+ images.length > 0

There's meant to be guidance around this in the JavaScript coding standards. They appear to be out of date on the live site.

Archive: http://web.archive.org/web/20190412084124/https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/

@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants