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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: maka3d at yahoo dot com dot br
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 19:01:37 2025 UTC