Skip to content

Fix #6337: blank array-notation field repopulates with the default - #21

Open
NielBuys wants to merge 6 commits into
developfrom
tasks/issue-6337-blank-array-field
Open

NielBuys wants to merge 6 commits into
developfrom
tasks/issue-6337-blank-array-field

Conversation

@NielBuys

@NielBuys NielBuys commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Fixes upstream bcit-ci/CodeIgniter#6337. Full review: docs/todo/archive/issue-6337-blank-array-field-repopulation.md.

The bug

A field named with array notation (address[city]), submitted blank and redisplayed after a validation error, showed the set_value() default instead of the blank value the user submitted. Plain fields (city) already behave correctly.

_reduce_array() converted '' to NULL, and set_value() treats NULL as "not posted". The conversion was a workaround for bcit-ci#113 (2012) that became redundant in 2013, when _execute() started skipping both NULL and ''. The 2015 bcit-ci#3816 fix corrected plain fields but missed this line.

Change

One line removed from _reduce_array() (plus its now-wrong comment). Array-notation fields now behave exactly like plain fields.

⚠️ Behaviour change: needs an upgrade note in the release

This affects only array-notation fields submitted blank:

Before After (same as plain fields)
set_value('address[city]', 'default') 'default' ''
Callback argument NULL ''
matches between two blank array fields fails passes

Release notes are generated from PR titles, so the upgrade note text in section 10 of the review doc must be added to the GitHub release by hand. ixaya/manager requires nielbuys/framework ^3.1, so its users get this change on composer update regardless of the version number.

Downstream scans found no affected code in NCompPOSv2 or ixaya/manager 2.4.0 (details in the doc).

Tests

Four new tests in Form_validation_test.php:

Without the fix, three of the four fail. The bcit-ci#113 guard passes either way, as intended. With the fix, Form_validation_test and Form_helper_test pass (69 tests). Full suite: only the existing Calendar_test::test_generate failure, which is also present on develop.

🤖 Generated with Claude Code

NielBuys and others added 4 commits October 6, 2026 21:18
…ault

_reduce_array() turned a blank '' into NULL for array-notation fields
(address[city]). set_value() treats NULL postdata as "not posted" and
returned the default, so a field the user cleared came back filled in.
Plain fields have kept '' since the bcit-ci#3816 fix; this line was missed then.

The NULL conversion was added for bcit-ci#113 (2012), when blank-field rule
skipping only checked for NULL. _execute() has skipped both NULL and ''
since 2013, so bcit-ci#113 stays fixed without it; a test now guards that.

Behaviour change, for array-notation fields submitted blank only - all
now match plain fields:
- set_value() returns '' instead of the default
- callbacks receive '' instead of NULL
- matches[] between two blank fields passes instead of failing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Status updated to applied in 18b8626, option (a). Records the
NCompPOSv2 and ixaya/manager downstream scans and the upgrade note
text for the release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NielBuys added a commit that referenced this pull request Oct 6, 2026
- CI_VERSION 3.1.13-dev -> 3.1.24; it now follows the release tag
- user guide conf.py version/release and the downloads "Current version"
  link (now the fork's 3.1.24 archive, plus a link to earlier releases)
- changelog: 3.1.24 release date Oct 7, 2026, and a note on CI_VERSION
- SECURITY.md and the 3.4.5 review record the CI_VERSION decision

PRs #21 (bcit-ci#6337) and #22 (bcit-ci#6335) are held for the next release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NielBuys and others added 2 commits October 6, 2026 22:17
Held out of 3.1.24, so the entry moves to the new 3.1.25 section. The
review doc's status date is corrected to 2026-10-06 and its upgrade-note
section now points at the changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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