Skip to content

Fixed reading relation field definitions without constraints - #918

Merged
alongosz merged 3 commits into
4.6from
fix-relation-converters-missing-constraints
Oct 29, 2026
Merged

alongosz merged 3 commits into
4.6from
fix-relation-converters-missing-constraints

Conversation

@alongosz

Copy link
Copy Markdown
Member
🎫 Issue n/a

Related PRs:

Description:

PHPStan 2.3.3 started reporting booleanNot.alwaysFalse in RelationConverter and RelationListConverter, which turns Unit tests & SQLite integration tests red on PHP 8.3 and 8.4 for every PR against 4.6 (e.g. #699, run 40712372766).

PHPStan is right though: the guard meant to skip a missing <constraints> element checked the DOMNodeList returned by getElementsByTagName(), which is always truthy. So for storage XML without <constraints>, ->item(0) returned null and toFieldDefinition() crashed with a call on null. Its write counterpart always emits <constraints>, so it'd affect only data written some other way, e.g. legacy content or hand-made migrations.

  • [Tests] Added missing test coverage
  • Fixed checking <constraints> element in RelationConverter and RelationListConverter
  • [PHPStan] Removed baseline entries resolved by the fix - b928b06

For QA:

No QA required.

Documentation:

No documentation required.

🤖 Generated with Claude Code

alongosz and others added 3 commits October 28, 2026 16:45
Covered reading Relation and RelationList field definitions from storage
XML with full, empty and missing <constraints> elements. The "without
constraints" cases currently fail with a call on null, as the dead
DOMNodeList truthiness guard never returns early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard meant to skip a missing <constraints> element tested the
DOMNodeList returned by getElementsByTagName(), which is always truthy.
A missing element therefore led to a call on null. The guard now checks
the element itself and, in RelationListConverter, no longer returns
early, so the selection limit validator is still read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@alongosz
alongosz merged commit 4559458 into 4.6 Oct 29, 2026
46 checks passed
@alongosz
alongosz deleted the fix-relation-converters-missing-constraints branch October 29, 2026 08:41
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.

5 participants