From 5dbd9b44c94168ad800cae5b7197c78004eacf18 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 24 Jul 2006 05:08:17 +0000 Subject: [PATCH] Fixed a typo in the POD for Session/Env.pm Added more docs for find method in Group.pm Fixed a latent bug that would probably never occur in Macro/GroupAdd.pm If Group->find is called with the name of a group that doesn't exist, then Group will return an object with defaults, and the guid of the group is undef, not ''. However, since by default autoAdd is off, the Macro will still do the right thing. GroupDelete has the same bug, but it shouldn't be patched until there's a test written for it. --- lib/WebGUI/Group.pm | 3 +++ lib/WebGUI/Macro/GroupAdd.pm | 2 +- lib/WebGUI/Session/Env.pm | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index a73984f19..3502e6875 100755 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -457,6 +457,9 @@ An alternative to the constructor "new", use find as a constructor by name rathe Returns the first group with that name found. There is no guaranteed order of the search to be sure not to create groups with the same name! +If the name of the group cannot be found, a new group will not be created. This is +due to how the constructor new handles the null id. + =head3 session A reference to the current session. diff --git a/lib/WebGUI/Macro/GroupAdd.pm b/lib/WebGUI/Macro/GroupAdd.pm index 6cd1897d7..1be988f92 100644 --- a/lib/WebGUI/Macro/GroupAdd.pm +++ b/lib/WebGUI/Macro/GroupAdd.pm @@ -49,7 +49,7 @@ sub process { return "" if ($param[1] eq ""); return "" if ($session->user->userId eq '1'); my $g = WebGUI::Group->find($param[0]); - return "" if ($g->getId eq ""); + return "" unless defined $g->getId; return "" unless ($g->autoAdd); return "" if ($session->user->isInGroup($g->getId)); my %var = (); diff --git a/lib/WebGUI/Session/Env.pm b/lib/WebGUI/Session/Env.pm index 0fb4efbf9..396f6c48d 100644 --- a/lib/WebGUI/Session/Env.pm +++ b/lib/WebGUI/Session/Env.pm @@ -91,7 +91,7 @@ sub getIp { =head2 new ( ) -Constructor. Returns a stow object. +Constructor. Returns an env object. =cut