Problem/Motivation

In FieldValueSourceBase::extractPropertyValue(), we have this:

    $value = $property->getValue();
    $value = empty($value) ? '' : $value;

So, false boolean are casted as "". 0 numeric are casted as "".

It seems it may make a mess with boolean field properties.

Proposed resolution

What was the purpose of this line? Do we still need it?

Maybe it was to filter out empty arrays of objects, so we need a way to prevent it to alter scalars.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

pdureau’s picture

Category: Task » Bug report
pdureau’s picture

Assigned: Unassigned » just_like_good_vibes

just_like_good_vibes made their first commit to this issue’s fork.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Active » Needs review

please review

pdureau’s picture

Url::fromUri($value, $options) only accepts strings for $value

Because we are testing ($property instanceof Uri) before, we know than $value will be an URL if not NULL, so your code is OK.

However, I am afraid it will not be clear enough for the next guy which will read this code in the future.
So, I have moved the logic to a proper, more explicit, method. If you are OK, you can merge.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Needs review » Needs work

ok for me, but the name resolvesUri is not so explicit, is it?

pdureau’s picture

Indeed, i will use resolvesInernalUri because this is what we want to do: get public URI from internal URI

pdureau’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs work » Needs review

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » Unassigned
Status: Needs review » Fixed
pdureau’s picture

Status: Fixed » Closed (fixed)