Bug #24204
closedWrong internal object references after cloning tslib_cObj instances
0%
Description
When cloning an instance of tslib_cObj PHP (in the nature of a clone) copies all the properties of the original instance to the clone instance.
$original->contentObjects contains references to instances of tslib_content_*, these instances of tslib_content_* have back references to their parent tslib_cObj instance. Now when cloning, instead of pointing to the new $clone tslib_cObj instance, these tslib_content_* instances still point the $original tslib_cObj. This causes major problems resulting in rendering of the frontend hitting maximum execution time or memory limits and still not rendering the expected content.
The behavior can be tested with EXT:kb_nescefe v1.1.1
The solution is to reset $clone>contentObjects using PHP's magic __clone() method so that no references are left to $original->contentObject
1) ============================================================================== $cObjA (tslib_cObj) <------------------------| | | |$cObjA->contentObjects[] | |--------------> CASE (tslib_content_Case) --| |--------------> USER (tslib_content_User) --| |--------------> HTML (tslib_content_Html) --| |--------------> TEXT (tslib_content_Text) --| 2) ============================================================================== $cObjB = clone $cObjA; 3) ============================================================================== $cObjA (tslib_cObj) <------------------------| | | $cObjA->contentObjects[]! | | ^ |--------------> CASE (tslib_content_Case) --| XXX <-----| |--------------> USER (tslib_content_User) --| XXX <-----| |--------------> HTML (tslib_content_Html) --| XXX <-----| |--------------> TEXT (tslib_content_Text) --| XXX <-----| | $cObjB (tslib_cObj) ---------------------------------------|
(issue imported from #M16568)