From 1e494b08d3bf86675918c24506674c503f356ced Mon Sep 17 00:00:00 2001 From: btruong Date: Wed, 21 Sep 2016 19:50:24 -0700 Subject: [PATCH] Since our CMS Drupal does occsioanlly assign the value zero to userID, we need to allow segment calls to still validate when the userId is zero, so instead using not empty, using isset would allow the call to validate if the userId value happens to be zero --- lib/Segment.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Segment.php b/lib/Segment.php index 482b872..43e4b6e 100644 --- a/lib/Segment.php +++ b/lib/Segment.php @@ -57,7 +57,7 @@ public static function identify(array $message) { public static function group(array $message) { self::checkClient(); $groupId = !empty($message["groupId"]); - $userId = !empty($message["userId"]); + $userId = isset($message["userId"]); self::assert($groupId && $userId, "Segment::group() expects userId and groupId"); return self::$client->group($message); } @@ -94,8 +94,8 @@ public static function screen(array $message) { */ public static function alias(array $message) { self::checkClient(); - $userId = !empty($message["userId"]); - $previousId = !empty($message["previousId"]); + $userId = isset($message["userId"]); + $previousId = isset($message["previousId"]); self::assert($userId && $previousId, "Segment::alias() requires both userId and previousId"); return self::$client->alias($message); } @@ -107,7 +107,7 @@ public static function alias(array $message) { * @param string $type */ public static function validate($msg, $type){ - $userId = !empty($msg["userId"]); + $userId = isset($msg["userId"]); $anonId = !empty($msg["anonymousId"]); self::assert($userId || $anonId, "Segment::$type() requires userId or anonymousId"); }