Skip to content

Fix illegal string offset warnings when deleting multiple DB mapping rows (issue #61)#128

Merged
alorbach merged 1 commit into
masterfrom
copilot/fix-bug-multi-lines-mapping
May 6, 2026
Merged

Fix illegal string offset warnings when deleting multiple DB mapping rows (issue #61)#128
alorbach merged 1 commit into
masterfrom
copilot/fix-bug-multi-lines-mapping

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

On the second (and any subsequent) delete of a mapping row, the edit handler re-loads all mappings from DB as plain strings, but $_POST['Mappings'] only contains the currently-visible subset. The rebuild loop only overwrites present keys, leaving removed fields as raw strings in $content['SUBMAPPINGS']. The display loop then hits them with array-offset syntax → Illegal string offset 'MappingCaption' / 'MappingInternalID' / etc.

Changes

  • src/admin/dbmappings.php — Reset $content['SUBMAPPINGS'] to [] before rebuilding from $_POST['Mappings']. POST data is the authoritative form state; DB-loaded entries for already-removed fields must not survive into the display loop.
// Before
if ( isset($_POST['Mappings']) )
    $AllMappings = $_POST['Mappings'];

// After
if ( isset($_POST['Mappings']) )
{
    $AllMappings = $_POST['Mappings'];
    $content['SUBMAPPINGS'] = array();   // ← discard stale DB string entries
}
  • tests/php/Unit/DbMappingSubMappingsTest.php — New PHPUnit regression test with four cases: confirms the buggy path leaves stale string entries, the fixed path produces only arrays for POST-present fields, and sequential deletes stay clean.

Summary by cubic

Fixes "Illegal string offset" warnings when deleting multiple database mapping rows (issue #61) by resetting $content['SUBMAPPINGS'] before rebuilding from $_POST['Mappings'].
Adds PHPUnit regression tests that cover the buggy path and ensure sequential deletes remain clean.

Written for commit 6512092. Summary will update on new commits.

… DB string entries causing illegal string offset warnings on multi-delete

Agent-Logs-Url: https://github.com/rsyslog/loganalyzer/sessions/8cc355cc-e8e5-4ad4-9036-96d54e841b8d

Co-authored-by: alorbach <1675286+alorbach@users.noreply.github.com>
@alorbach
Copy link
Copy Markdown
Member

alorbach commented May 6, 2026

@codex review

Copy link
Copy Markdown
Member

@alorbach alorbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy fix

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@alorbach alorbach merged commit f9dbd7f into master May 6, 2026
6 checks passed
@alorbach alorbach deleted the copilot/fix-bug-multi-lines-mapping branch May 6, 2026 11:44
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.

2 participants