Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

clone and Stale Reference

Iman edited this page Jun 23, 2019 · 4 revisions

clone is the Solution 2nd for data pollution.

  1. clone creates new objects. Give an object X1, and another object Y holding a ref to X1, in a new request X1 is cloned to produce a new object X2, but object Y is still holding X1, not X2. So developers and users should pay some attention to this kind of relations.

  2. The second problem is that by default clone does not clone props of type closure or object.

  3. The third problem is that clone maybe sometimes destroy the method rebinding in Laravel container.

  4. Static props would better not change.

Objects url and routes have ref in Laravel official objects , but rarely have ref in your code. So clone is used for url and routes.

While other objects, such as event, are used widely in your code, so clone is not used, Solution 3 is used.