Answers.Body: <p>Hey Sam the answer is in your own dump file. Just look at the userModel Numbers in userFollowing, userFollowers and friends.</p>
  
  <p>UserFollowing has [379, 381, 393], 
  UserFollowers has [446, 454] and 
  friends has [379, 381]</p>
  
  <p>Friends has the same numbers as userFollowing but not the same as userFollowers. Hence when you do the without filter on userFollowers you are basically doing
  [446, 454]|without([379, 381])
  Which will ofcourse return [446, 454]. </p>
  
  <p>You could ofcourse get the username out for each model and perform the operations on that and since those would be strings this would work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-17T07:23:35.683Z
Answers.Text: Ah, exactly what I've been trying to get my head around. So do model numbers not relate to the user object?
Answers.UserDisplayName: Sam Hibberd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-17T08:59:04.443Z
Answers.Text: You are correct. There is no connection between model number and user model. The same user can have different model numbers at different times because each time a new model will be created for that user.
  
  You can even try this to see the model number change on each refresh:
  {{ dump(craft.users.first()) }}
Answers.UserDisplayName: Moin Qidwai
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-17T03:30:24.020Z
Answers.LastActivityDate: 2015-02-17T03:30:24.020Z
Answers.UserDisplayName: Moin Qidwai
Answers.Body: <p>Try using <code>|without</code> based on arrays of user IDs, not entire UserModel objects. Behind the scenes, it's just using PHP's <a href="http://php.net/manual/en/function.in-array.php" rel="nofollow">in_array</a> method, which works much better on simple primitives like ints, strings, etc. instead of complex objects like Models (that has magic methods, other objects, primitives, etc.).  in_array probably doesn't know how deep of a comparison to make on those objects.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-16T20:55:22.240Z
Answers.Text: Ok I will try that, strange that it's working on one but not the other array (both of which contain the same data).
Answers.UserDisplayName: Sam Hibberd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-16T18:01:31.957Z
Answers.LastActivityDate: 2015-02-16T18:01:31.957Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am using the Dukt Follow plugin to return 2 arrays which both hold User objects, I am then using the without filter to remove users from the array which are considered friends. Friends are determined by using the intersect filter on the 2 arrays.</p>
  
  <p>Everything works apart from the second without filter which does not work, and returns objects that are in the friends array.</p>
  
  <pre><code>{# Friends, Followers &amp; Following #}
  {% set userFollowing = craft.follow.getFollowing(user.id) %}
  {% set userFollowers = craft.follow.getFollowers(user.id) %}
  
  {% set friends = userFollowing|length and userFollowers|length ? userFollowing|intersect(userFollowers) : null %}
  {% set following = userFollowing|without(friends) %}
  {% set followers = userFollowers|without(friends) %}
  </code></pre>
  
  <p>Is there an obvious reason why this might not be working?
  How is best to debug something like this?</p>
  
  <p>I have checked the output of all the arrays and objects and they do appear to hold the data that they should. </p>
  
  <p>Basic data stored in each array:</p>
  
  <pre><code>User Following:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn","Craft\\UserModel: shorn"]
  
  User Followers:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  
  Friends:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  
  Following:
  Array: {"2":"Craft\\UserModel: shorn"}
  
  Followers:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  </code></pre>
  
  <p>Full variable output can be accessed here: <a href="http://cl.ly/2o292X3O2r0M" rel="nofollow">http://cl.ly/2o292X3O2r0M</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-16T10:43:29.770Z
Comments.Text: Cannot really reproduce this. Would be helpful if you could post the data inside friends, userFollowing and userFollowers.
Comments.UserDisplayName: Moin Qidwai
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-16T16:52:47.527Z
Comments.Text: A bit confused — the output data that you posted contains 'userFollowing', 'userFollowers' (neither of which intersect btw), and 'friends' — not 'following', 'followers', and 'friends' as I would expect. Keep in mind that the `without` filter is returning a copy of the array — not modifying the original. In principle, this should work though. You might have something else going on with your data — I would check the values again carefully.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-16T17:33:09.717Z
Comments.Text: The data provided contains what was requested, can you confirm what you mean by 'neither of which intersect btw'? The friends array does return the required users which are in both arrays hence following each other?
Comments.UserDisplayName: Sam Hibberd
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-16T17:45:37.263Z
Comments.Text: @DouglasMcDonald I have added more debug data, does this help explain the issue any better?
Comments.UserDisplayName: Sam Hibberd
Tags: <templating><filter>
Title: Why is the Craft without filter not working correctly and how to debug?
ThreadText: # Why is the Craft without filter not working correctly and how to debug?
  
  (Asked by: username_0 on 2015-02-16)
  
  I am using the Dukt Follow plugin to return 2 arrays which both hold User objects, I am then using the without filter to remove users from the array which are considered friends. Friends are determined by using the intersect filter on the 2 arrays.
  
  Everything works apart from the second without filter which does not work, and returns objects that are in the friends array.
  
  ```
  {# Friends, Followers & Following #}
  {% set userFollowing = craft.follow.getFollowing(user.id) %}
  {% set userFollowers = craft.follow.getFollowers(user.id) %}
  
  {% set friends = userFollowing|length and userFollowers|length ? userFollowing|intersect(userFollowers) : null %}
  {% set following = userFollowing|without(friends) %}
  {% set followers = userFollowers|without(friends) %}
  
  ```
  
  Is there an obvious reason why this might not be working?
  How is best to debug something like this?
  
  I have checked the output of all the arrays and objects and they do appear to hold the data that they should.
  
  Basic data stored in each array:
  
  ```
  User Following:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn","Craft\\UserModel: shorn"]
  
  User Followers:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  
  Friends:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  
  Following:
  Array: {"2":"Craft\\UserModel: shorn"}
  
  Followers:
  Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
  
  ```
  
  Full variable output can be accessed here: <http://cl.ly/2o292X3O2r0M>
  
  **Tags:** templating, filter
  
  > **Comments:**
  > **username_1**: Cannot really reproduce this. Would be helpful if you could post the data inside friends, userFollowing and userFollowers.  
  > **username_2**: A bit confused — the output data that you posted contains 'userFollowing', 'userFollowers' (neither of which intersect btw), and 'friends' — not 'following', 'followers', and 'friends' as I would expect. Keep in mind that the `without` filter is returning a copy of the array — not modifying the original. In principle, this should work though. You might have something else going on with your data — I would check the values again carefully.  
  > **username_0**: The data provided contains what was requested, can you confirm what you mean by 'neither of which intersect btw'? The friends array does return the required users which are in both arrays hence following each other?  
  > **username_0**: @username_2 I have added more debug data, does this help explain the issue any better?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-02-17. Score: 1
  
  Hey Sam the answer is in your own dump file. Just look at the userModel Numbers in userFollowing, userFollowers and friends.
  
  UserFollowing has [379, 381, 393],
  UserFollowers has [446, 454] and
  friends has [379, 381]
  
  Friends has the same numbers as userFollowing but not the same as userFollowers. Hence when you do the without filter on userFollowers you are basically doing
  [446, 454]|without([379, 381])
  Which will ofcourse return [446, 454].
  
  You could ofcourse get the username out for each model and perform the operations on that and since those would be strings this would work.
  
  > **Comments:**
  > **username_0**: Ah, exactly what I've been trying to get my head around. So do model numbers not relate to the user object?  
  > **username_1**: You are correct. There is no connection between model number and user model. The same user can have different model numbers at different times because each time a new model will be created for that user.  You can even try this to see the model number change on each refresh: {{ dump(craft.users.first()) }}  
  
  ---
  
  ### Answer by username_3 on 2015-02-16. Score: 1
  
  Try using `|without` based on arrays of user IDs, not entire UserModel objects. Behind the scenes, it's just using PHP's [in\_array](http://php.net/manual/en/function.in-array.php) method, which works much better on simple primitives like ints, strings, etc. instead of complex objects like Models (that has magic methods, other objects, primitives, etc.). in\_array probably doesn't know how deep of a comparison to make on those objects.
  
  > **Comments:**
  > **username_0**: Ok I will try that, strange that it's working on one but not the other array (both of which contain the same data).  
  
  ---
  
  