Set sizes metadata to empty array if doesn't exist.#61
Merged
schlessera merged 2 commits intomasterfrom Jan 7, 2018
Merged
Conversation
schlessera
requested changes
Jan 7, 2018
features/media-regenerate.feature
Outdated
|
|
||
| # Regenerate with Imagick disabled. | ||
| When I try `WP_CLI_TEST_MEDIA_REGENERATE_IMAGICK=0 wp media regenerate --yes` | ||
| Then the return code should be 0 |
Member
There was a problem hiding this comment.
Problem with indentation here.
src/Media_Command.php
Outdated
| $metadata['sizes'] = array(); | ||
| } | ||
|
|
||
| if ( $this->image_sizes_differ( $image_sizes, $metadata['sizes'] ) ) { |
Member
There was a problem hiding this comment.
Do you think the above logical construction (the check to make sure $metadata['sizes'] is an array) is useful for documentation purposes?
Otherwise, the code would be cleaner with a simple cast to array in the line where it is used...
if ( $this->image_sizes_differ( $image_sizes, (array) $metadata['sizes'] ) ) {
Member
|
Nice, a creative way to force the problem in tests, @gitlost ! |
schlessera
approved these changes
Jan 7, 2018
danielbachhuber
pushed a commit
that referenced
this pull request
Nov 18, 2022
Set sizes metadata to empty array if doesn't exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60
In
needs_regeneration():Reproduces the issue by uploading a BMP with Imagick disabled so no sizes metadata generated.
Also adds attachment ID to some warnings for better feedback, separates out warnings from progress log on metadata error, and adjusts tests.