Skip to content

Request: patch release 0.31.1 for falsy attribute encoding bug #61

@ademarco

Description

@ademarco

Bug Report

Q A
BC Break no
Version 0.31.0

Summary

ObjectEncoder silently drops XML attributes when their PHP value is falsy (false, 0, 0.0, ""). The truthiness check on line 106 of ObjectEncoder.php short-circuits before the ISO conversion runs, so the attribute is never written.

// current (broken): falsy values like `false` skip the attribute entirely
$isAttribute => $value ? (new AttributeBuilder($type, $iso->to($value)))(...) : $defaultAction,

// fix: only skip when the value is actually null
$isAttribute => $value !== null ? (new AttributeBuilder($type, $iso->to($value)))(...) : $defaultAction,

For example, encoding active = false produces <user><hat>...</hat></user> instead of <user active="false"><hat>...</hat></user>.

This was already fixed on main via #60 , but the fix is not available to projects that cannot upgrade to 0.32.x (see below).

Why a patch release is needed

Between 0.31.0 and 0.32.0 the minimum PHP version was bumped from ~8.3.0 || ~8.4.0 || ~8.5.0 to ~8.4.0 || ~8.5.0, and several dependencies were also updated (e.g. veewee/xml v3 to v4, veewee/reflecta ~0.16 to ~0.17, php-standard-library monolith to individual packages). This means projects still on PHP 8.3 cannot upgrade to 0.32.0 just to get this bugfix.

A 0.31.1 patch release would make the fix available without requiring the PHP 8.4+ upgrade.

Proposed approach

We have already prepared a PR with the one-line fix and corresponding tests, based off the 0.31.0 tag: openeuropa#1

If you could create a 0.31.x branch from the 0.31.0 tag, we would be happy to open the same PR directly against your repository so you can review, merge, and tag 0.31.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions