Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.16.14

Bug #942 Bug in isInactive()
Submitted: 2004-03-04 06:09 UTC
From: alain_d99 at freesurf dot ch Assigned: lsmith
Status: Closed Package: LiveUser
PHP Version: 4.2.1 OS: Windows
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 18 + 39 = ?

 
 [2004-03-04 06:09 UTC] alain_d99 at freesurf dot ch
Description: ------------ Hello, LiveUser.php: v1.79 The LiveUser::isInactive() function doesn't work as expected. Example: $nLiveUser =& LiveUser::factory($nConfig); $nLiveUser->init(); if(!$nLiveUser->isLoggedIn()) { if($nLiveUser->isInactive()) echo "Inactive"; else echo "Active"; } In the example above, the "Active" term is always printed, even if user has its "is_active" bit on 'N'. The problem comes from the tryLogin() function at the end: if (!$auth->isActive) { $this->status = LIVEUSER_STATUS_ISINACTIVE; $userFound = true; } it would be: if (!$auth->isActive) { $this->_auth = $auth; //ADDED $this->status = LIVEUSER_STATUS_ISINACTIVE; $userFound = true; } Now, LiveUser::isInactive() works perfectly well. Thanks for your work, Alain Expected result: ---------------- LiveUser::isInactive() must return true if login is right and user has its "is_active" bit on 'N'. Actual result: -------------- LiveUser::isInactive() returns always false

Comments

 [2004-03-05 14:36 UTC] lsmith
Hmm maybe changing the method itself makes more sense: function isInactive() { if ($this->_error) { return false; } return ($this->status == LIVEUSER_STATUS_ISINACTIVE) { }
 [2004-03-06 08:58 UTC] alain_d99 at freesurf dot ch
Hello Smith, the status variable is only intended to give a "status report" of a LiveUser function member, right? If we write the following instructions, a problem arrives: $nResult = $nLiveUser->init(); //Here status = LIVEUSER_STATUS_ISINACTIVE, Ok $nLiveUser->totoFunction(); //Here status = LIVEUSER_STATUS_TOTO if($nLiveUser->isInactive()) //Here, the inInactive function don't give the correct result even if the user has its "is_active" bit on 'N'. the isInactive() function must give always the right result, even if some calls are made to another LiveUser function members. Thank for your work, greetings, Alain
 [2004-03-06 11:24 UTC] lsmith
I see what you mean. However I am a bit worried about the implications of this. This would mean that we may have to introduce checks for inactivity in other places where we currently just check if the "_auth" property is an object. Could you explain a bit more when it may happen that the status information for inactivity is overwritten in such a way. Maybe the solution is to replace the method with another method which returns true if the user is active aka isActive()?
 [2004-03-07 10:35 UTC] lsmith
Ok, moving to an isActive() method doesnt make sense. However I think an implementation of isInactive() as I suggested should be sufficient. As the description of the method suggests its purpose is to check if the user was inactive after after a login is initiated. Especially with the fixes from bug #943.
 [2004-03-08 12:31 UTC] alain_d99 at freesurf dot ch
Hello Smith, you are right, your new isInactive() will be effectively sufficient if you don't introduce a new function that change the status variable (doesn't exist until now). I understand that only init() and its subfunctions will change this variable, and status variable gives the right "status" of LiveUser instance. Then you can see the status everywhere until the next call of init() function. But if you want to use your LIVEUSER_STATUS_ constants for another functions, then your will break the validity of your isInactive() function. Then, I find your solution is good. Thank for your work, and greetings, Alain PS: if status variable is sufficient, no need for expired and idled variables anymore, because of use of LIVEUSER_STATUS_IDLED/EXPIRED?
 [2004-03-08 21:10 UTC] lsmith
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.