Read a non-attribute-set column as an empty attribute set - #2688
Open
kha333n wants to merge 1 commit into
Open
Conversation
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.
Fixes #2687.
1.xonly —2.xalready guards this, so no forward port.A product whose
attribute_dataholds anything other than an attribute setcannot be loaded:
Product::find()throws, and so does every listing whose rangeincludes it.
The fix
get()decoded the column and iterated the result without checking it wasiterable. It now reads anything that is not an array as an empty attribute set,
which is what
2.xdoes.is_array()rather than2.x's?: []: both catchnulland0, which arethe values that actually arise, and
is_array()also catches a truthy scalarthat would otherwise reach the same
foreach.Rows reach this state through Lunar itself — a non-UTF-8 attribute value makes
set()store0(#2685), and0is one of the valuesget()cannot read.Fixing that stops new ones, but the records already damaged stay unreadable, and
cannot be repaired through Lunar because Lunar cannot read them.
Touches the same file as #2686, which fixes the write side. No overlap in intent,
but whichever lands second wants a rebase.
Tests
tests/core/Unit/Base/Casts/AsAttributeDataReadTest.php:over the five shapes the column can hold:
null,0,"abc",123andmalformed JSON. All five throw on
1.x.after, and is the guard that the fix skips only non-attribute-sets.