From 4af8915edaa0e25d651b819590c802b18ea1fb67 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 7 Aug 2008 16:42:33 +0000 Subject: Refs #174: Introducing the ElggDummy class which returns false for all methods and set variables called on it. This is what the logged out $_SESSION['user'] is set to and is also what page_owner_entity will return if page_owner is invalid. This means that calls to things like $_SESSION['user']->getGUID() are now safe and will no longer cause a parsing error. Please report any issues. git-svn-id: https://code.elgg.org/elgg/trunk@1770 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/sessions.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'engine/lib/sessions.php') diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 87e2f931d..5b08a6e5b 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -184,14 +184,16 @@ $code = $_COOKIE['elggperm']; $code = md5($code); $_SESSION['guid'] = 0; - $_SESSION['id'] = 0; + $_SESSION['id'] = 0; + $_SESSION['user'] = new ElggDummy(); if ($user = get_user_by_code($code)) { $_SESSION['user'] = $user; $_SESSION['id'] = $user->getGUID(); $_SESSION['guid'] = $_SESSION['id']; $_SESSION['code'] = $_COOKIE['elggperm']; } - } else { + } else { + $_SESSION['user'] = new ElggDummy(); $_SESSION['id'] = 0; $_SESSION['guid'] = 0; } @@ -201,11 +203,13 @@ if ($user = get_user_by_code($code)) { $_SESSION['user'] = $user; } else { - unset($_SESSION['user']); + //unset($_SESSION['user']); + $_SESSION['user'] = new ElggDummy(); $_SESSION['guid'] = 0; $_SESSION['id'] = 0; } - } else { + } else { + $_SESSION['user'] = new ElggDummy(); $_SESSION['guid'] = 0; $_SESSION['id'] = 0; } @@ -213,7 +217,7 @@ if ($_SESSION['id'] > 0) { set_last_action($_SESSION['id']); } - + print_r($_SESSION); register_action("login",true); register_action("logout"); -- cgit v1.2.3