1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

unset() deprecated?

Discussion in 'XenForo Development Discussions' started by Marcus, Apr 27, 2015.

  1. Marcus

    Marcus Well-Known Member

    I remember reading through lots of unset() statements in earlier xenforo code, maybe it was even another software. But now xenforo rarely uses unset when variables are not needed any more within the functions. Is there a common rule about when unsetting a variable or doesn't it matter so much?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Unset certainly isn't deprecated. It's use case is simply, if you need to unset something you use it. If you don't, you don't.
     
  3. Marcus

    Marcus Well-Known Member

    My question is whether there is a common rule (best practise) when to use unset. Lots of variables in the Controller not passed to the View are not unset. In ControllerPublic::actionIndex() the obviously small variables $forumId, $forumName and the variable $profilePostModel are not passed to the View, and they are not unset. Usually larger arrays are unset like $thread in ControllerPublic::actionForum. Is there a definition or common rule when there is a need to unset a variable?
     

Share This Page