Skip to content

fix(contexts): keep the nodes added by an application update in the loaded shape - #3230

Open
rubenvdlinde wants to merge 1 commit into
mainfrom
fix/noid/context-update-added-node-shape
Open

rubenvdlinde wants to merge 1 commit into
mainfrom
fix/noid/context-update-added-node-shape

Conversation

@rubenvdlinde

Copy link
Copy Markdown

Adding a table or view to an application through PUT /api/2/contexts/{id} logs a PHP warning, Undefined array key "node_type", and the new table doesn't take its place on the start page.

Size: 60 lines: 13 code and 47 tests.

What changes

ContextService::update() keeps the nodes and start page contents of the application in two arrays while it works through the submitted list. The loaded ones come from ContextMapper with snake case keys (node_type, node_id, node_rel_id). Nodes added during the update went in through jsonSerialize(), which uses camel case (nodeType, nodeId, nodeRelId). Ordering the start page afterwards reads the snake case keys, so for an added node it:

  • raised Undefined array key "node_type" and "node_id" for the node, and "node_rel_id" for its start page content,
  • couldn't match the node to its content, so the new content kept order 100 instead of the place it was submitted at,
  • returned an application whose nodes and pages mixed both shapes.

Added nodes and contents now go into those arrays in the same shape the mapper loads them in.

How it was tested

New test in ContextServiceTest: an application with one table gets a view added in front of it. The view comes back in the loaded shape, its start page content gets order 10, and the table moves to 20.

ContextServiceTest without the fix: Undefined array key "node_type" (Tests: 1, Errors: 1)
ContextServiceTest with the fix:    OK (7 tests, 18 assertions)
Full unit suite, PostgreSQL (Nextcloud 34): OK (423 tests, 837 assertions)
php-cs-fixer: no files to fix

🖼️ Screenshots

Backend only, no visual change.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

…oaded shape

Updating an application with new tables or views stored the added nodes and start page
contents in their JSON shape (nodeType, nodeId, nodeRelId) next to the loaded ones
(node_type, node_id, node_rel_id). Ordering the start page then read keys that were not
there, which raised an "Undefined array key" warning and left the new contents
unordered, and the returned application mixed both shapes.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@rubenvdlinde
rubenvdlinde marked this pull request as ready for review November 6, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants