CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 'state' field query malfunction
Pages: [1]

Author Topic: 'state' field query malfunction  (Read 1079 times)

anothername

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 3
  • CiviCRM version: CiviCRM 4.2.6
  • CMS version: Drupal 7.19
  • MySQL version: 5.1.66-0+squeeze1-log
  • PHP version: 5.3.3-7+squeeze14
'state' field query malfunction
July 20, 2011, 08:24:14 pm
Strange bug here. For some reason (hopefully soon to be discovered) the when doing searches, the 'state' field is not pulling up contacts with the selected 'state' but all contacts with the other appropriate fields selected (included other address types).

What reasons are there for a search field to function like this? The data still exists because it still shows up (and exist in the mysql tables).

The advance search gives the appropriate prompt:  State/Province - Alabama ...AND... Country = 'United States'  Though, that does not change the fact that the search results include all states, regardless of if they are Alabama.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 'state' field query malfunction
July 21, 2011, 12:12:42 am

this was a bug in earlier versions of 3.4.x

can u upgrade to 3.4.4. If the bug is still there, can you please reproduce on our demo server and let us know. Definitely a critical bug that needs to be fixed before the next release :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

anothername

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 3
  • CiviCRM version: CiviCRM 4.2.6
  • CMS version: Drupal 7.19
  • MySQL version: 5.1.66-0+squeeze1-log
  • PHP version: 5.3.3-7+squeeze14
Re: 'state' field query malfunction
July 21, 2011, 09:19:56 am
I am at 3.4.4 but cannot reproduce it on the demo site.

Very strange.

anothername

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 3
  • CiviCRM version: CiviCRM 4.2.6
  • CMS version: Drupal 7.19
  • MySQL version: 5.1.66-0+squeeze1-log
  • PHP version: 5.3.3-7+squeeze14
Re: 'state' field query malfunction
July 26, 2011, 08:38:56 am
Is there any reason the bug would exist on my system but not the demo? All the tables are there an everything...

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: 'state' field query malfunction
July 26, 2011, 02:02:15 pm
The demo is sometimes updated from svn repository so it probably has code changes made after 3.4.4 release. I looked for the issue on the issue tracker to verify if it was fixed before or after 3.4.4 release but did not see it (only a similar search builder issue).
Protect your investment in CiviCRM by  becoming a Member!

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: 'state' field query malfunction
July 29, 2011, 12:07:58 am
Just to add to this, I've updated to 3.4.4 as well and am seeing the same error.  It works as it should on demo.  Is there any other diagnosis I can do?  I've turned on devel and query logging but it isn't shedding any light.  I can filter by other fields for example postcode and city successfully.  It happens on my dev install so going to turn on query log and try running the whole thing through the debugger when I get a chance but any insight would be welcome.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: 'state' field query malfunction
August 03, 2011, 10:52:22 pm
Looking at the code in CRM/Contact/BAO/Query.php in the stateProvince function there are these lines (at about line 2951):

Code: [Select]
        if ( $countryClause ) {
            $clause = ( $stateClause AND $countryClause );
        } else {
            $clause = $stateClause;
        }

If I change the second line there as below it works fine.

Code: [Select]
            $clause = ( $stateClause . ' AND ' . $countryClause );

I feel like I might be missing something obvious, so I thought I'd check before trying to provide a patch.

Malks.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: 'state' field query malfunction
August 03, 2011, 11:17:28 pm
In 3.4.5 the line is changed to:

Code: [Select]
            $clause = "( $stateClause AND $countryClause )";

Which should work just fine.

anothername

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 3
  • CiviCRM version: CiviCRM 4.2.6
  • CMS version: Drupal 7.19
  • MySQL version: 5.1.66-0+squeeze1-log
  • PHP version: 5.3.3-7+squeeze14
Re: 'state' field query malfunction
August 06, 2011, 09:27:34 pm
The upgrade to 3.4.5 fixed it.

sergeich

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
    • USDLC
Re: 'state' field query malfunction
August 13, 2011, 01:10:24 pm
I ran into the same issue on 3.4.4. Thanks for an easy fix! Glad I found it before posting a new topic.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 'state' field query malfunction

This forum was archived on 2017-11-26.