php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25054 AUTH getAuthData method bug
Submitted: 2003-08-12 08:31 UTC Modified: 2003-08-12 13:17 UTC
From: maka3d at yahoo dot com dot br Assigned: yavo (profile)
Status: Closed Package: PEAR related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2003-08-12 08:31 UTC] maka3d at yahoo dot com dot br
Description:
------------
PEAR package Auth
the getAuthData method of Auth class, raise a Notice error if called without a user login successfull before.


Reproduce code:
---------------
...
function getAuthData($name = null)
{
$session = &Auth::_importGlobalVariable("session");
if (is_null($name)) {
return $session['auth']['data']; // // trigger a NOTICE if the user is not logged-in
...
// solution: return isset($session['auth']['data']) ?
$session['auth']['data'] : null;

Expected result:
----------------
expect return null

Actual result:
--------------
raise a notice


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-12 10:26 UTC] nicos@php.net
Here is the patch.

I need feedbacks please.

Index: Auth.php
===================================================================
RCS file: /repository/pear/Auth/Auth.php,v
retrieving revision 1.57
diff -u -u -r1.57 Auth.php
--- Auth.php    19 Jul 2003 18:04:20 -0000      1.57
+++ Auth.php    12 Aug 2003 15:26:03 -0000
@@ -429,7 +429,11 @@
         $session = &Auth::_importGlobalVariable("session");

         if (is_null($name)) {
-            return $session['auth']['data'];
+            if(isset($session['auth']['data'])) {
+                return $session['auth']['data'];
+            } else {
+                return null;
+            }
         }
         if (isset($session['auth']['data'][$name])) {
             return $session['auth']['data'][$name];

 [2003-08-12 13:17 UTC] maka3d at yahoo dot com dot br
Works fine,
thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC