Skip to content

Saving an object outside its edit form resets its custom fields to 0 #473

Closed

Description

@caseysoftware

BaseObject::hook_postStore() (L765) always runs:

$custom_fields = new w2p_Core_CustomFields($this->_tbl_module, 'addedit', $id, 'edit');
$custom_fields->bind($_POST);
$custom_fields->store($id);

The constructor loads the object's current values, but w2p_Core_CustomFields::bind() (L158) sets every field that isn't in $_POST to 0, and store() writes them back. So any store() whose request didn't come from that object's full add/edit form wipes its custom field values, for example:

  • Project Designer bulk task updates (do_task_bulk_aed.php, about 15 store() calls),
  • the second store() in do_task_aed.php after a dependency date shift only survives because the same $_POST is still there,
  • every save from a future API request, cron job or import, where $_POST is empty.

Fix: pass custom field values explicitly (setCustomFields(array) before store()), have bind() change only the keys that are present, and skip the custom field step entirely when no values were given. The add/edit handlers pass their posted values.

Found by reading the code on dev-5.0.0 @ 179b4eaf; not yet reproduced on a running install.

Part of #488 (Phase 0 of the REST API and MCP server proposal (#471)).

Activity

  1. added
    api
    on Oct 23, 2026
  2. added a commit that references this issue on Oct 24, 2026
    b986886
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apidatabase

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions