From 5484b06df8ed18c4b37763872971854ec9ff1251 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 13 Feb 2018 17:06:42 -0800 Subject: [PATCH] Fixed #4923 - invalid check for location object in Ldap Sync --- app/Console/Commands/LdapSync.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index aca8921deb..e0e001a997 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -85,6 +85,8 @@ class LdapSync extends Command } /* Determine which location to assign users to by default. */ + $location = NULL; + if ($this->option('location')!='') { $location = Location::where('name', '=', $this->option('location'))->first(); LOG::debug('Location name '.$this->option('location').' passed'); @@ -93,9 +95,8 @@ class LdapSync extends Command $location = Location::where('id', '=', $this->option('location_id'))->first(); LOG::debug('Location ID '.$this->option('location_id').' passed'); LOG::debug('Importing to '.$location->name.' ('.$location->id.')'); - } else { - $location = NULL; } + if (!isset($location)) { LOG::debug('That location is invalid or a location was not provided, so no location will be assigned by default.'); } @@ -188,7 +189,7 @@ class LdapSync extends Command if ($item['ldap_location_override'] == true) { $user->location_id = $item['location_id']; - } else if ($location) { + } elseif ((isset($location)) && (!empty($location))) { $user->location_id = e($location->id); }