major
minor
major
minor
minor
#26554
Calculated web folder references delete folder when deleting the base object
If a class A declares a mandatory reference of the type "DocumentFolder," a folder is automatically created and linked to each instance of A.
If an instance with references of the type "DocumentFolder" is deleted, these references are resolved and the referenced folders are deleted.
However, this also applies to calculated folder references: If object B declares a calculated reference of type "DocumentFolder" and returns the folder from A in it, deleting B will delete the folder from A, even though B is not the attachment context for that folder.
A is now left with an empty (though required) folder reference.
Analysis
For historical reasons, the type `tl.folder:WebFolder ` has the peculiarity that all references of type `WebFolder ` are populated with a new ` WebFolder` instance upon object creation. This aspect has not yet been documented in the model (e.g., via a default annotation). Consequently, when an object is (directly) deleted (via `tDelete()`), any WebFolder stored in any reference is also deleted. This process does not take into account whether the reference is marked as a composition, nor whether the reference is possibly calculated. During deletion, however, special code runs to ensure that the WebFolder is deleted recursively along with its contents, even though this is not explicitly defined in the model.
Improvement
- The special code for the WebFolder type is removed.
- The WebFolder type receives a default provider annotation (<default-value/>), which ensures that all individual composition references of type WebFolder are pre-populated with a WebFolder instance during object creation.
- WebFolder attributes must therefore always be created as compositions if this default assignment is desired. In turn, deleting the folder when the base object is deleted then occurs automatically via the composition annotation of the reference.
- When deleting a WebFolder, recursive deletion must always occur, regardless of whether the folder is being deleted as part of a base object or not. This cannot be done via the model because WebFolder content may historically also be “linked.” However, linked content must not be deleted during recursive deletion.
Code Migration
- In exported model files, a reference of type `tl.folder:WebFolder ` must be converted to a composition to preserve the same semantics as before. The corresponding data migration in existing datasets occurs automatically.
#!xml <reference name="folder" composite="true" type="tl.folder:WebFolder" />
Test
- /com.top_logic.demo/src/test/java/test/com/top_logic/demo/scripted/webfolder/TestComputedWebfolderRef.script.xml
- test.scripted.TestMigration740