From f3e4faf5d6776d61bc88fcb54dcb0a33f1a11d8b Mon Sep 17 00:00:00 2001 From: nook24 Date: Thu, 16 Oct 2025 08:43:03 +0200 Subject: [PATCH] Add warning about the fact that the TreeBehavior can not handle concurrent requests and that the user need to implement it's own locking to prevent data corruption See https://github.com/cakephp/cakephp/issues/17174 Signed-off-by: nook24 --- en/orm/behaviors/tree.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/en/orm/behaviors/tree.rst b/en/orm/behaviors/tree.rst index c8f321301c..3cb6d94342 100644 --- a/en/orm/behaviors/tree.rst +++ b/en/orm/behaviors/tree.rst @@ -18,6 +18,7 @@ The TreeBehavior helps you maintain a hierarchical data structure in the database that can be queried without much overhead and helps reconstruct the tree data for finding and displaying processes. + Requirements ============ @@ -31,6 +32,16 @@ You can configure the name of those fields should you need to customize them. More information on the meaning of the fields and how they are used can be found in this article describing the `MPTT logic `_ +.. warning:: + + The TreeBehavior is not safe for concurrent write operations. + Simultaneous requests that modify tree-structured data + (e.g., insertions, deletions, or moves) can lead to corruption of the + ``lft`` and ``rght`` values. + + To prevent this, a locking mechanism like a + `Semaphore `_ should be used. + .. warning:: The TreeBehavior does not support composite primary keys at this point in