X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FSafe_DataObject.php;h=08bc6846f47bb905ac3893562ee7c5667fb51696;hb=9ec24f59ca61bbbb45667b548a872e724f31ab3e;hp=021f7b50645ff4118571d3f6b4aa4b4c53eb9442;hpb=3d170bfa30168280a9c11e944f886460d7cc18c7;p=quix0rs-gnu-social.git diff --git a/classes/Safe_DataObject.php b/classes/Safe_DataObject.php index 021f7b5064..08bc6846f4 100644 --- a/classes/Safe_DataObject.php +++ b/classes/Safe_DataObject.php @@ -42,6 +42,25 @@ class Safe_DataObject extends DB_DataObject } } + /** + * Magic function called at clone() time. + * + * We use this to drop connection with some global resources. + * This supports the fairly common pattern where individual + * items being read in a loop via a single object are cloned + * for individual processing, then fall out of scope when the + * loop comes around again. + * + * As that triggers the destructor, we want to make sure that + * the original object doesn't have its database result killed. + * It will still be freed properly when the original object + * gets destroyed. + */ + function __clone() + { + $this->_DB_resultid = false; + } + /** * Magic function called at serialize() time. *