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

unset() deprecated?

Marcus

Well-known member
#1
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?
 

Chris D

XenForo developer
Staff member
#2
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.
 

Marcus

Well-known member
#3
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?