Answers.Body: <p>This problem recurred for us in 4.7, and the workaround suggested in the comments by jitendrapurohit didn't work when I tried to re-edit CRM/Contact/BAO/Query.php. As it seemed likely the problem was actually related to the database, I had a dig around in the db, and found that there was an old smart group linked to a saved search that was looking for contacts in the UK - that seemed to be referencing the country in a way that didn't match the current country references in CRM/Contact/BAO/Query.php, so I deleted the smart group from the db and ran the 'Rebuild Smart Group Cache' job. The fatal error is no longer being triggered, so I'm fairly sure that's what was causing the problem.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-01T16:38:30.887Z
Answers.LastActivityDate: 2016-02-01T16:38:30.887Z
Answers.UserDisplayName: liblogger
Answers.Body: <p>There were some known issues regarding Smart Groups in 4.6.9</p>
  
  <p>I would suggest you upgrade since the 4.6.10 is a security release and try rebuilding them.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-16T15:47:23.317Z
Answers.Text: (Not sure if my previous comments reached you - still getting my head round SE)
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T16:04:14.130Z
Answers.Text: Hi Pete - the upgrade to 4.6.10 doesn't seem to have made a difference. The link to the manage groups page is still broken. I hadn't noticed that the smart groups weren't displaying in the contact record - both before and after the upgrade it's displaying "Sorry but we are not able to provide this at the moment." and "Sorry an Error Occured / United Kingdom is not of the type Positive"
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T16:07:57.837Z
Answers.Text: I am able to create a Smart Group from the same search - but unlike the non-smart group, I can't then go into the group contact list page.
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T16:39:27.613Z
Answers.Text: Oh, and trying to rebuild the smart group cache also results in a 'United Kingdom is not of the type Positive' fatal error. My colleagues think this is stereotyping :)
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T18:12:26.780Z
Answers.LastActivityDate: 2015-11-05T18:12:26.780Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>I've seen something similar.  After the failure, have you tried to go back to the manage groups page.  In our case you can.  The first time it goes and gets all the counts of how many contacts are in each group.  The next time it doesn't.  If it errors in the group count, it gives that message.  You can manually trigger a count by clicking on the Update Smart Group counts link (under and to the right of the Find Groups box).</p>
  
  <p>Assuming you can get to the groups the second time, try disabling the group and trigger the count.  If that works, then try creating a new smart group that does the same thing the old one did.  In our case that worked.</p>
  
  <p>The logic that creates the sql to do the smart group is always being tweaked (it can be quite complicated).  Sometimes what was created in one version doesn't work quite right in a later version.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T15:53:13.340Z
Answers.Text: No, we can't get to the manage groups page, however often we try. The group that was being created was just a regular non-smart group - we hadn't got as far as noticing the issue with the smart groups!
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T17:58:35.523Z
Answers.LastActivityDate: 2015-11-05T17:58:35.523Z
Answers.UserDisplayName: Paul-Tahoe
Answers.Body: <p>Similar issue has been recently resolved in master(<a href="https://issues.civicrm.org/jira/browse/CRM-17361" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-17361</a>). </p>
  
  <p>Can you patch up your site with <a href="https://github.com/civicrm/civicrm-core/pull/6985" rel="nofollow">https://github.com/civicrm/civicrm-core/pull/6985</a> and see if it works for you ? </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-10T07:08:47.360Z
Answers.Text: yes, you need to make sure that the patch has been applied correctly. Line number may not be matching as improvements w.r.t file gets added very often. In that case, manually apply the patch pasting the added code b/w the correct starting and ending point.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-10T10:51:33.897Z
Answers.Text: Sorry, should have clarified - I added the patch manually because of the line number discrepancy, but we're still seeing the error.
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-16T15:46:40.253Z
Answers.Text: (Not sure if my previous comment reached you - still getting my head round SE)
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-17T04:48:50.573Z
Answers.Text: Looking at the backtrace, the `country_id` should be retrieved as 'id' and not the name of the country, which seems to be failing in your case due to some reason which you need to figure out. For the time being, I think, your case will work if you revert `CRM/Contact/BAO/Query.php` changes from [this commit](https://github.com/civicrm/civicrm-core/commit/836f1f3fb0ace7318b1728e8e9eb42b12f075290). Please let us know if it worked.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-23T17:10:06.537Z
Answers.Text: Hi @jitendrapurohit - reverting those changes does seem to have worked - we can access the Manage groups page and view Smart groups in the contact record. I'm not sure where to start in terms of figuring out why the country id isn't being retrieved correctly - any pointers? Or should I start a new question?
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T16:18:20.447Z
Answers.Text: I'm afraid it doesn't seem to have made a difference. I noticed the line numbers were different, so I don't know if there are other file differences between 4.6.10 and the patched version that would affect this issue?
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-06T06:27:44.630Z
Answers.LastActivityDate: 2015-11-06T06:27:44.630Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>We're unable to access to the Manage groups page - it brings up a fatal error with the message:  </p>
  
  <p>Sorry but we are not able to provide this at the moment.<br>
  United Kingdom is not of the type Positive</p>
  
  <p>I'm not sure if this is since we upgraded to 4.6.9, or if it was triggered by the creation of a group from a custom search (Contacts by date added).</p>
  
  <p>We seem to be able to access individual groups by going through the groups tab in contact records, and we're able to add new groups.</p>
  
  <p>The error log has the following:</p>
  
  <pre><code>Nov 05 16:00:29  [info] $Fatal Error Details = Array
  (
      [message] =&gt; United Kingdom is not of the type Positive
      [code] =&gt; 
  )
  
  
  Nov 05 16:00:29  [info] $backTrace = #0 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Error.php(364):    CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Utils\Type.php(259): CRM_Core_Error::fatal("United Kingdom is not of the type Positive")
  #2 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(5171): CRM_Utils_Type::escape("United Kingdom", "Positive")
  #3 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(3575): CRM_Contact_BAO_Query::buildClause("civicrm_address.country_id", "=", "United Kingdom", "Positive")
  #4 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1741): CRM_Contact_BAO_Query-&gt;country((Array:5), FALSE)
  #5 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1873): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5))
  #6 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(499): CRM_Contact_BAO_Query-&gt;whereClause()
  #7 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(461): CRM_Contact_BAO_Query-&gt;initialize()
  #8 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(501): CRM_Contact_BAO_Query-&gt;__construct((Array:6), (Array:4), NULL, FALSE, FALSE, 1, TRUE, TRUE, FALSE, NULL, (Array:3))
  #9 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(2924): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
  #10 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(2834): CRM_Contact_BAO_Query-&gt;addGroupContactCache((Array:1), NULL, "contact_a", "IN")
  #11 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1657): CRM_Contact_BAO_Query-&gt;group((Array:5))
  #12 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1873): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5))
  #13 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(499): CRM_Contact_BAO_Query-&gt;whereClause()
  #14 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(461): CRM_Contact_BAO_Query-&gt;initialize()
  #15 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(4314): CRM_Contact_BAO_Query-&gt;__construct((Array:1), (Array:1), NULL, TRUE, FALSE, 1, TRUE, TRUE, FALSE)
  #16 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(220): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
  #17 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(192): CRM_Contact_BAO_GroupContactCache::add((Array:36))
  #18 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(202): CRM_Contact_BAO_GroupContactCache::loadAll()
  #19 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Group\Page\Group.php(147): CRM_Contact_BAO_GroupContactCache::fillIfEmpty()
  #20 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Page\Basic.php(178): CRM_Group_Page_Group-&gt;browse(NULL, NULL)
  #21 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(312): CRM_Core_Page_Basic-&gt;run((Array:2), NULL)
  #22 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))
  #23 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(54): CRM_Core_Invoke::_invoke((Array:2))
  #24 C:\xampp\htdocs\switch\sites\all\modules\civicrm\drupal\civicrm.module(489): CRM_Core_Invoke::invoke((Array:2))
  #25 [internal function](): civicrm_invoke("group")
  #26 C:\xampp\htdocs\switch\includes\menu.inc(527): call_user_func_array("civicrm_invoke", (Array:1))
  #27 C:\xampp\htdocs\switch\index.php(21): menu_execute_active_handler()
  #28 {main}
  </code></pre>
  
  <p>Any ideas as to what might be causing this? It doesn't happen in the demo version.</p>
  
Tags: <groups><error>
Title: Fatal error when trying to access the Manage Groups page
ThreadText: # Fatal error when trying to access the Manage Groups page
  
  (Asked by: username_0 on 2015-11-05)
  
  We're unable to access to the Manage groups page - it brings up a fatal error with the message:
  
  Sorry but we are not able to provide this at the moment.  
  United Kingdom is not of the type Positive
  
  I'm not sure if this is since we upgraded to 4.6.9, or if it was triggered by the creation of a group from a custom search (Contacts by date added).
  
  We seem to be able to access individual groups by going through the groups tab in contact records, and we're able to add new groups.
  
  The error log has the following:
  
  ```
  Nov 05 16:00:29  [info] $Fatal Error Details = Array
  (
      [message] => United Kingdom is not of the type Positive
      [code] => 
  )
  
  Nov 05 16:00:29  [info] $backTrace = #0 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Error.php(364):    CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Utils\Type.php(259): CRM_Core_Error::fatal("United Kingdom is not of the type Positive")
  #2 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(5171): CRM_Utils_Type::escape("United Kingdom", "Positive")
  #3 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(3575): CRM_Contact_BAO_Query::buildClause("civicrm_address.country_id", "=", "United Kingdom", "Positive")
  #4 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1741): CRM_Contact_BAO_Query->country((Array:5), FALSE)
  #5 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1873): CRM_Contact_BAO_Query->whereClauseSingle((Array:5))
  #6 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(499): CRM_Contact_BAO_Query->whereClause()
  #7 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(461): CRM_Contact_BAO_Query->initialize()
  #8 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(501): CRM_Contact_BAO_Query->__construct((Array:6), (Array:4), NULL, FALSE, FALSE, 1, TRUE, TRUE, FALSE, NULL, (Array:3))
  #9 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(2924): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
  #10 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(2834): CRM_Contact_BAO_Query->addGroupContactCache((Array:1), NULL, "contact_a", "IN")
  #11 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1657): CRM_Contact_BAO_Query->group((Array:5))
  #12 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(1873): CRM_Contact_BAO_Query->whereClauseSingle((Array:5))
  #13 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(499): CRM_Contact_BAO_Query->whereClause()
  #14 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(461): CRM_Contact_BAO_Query->initialize()
  #15 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\Query.php(4314): CRM_Contact_BAO_Query->__construct((Array:1), (Array:1), NULL, TRUE, FALSE, 1, TRUE, TRUE, FALSE)
  #16 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(220): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
  #17 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(192): CRM_Contact_BAO_GroupContactCache::add((Array:36))
  #18 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Contact\BAO\GroupContactCache.php(202): CRM_Contact_BAO_GroupContactCache::loadAll()
  #19 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Group\Page\Group.php(147): CRM_Contact_BAO_GroupContactCache::fillIfEmpty()
  #20 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Page\Basic.php(178): CRM_Group_Page_Group->browse(NULL, NULL)
  #21 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(312): CRM_Core_Page_Basic->run((Array:2), NULL)
  #22 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))
  #23 C:\xampp\htdocs\switch\sites\all\modules\civicrm\CRM\Core\Invoke.php(54): CRM_Core_Invoke::_invoke((Array:2))
  #24 C:\xampp\htdocs\switch\sites\all\modules\civicrm\drupal\civicrm.module(489): CRM_Core_Invoke::invoke((Array:2))
  #25 [internal function](): civicrm_invoke("group")
  #26 C:\xampp\htdocs\switch\includes\menu.inc(527): call_user_func_array("civicrm_invoke", (Array:1))
  #27 C:\xampp\htdocs\switch\index.php(21): menu_execute_active_handler()
  #28 {main}
  
  ```
  
  Any ideas as to what might be causing this? It doesn't happen in the demo version.
  
  **Tags:** groups, error
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2016-02-01. Score: 0 | Accepted answer
  
  This problem recurred for us in 4.7, and the workaround suggested in the comments by jitendrapurohit didn't work when I tried to re-edit CRM/Contact/BAO/Query.php. As it seemed likely the problem was actually related to the database, I had a dig around in the db, and found that there was an old smart group linked to a saved search that was looking for contacts in the UK - that seemed to be referencing the country in a way that didn't match the current country references in CRM/Contact/BAO/Query.php, so I deleted the smart group from the db and ran the 'Rebuild Smart Group Cache' job. The fatal error is no longer being triggered, so I'm fairly sure that's what was causing the problem.
  
  
  ---
  
  ### Answer by username_1 on 2015-11-05. Score: 0
  
  There were some known issues regarding Smart Groups in 4.6.9
  
  I would suggest you upgrade since the 4.6.10 is a security release and try rebuilding them.
  
  > **Comments:**
  > **username_0**: Hi Pete - the upgrade to 4.6.10 doesn't seem to have made a difference. The link to the manage groups page is still broken. I hadn't noticed that the smart groups weren't displaying in the contact record - both before and after the upgrade it's displaying "Sorry but we are not able to provide this at the moment." and "Sorry an Error Occured / United Kingdom is not of the type Positive"  
  > **username_0**: I am able to create a Smart Group from the same search - but unlike the non-smart group, I can't then go into the group contact list page.  
  > **username_0**: Oh, and trying to rebuild the smart group cache also results in a 'United Kingdom is not of the type Positive' fatal error. My colleagues think this is stereotyping :)  
  > **username_0**: (Not sure if my previous comments reached you - still getting my head round SE)  
  
  ---
  
  ### Answer by username_2 on 2015-11-05. Score: 0
  
  I've seen something similar. After the failure, have you tried to go back to the manage groups page. In our case you can. The first time it goes and gets all the counts of how many contacts are in each group. The next time it doesn't. If it errors in the group count, it gives that message. You can manually trigger a count by clicking on the Update Smart Group counts link (under and to the right of the Find Groups box).
  
  Assuming you can get to the groups the second time, try disabling the group and trigger the count. If that works, then try creating a new smart group that does the same thing the old one did. In our case that worked.
  
  The logic that creates the sql to do the smart group is always being tweaked (it can be quite complicated). Sometimes what was created in one version doesn't work quite right in a later version.
  
  > **Comments:**
  > **username_0**: No, we can't get to the manage groups page, however often we try. The group that was being created was just a regular non-smart group - we hadn't got as far as noticing the issue with the smart groups!  
  
  ---
  
  ### Answer by username_3 on 2015-11-06. Score: 0
  
  Similar issue has been recently resolved in master(<https://issues.civicrm.org/jira/browse/CRM-17361>).
  
  Can you patch up your site with <https://github.com/civicrm/civicrm-core/pull/6985> and see if it works for you ?
  
  > **Comments:**
  > **username_0**: I'm afraid it doesn't seem to have made a difference. I noticed the line numbers were different, so I don't know if there are other file differences between 4.6.10 and the patched version that would affect this issue?  
  > **username_3**: yes, you need to make sure that the patch has been applied correctly. Line number may not be matching as improvements w.r.t file gets added very often. In that case, manually apply the patch pasting the added code b/w the correct starting and ending point.  
  > **username_0**: Sorry, should have clarified - I added the patch manually because of the line number discrepancy, but we're still seeing the error.  
  > **username_0**: (Not sure if my previous comment reached you - still getting my head round SE)  
  > **username_3**: Looking at the backtrace, the `country_id` should be retrieved as 'id' and not the name of the country, which seems to be failing in your case due to some reason which you need to figure out. For the time being, I think, your case will work if you revert `CRM/Contact/BAO/Query.php` changes from [this commit](https://github.com/civicrm/civicrm-core/commit/836f1f3fb0ace7318b1728e8e9eb42b12f075290). Please let us know if it worked.  
  > **username_0**: Hi @jitendrapurohit - reverting those changes does seem to have worked - we can access the Manage groups page and view Smart groups in the contact record. I'm not sure where to start in terms of figuring out why the country id isn't being retrieved correctly - any pointers? Or should I start a new question?  
  
  ---
  
  