CMDB object lifecycle
The CMDB object layer manages persistent objects and their relationships from in-memory change through validated database state. It keeps object data, link changes, audit records, safe deletion work, concurrent editing locks, and database transactions aligned so that each accepted operation produces a traceable and consistent result. See the broader CMDB and data model page for the model around this lifecycle.
Object state
An object moves between an in-memory state and a persistent state. The layer compares current values with the original values loaded from the database, tracks touched fields, and writes only accepted changes. DBObject::Set() is the main change boundary: it checks that the attribute can be written, converts the input to the attribute type, refreshes dependent values, and marks the object as dirty. References: core/dbobject.class.php• L581-688
The common write entry point selects creation or update from the object state. DBObject::DBWrite() calls DBInsert() for a new object and DBUpdate() for an existing object. After a successful write, the layer treats the current values as the new baseline and clears the pending change state. References: core/dbobject.class.php• L3904-3910, core/dbobject.class.php• L3602-3621
Object creation
Creation turns a new object into a persistent object only after computed values, lifecycle hooks, attribute checks, and integrity checks succeed. The root class receives the identifier first. The layer then stores class-specific data, link data, external values, and creation history before it commits the database work. References: core/dbobject.class.php• L3046-3065, core/dbobject.class.php• L3192-3342
The post-create stage lets the wider system react to the new object. It sends write events, runs create and mention triggers, and informs objects that point to the new object. These reactions connect persistence with notifications and other derived behavior without changing the core meaning of a successful create. References: core/dbobject.class.php• L3352-3378
Object update
An update starts by computing current values and freezing the old values that are needed for audit and follow-up work. If no value changed, the layer stops without a database write. Otherwise it validates the proposed state, writes database-backed attributes, applies link and external-attribute changes, and records the change before commit. References: core/dbobject.class.php• L3421-3474, core/dbobject.class.php• L3476-3566
After the database write, the layer resets the object baseline and runs update events and triggers. A lifecycle stimulus is part of the same update path, so state entry and state exit reactions run after the state change is persisted. References: core/dbobject.class.php• L3602-3649, core/dbobject.class.php• L3662-3714
Attribute validation
Validation protects the data model before persistence. The layer checks changed values against attribute rules, validates references to other objects, checks allowed values and formats, detects duplicate linked items where needed, and then checks rules that depend on more than one attribute. Class-specific consistency rules can add further errors. References: core/dbobject.class.php• L1942-2048, core/dbobject.class.php• L2050-2059, core/dbobject.class.php• L2309-2365
Validation also follows relationship rules. A change to an object can cause checks on objects at the other end of a mirrored link. The layer carries errors and warnings back to the original operation, which prevents a locally valid change from breaking a related object. References: core/dbobject.class.php• L2412-2489, core/dbobject.class.php• L2508-2540
Link changes
A link set is the collection of objects related to a host object. The layer keeps a link set's original members apart from added, removed, and modified members. This delta lets a caller edit a relationship in memory and lets persistence apply only the relationship changes that remain after comparison. References: core/ormlinkset.class.inc.php• L134-175, core/ormlinkset.class.inc.php• L462-516
When the host object is written, changed link sets are written as part of the same object operation. The link layer serializes competing writes to the same link class, checks the current database links, and then applies the accepted additions, removals, and edits. References: core/dbobject.class.php• L2857-2881, core/ormlinkset.class.inc.php• L538-599
Link changes can affect both data integrity and history. Mirrored links can trigger validation and update reactions on their target objects. When link tracking is enabled, the system records additions and removals or records that a link item changed so the activity history can explain the relationship change. See query and OQL for how related objects are selected and ITIL and infrastructure data models for examples of relationship-heavy model use. References: core/dbobject.class.php• L2367-2400, core/dbobject.class.php• L2412-2489, core/dbobject.class.php• L4952-5037
Change records
A CMDB change is one user or system request that can group several atomic operations. It carries the time, user information, user identifier, and origin of the request. The core object layer creates one current change context for the operation and attaches its change operations to that context. References: core/cmdbchange.class.inc.php• L13-40, core/cmdbobject.class.inc.php• L141-153, core/cmdbobject.class.inc.php• L255-277
Atomic change operations describe what happened to a persistent object. They cover object creation and deletion, scalar and special attribute changes, plug-in actions, and link-set additions, removals, or item changes. An operation without a persisted change context obtains the current context and persists it before it links the operation. References: core/cmdbchangeop.class.inc.php• L48-105, core/cmdbchangeop.class.inc.php• L109-184, core/cmdbchangeop.class.inc.php• L187-217, core/cmdbchangeop.class.inc.php• L914-1010
The audit path respects attribute tracking and visibility. External fields and link-set values are not recorded as ordinary scalar changes. Attribute definitions decide how tracked old and new values are stored and displayed, while history descriptions check whether the reader can view the target attribute. References: core/cmdbobject.class.inc.php• L333-385, core/cmdbchangeop.class.inc.php• L224-276
Deletion plans
A deletion plan is a proposed set of deletes and reference updates that keeps the model valid. Before deleting the requested object, the layer follows objects that reference it and applies each reference's deletion rule. Optional references can be cleared or moved. Mandatory references can cause dependent objects to enter the plan for deletion. References: core/dbobject.class.php• L5049-5135, core/dbobject.class.php• L5137-5207
The plan is both a safety check and an execution description. It records delete modes, objects to update, manual actions, and blocking or security issues. CheckToDelete() computes the plan and refuses execution when it finds a stopper. DBDelete() then deletes planned objects and saves planned reference updates. References: core/deletionplan.class.inc.php• L13-24, core/deletionplan.class.inc.php• L64-117, core/dbobject.class.php• L2623-2695, core/dbobject.class.php• L4040-4123
Deletion writes history before it removes the object and runs pre-delete and post-delete reactions around the database work. The object remains identifiable by its key for reporting after deletion, but it is no longer persistent and cannot be updated as the old object. References: core/dbobject.class.php• L744-784, core/dbobject.class.php• L3947-4038, core/cmdbobject.class.inc.php• L314-331
Ownership locks
An ownership lock protects an existing object while a user edits it. The lock stores the object identity, owner, token, acquisition time, and last-seen time. A watchdog extends the lock while the edit remains active. The default lock lifetime is 120 seconds unless configuration changes it. References: core/ownershiplock.class.inc.php• L27-64
The edit and stimulus flows acquire a lock before they show an existing object for change. They pass the token through the form and release it after the operation or when the page unloads. A valid lock blocks another editor; an expired lock can be replaced, and an allowed override can kill a lock. References: application/cmdbabstract.class.inc.php• L2399-2427, application/cmdbabstract.class.inc.php• L2593-2637, application/cmdbabstract.class.inc.php• L2971-3007, application/cmdbabstract.class.inc.php• L3221-3227, application/cmdbabstract.class.inc.php• L3230-3255, core/ownershiplock.class.inc.php• L72-172, core/ownershiplock.class.inc.php• L219-327
Locks and database transactions solve different concurrency problems. An ownership lock prevents two user editing sessions from acting on the same object. A database transaction keeps the writes for one create, update, or delete unit together. References: core/config.class.inc.php• L1299-1321, core/dbobject.class.php• L3246-3313, core/dbobject.class.php• L3494-3600
Database transactions
The database layer groups related writes inside a transaction when core transaction support is enabled. This includes object tables, links, external values, and change records for a create or update. A delete uses the same boundary for the table removals. On failure, the layer rolls back the database work and reports the operation as failed. References: core/dbobject.class.php• L3246-3313, core/dbobject.class.php• L3494-3600, core/dbobject.class.php• L3984-4025
Transactions are nested at the application level but use one database transaction at the root. Inner start, commit, and rollback calls change the tracked nesting level. Only the root commit or rollback reaches the database. Deadlocks and lock wait timeouts are logged, and a root operation can retry when configured transaction handling detects a deadlock. References: core/cmdbsource.class.inc.php• L529-556, core/cmdbsource.class.inc.php• L656-752, core/cmdbsource.class.inc.php• L799-807
UI submission transactions
A UI transaction is a one-use token that protects a form submission from duplicate processing. The form receives the token when it is rendered. The request checks the token and removes it when it is accepted. The storage can use the session or files. File-backed tokens are tied to the current user and expire after the configured lifetime. Disabled protection makes all token values valid. References: application/transaction.class.inc.php• L21-92, application/transaction.class.inc.php• L103-167, application/transaction.class.inc.php• L186-245, application/transaction.class.inc.php• L275-377, application/cmdbabstract.class.inc.php• L2480-2495, application/cmdbabstract.class.inc.php• L4661-4666
UI submission tokens are separate from database transactions and ownership locks. A form can use the token to prevent repeated submission, an ownership token to identify the editor, and a database transaction to make the resulting writes atomic. Creation and edit forms carry the token into their submission, while stimulus forms carry both the transaction token and the ownership token. Link-set, bulk-modify, and deletion forms receive a UI transaction token so relationship and object operations follow the same duplicate-submission protection. References: application/cmdbabstract.class.inc.php• L2399-2420, application/cmdbabstract.class.inc.php• L2480-2495, application/cmdbabstract.class.inc.php• L2593-2637, application/cmdbabstract.class.inc.php• L2710-2719, application/cmdbabstract.class.inc.php• L2971-3007, application/cmdbabstract.class.inc.php• L3172-3181, application/cmdbabstract.class.inc.php• L3221-3227, application/cmdbabstract.class.inc.php• L4661-4666, application/cmdbabstract.class.inc.php• L4718-4751, application/cmdbabstract.class.inc.php• L4916-4975
Lifecycle flow
The main lifecycle flow turns a proposed object state into a validated and traceable database state. The following diagram shows the relationship between validation, persistence, history, links, and concurrency controls.
flowchart TD
A[Load or create object] --> B[Set attributes and link changes]
B --> C[Compute values]
C --> D[Validate object and related objects]
D -->|Invalid| E[Return issues]
D -->|Valid| F[Acquire or verify edit controls]
F --> G[Start database transaction]
G --> H[Write object tables and links]
H --> I[Write external values]
I --> J[Write change records]
J --> K[Commit]
K --> L[Run post-write reactions]
L --> M[Refresh object baseline]
G -->|Failure| N[Rollback and report failure]
Deletion uses a different path because it must first account for objects that point to the target. The plan must have no stopper before the layer performs the planned deletes and reference resets. References: core/dbobject.class.php• L3192-3342, core/dbobject.class.php• L3421-3649, core/dbobject.class.php• L4062-4123
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
DBObject::Set(),CheckToWrite(), or attribute comparison can change both persistence decisions and audit deltas. - Changes to link-set tracking or
DBWriteLinks()can affect mirrored validation, target-object triggers, and link history records. - Changes to deletion propagation rules must preserve the distinction between planned deletes, reference resets, and manual blockers.
- Changes to change-operation classes must keep the current-change association valid for object, attribute, and link history.
- Changes to ownership-lock or UI-token handling must keep lock tokens distinct from duplicate-submission tokens and database transaction state.
- Changes to UI-token storage, expiry, or user checks must preserve one-use behavior across session-backed and file-backed stores.
- Changes to transaction nesting or retry handling must preserve root-level commit and rollback behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A changed attribute points to a missing or inaccessible object | The write is rejected and the reference is not persisted | CheckValue() and CheckChangedExtKeysValues() validate target objects |
| A linked set contains duplicate remote items where duplicates are not allowed | The operation receives a warning or a related consistency check can fail | Linked-set duplicate checks and target-object validation run before write |
| A required reference points to an object being deleted | Dependent objects are added to the deletion plan or the plan stops | Deletion propagation rules and DeletionPlan::ComputeResults() determine whether execution is safe |
| A deletion plan contains a manual operation or security issue | DBDelete() refuses to execute the plan | CheckToDelete() returns a stopper and exposes the plan issues |
| Another editor owns a valid object lock | The edit or stimulus flow reloads the object instead of allowing concurrent change | Ownership tokens are acquired and checked before editing |
| A database write hits a deadlock or lock wait timeout | The operation rolls back and may retry at the root transaction level | Transaction handling logs the database condition and retries when eligible |
| A form submission reuses an accepted, expired, or other-user UI transaction token | The second request is rejected as invalid or is not processed again | UI transaction validation checks the configured store, user, lifetime, and consumes the token after the accepted request |
Key files
| File | Why to read it |
|---|---|
| core/dbobject.class.php | Defines the general object state, validation, create, update, delete, and write flow. |
| core/cmdbobject.class.inc.php | Adds CMDB audit context and object, attribute, and deletion history to the base object flow. |
| core/ormlinkset.class.inc.php | Explains in-memory link deltas and persistence of relationship changes. |
| core/cmdbchange.class.inc.php | Defines the request-level change record and its author and origin data. |
| core/cmdbchangeop.class.inc.php | Defines the atomic history records attached to a CMDB change. |
| core/deletionplan.class.inc.php | Shows how delete and reference-update plans are collected, checked, and reported. |
| core/ownershiplock.class.inc.php | Defines exclusive edit locks, ownership tokens, renewal, expiry, and release. |
| core/cmdbsource.class.inc.php | Provides database transaction nesting and deadlock handling. |
| application/cmdbabstract.class.inc.php | Connects object creation, editing, lifecycle stimulus, bulk changes, and deletion forms to locks and UI transaction tokens. |
| application/transaction.class.inc.php | Defines duplicate-submission tokens used by UI forms. |