ID: 11091
Updated by: kalowsky
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

$GLOBALS['sess'] will work as well.

Previous Comments:
---------------------------------------------------------------------------

[2001-05-24 12:33:55] [EMAIL PROTECTED]
PHP 4.04 to 4.05 upgrade introduced new problems in PHPLIB.  In page.inc, there is a 
function like this:

function page_close() {
  global $sess, $user;
  if (isset($sess)) {
    $sess->freeze();
  }
  if (isset($user)) {
      $user->freeze();
  }
}

The intent is that if the $user or $sess classes were never set, then it would not try 
to call the freze method.  However, in 4.05, the "global" statement cause the "isset" 
statement to return "true" just by declaring them global.  I read from the other bug 
reports that this is kind of a "feature" where the global simply creates a "reference" 
to the $GLOBALS.  But then, how do we recode?  The only solution I found is this:

function page_close() {
  if (in_array("sess",array_keys($GLOBALS)))
    global $sess;
  if (in_array("user",array_keys($GLOBALS)))
    global $user;

  if (isset($sess)) {
    $sess->freeze();
  }
  if (isset($user)) {
    $user->freeze();
  }
}

This is kind of messy!  Is there any other way? Or can "global" be changed so that it 
only creates the reference if the var exists?

Thanks,
Gary

---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=11091&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to