Skip to content

[SimpleXML] Fix creating new attributes via attributes() dimension write - #264

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/sxml-attr-dim-84
Closed

[SimpleXML] Fix creating new attributes via attributes() dimension write#264
iliaal wants to merge 1 commit into
PHP-8.4from
fix/sxml-attr-dim-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Dimension writes like $x->attributes()["new"] = "v" did nothing for a not-yet-existing attribute, because sxe_prop_dim_write() replaced the element node with the first attribute node while resolving an SXE_ITER_ATTRLIST iterator, so xmlNewProp() hit a non-element node or never ran when the element had no attributes. sxe_prop_dim_write() now keeps the element node and resolves only the start of the attribute list, making dimension writes on attributes() behave like $x["new"] = "v". Property writes share this path and are fixed too; read, exists, and unset create nothing and are unaffected.

@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
sxe_prop_dim_write() overwrote the element node with the first attribute
node when resolving an SXE_ITER_ATTRLIST iterator, so xmlNewProp() targeted
a non-element node and was skipped entirely when no attribute existed yet.
Keep the element node in place and resolve only the attribute list start,
so $x->attributes()["new"] = "v" creates the attribute like the symmetric
$x["new"] path; property writes on the attributes() object share the fixed
path while read/exists/unset handlers are unaffected by this defect.
@iliaal
iliaal force-pushed the fix/sxml-attr-dim-84 branch from cbbe494 to 066a420 Compare August 29, 2026 12:01
@iliaal

iliaal commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

Promoted to php#23500.

@iliaal iliaal closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant