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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_contactListQuery Not Being Called in 4.2
Pages: [1]

Author Topic: hook_civicrm_contactListQuery Not Being Called in 4.2  (Read 817 times)

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 11:17:14 am
We have a few uses for hook_civicrm_contactListQuery, filtering which contacts show up for contact reference custom fields.  As of our upgrade to 4.2.19, it seems it is no longer being called.  None of our custom fields are getting filtered properly.

Here is an example the basic code we use, I don't see why it would not work.  Is this a bug?

Code: [Select]
function fei_civicrm_contactListQuery( &$query, $name, $context, $id )
{

  // Connect the hook to the Contact Reference custom field using the field ID
  // Field ID 29: Team Coordinator for Team Events
  if ( $context == 'customfield' && $id == 29 ) {

    // Construct the query to select only the contacts we want
    // The query must return two columns - data (what is shown in the field display), and contact id
    $query = "SELECT
      case when c.nick_name is not null then concat(c.nick_name, ' ', c.last_name) else c.display_name end as data
      , c.id
      FROM civicrm_contact c
      INNER JOIN civicrm_group_contact cg
        ON c.id = cg.contact_id
      WHERE (concat(last_name, ', ', ifnull(nick_name, first_name)) LIKE '%$name%'
             OR
             sort_name LIKE '%$name%'
            )
      AND   cg.group_id IN ( 10 ) -- This must match the ID of the FEI Staff: Home Office group
      AND   cg.status = 'Added'
      AND   c.is_deleted = 0
      ORDER BY c.sort_name
      LIMIT 50";
  } // end if context


} // end function

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 02:40:32 pm
What did you upgrade from to get to 4.2.19 - I can't imagine it would have been a regression late in the 4.2 series - but maybe it did regress at some point?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 02:52:38 pm
We upgraded from 3.3.6, so I'm not sure where this could have occurred.  Any work-around to get it going?  Should I file a bug?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 03:01:45 pm
I think if you want to file a bug for a hook not being called you probably need to do it against a more recent version. I can see the calls to that hook exist in similar places in 4.4 & in 4.2 - but I haven't personally used it
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 03:28:46 pm
I was under the impression 4.2 was LTS.  Doesn't a bug like this count in that?

I would try to go to 4.4, but it seems there are some database structure changes and we have a lot of custom code to work through.  I was hoping we can get 4.2 working so we can stay there until the one developer (me) has enough time to work through higher versions with more changes and potential surprises like this one.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 25, 2014, 03:33:20 pm
4.2 has recently been downgraded to security fixes only with 4.4 to be the next LTS.

But this is the sort of bug which is not readily replicable so you would probably need to do quite a bit of work at your end  before someone else would/ could pick it up and work on it - in any version. Generally the LTS only has fixes in it that are in an upstream version so the first step to getting something fixed in an LTS is to determine if the bug exists in 4.5.

 
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 26, 2014, 06:20:36 am
Hi Eileen,
So I upgraded to 4.5 on my dev box (same config as production), and the issue still persists.  The hook is not getting called.  What do you recommend now?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 26, 2014, 02:18:38 pm
Is your module definitely being recognised? Are other hooks in it called?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 26, 2014, 02:36:51 pm
Yes, my module has other hooks, including additional Tabs for Contacts and buildForm hooks for Event Registration forms, and those all work fine.  It is only the contactListQuery that is not being called for custom fields.  If it helps, the custom fields this is failing on are for Events (when you create an event), not sure that matters, though.

As I mentioned, it works fine in 3.3.6, and I believe my code is rather straightforward.  I didn't test on any versions other than 4.2 and 4.5, both of which don't work.  I cannot test this on the demo, of course, so I can't verify outside my environments.  But I can tell you this happens on both our production instance (which we had to roll back from 4.2 to 3.3.6 because of issues like this) and my dev box.

Also, I recall searching these forums, and I found at least one other post mentioning the same issue.  No one replied to that post and I wasn't sure which version it was on, so I created a new post.

Please let me know how I should proceed.

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: hook_civicrm_contactListQuery Not Being Called in 4.2
September 26, 2014, 06:09:04 pm
Your best bet would be to debug the code and try to figure out the bug. If Yiu are not a developer, might want to consider asking a local Civi developer and/or hiring someone to take a look and fix

If you do find the issue, please submit the pat h back to core so others can benefit

Thanks

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

pbarmak

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 3
  • CiviCRM version: 3.3.5
  • CMS version: Pressflow 6.19
  • MySQL version: 5.1
  • PHP version: 5.2.10
Re: hook_civicrm_contactListQuery Not Being Called in 4.2
September 27, 2014, 11:03:42 am
Well, could you maybe give me a place to even start debugging?  Where is the hook supposed to be called from?  I see CRM/Utils/Hook.php, but that just seems to define each function.  What does the calling of the hook when a custom field shows up on a form?

Some help would be appreciated, I don't know the core code like you all do, I just create customizations like hooks per your documentation (which was working well till recently).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_contactListQuery Not Being Called in 4.2

This forum was archived on 2017-11-26.