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 Drupal Modules (Moderator: Donald Lobo) »
  • Some (not all) custom data not available to Drupal Views after upgrade to 4.2
Pages: 1 [2]

Author Topic: Some (not all) custom data not available to Drupal Views after upgrade to 4.2  (Read 4334 times)

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 10, 2012, 08:00:53 am
Same issue. Subscribing.

Update: Patch seems to work if applied manually... checking...

Error:

Notice: Array to string conversion in CRM_Core_BAO_CustomGroup::getTree() (line 412 of sites/all/modules/civicrm/CRM/Core/BAO/CustomGroup.php).

Will need to use the $groupTree = ''; workaround for now.
« Last Edit: September 10, 2012, 09:49:17 am by bcobin »

russneversleeps

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.5.25
  • PHP version: 5.3.13
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 10, 2012, 02:07:46 pm
Quote from: bcobin on September 10, 2012, 08:00:53 am
Error:

Notice: Array to string conversion in CRM_Core_BAO_CustomGroup::getTree() (line 412 of sites/all/modules/civicrm/CRM/Core/BAO/CustomGroup.php).

Will need to use the $groupTree = ''; workaround for now.

The array $params is assigned values at Line 385 of CustomGroup.php:

Code: [Select]
      $params[1] = array($groupID, 'Integer');

So, for $groupID = 1, $params looks like this:

Code: [Select]
Array
(
    [1] => Array
               (
                    [0] => 1
                    [1] => 'Integer'
                )
)                   

An array nested inside of another array.

Line 412 of the patched file:

Code: [Select]
        implode( ',', array_values($params));

From what I can tell, the intention of this line is to flatten the array $params and return a comma-separated list of the values (something like "1,'Integer'") which is appended to $cacheString which is used to generate a unique $cacheKey. However, as $params consists of a nested array, the implode function returns "Array" rather than the expected string (this where the "Array to string conversion" error is thrown). As a result, each Custom Group doesn't get a unique $cacheString (and therefore $cacheKey), and as a result the wrong $groupTree is retrieved from cache.

One way to fix this would be to change line 412 to:
Code: [Select]
        implode( ',', array_values($params[1]));

For the record, I am not a programmer, and I certainly don't know enough about the caching system to know whether this actually addresses the problem or is just another workaround, or what unexpected consequences might result.

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: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 10, 2012, 02:30:56 pm

thanx for pursuing and following up on this. Good catch :)

Can you try the following much simplified patch:

Code: [Select]

Index: CRM/Core/BAO/CustomGroup.php
===================================================================
--- CRM/Core/BAO/CustomGroup.php        (revision 42296)
+++ CRM/Core/BAO/CustomGroup.php        (working copy)
@@ -406,11 +406,12 @@

     // lets see if we can retrieve the groupTree from cache
     $cacheString = $queryString;
-    if (!empty($params)) {
-      $cacheString .=
-        implode( ',', array_keys($params)) .
-        implode( ',', array_values($params));
+    if ( $groupID > 0 ) {
+      $cacheString .= "_{$groupID}";
+    } else {
+      $cacheString .= "_Inline";
     }
+
     $cacheKey = "CRM_Core_DAO_CustomGroup_Query " . md5($cacheString);

     $cache = CRM_Utils_Cache::singleton();

thanx

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

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 10, 2012, 02:44:47 pm
Applied manually - seems to work! Nice job...

russneversleeps

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.5.25
  • PHP version: 5.3.13
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 10, 2012, 06:13:35 pm
Quote from: Donald Lobo on September 10, 2012, 02:30:56 pm

thanx for pursuing and following up on this. Good catch :)

Can you try the following much simplified patch:
Motivated almost purely out of self-interest, but glad that I could help.  :)

New patch works for me. At least, it restores Views access to all custom data groups. No idea whether the caching functionality is working correctly, but no error messages yet.

mostou

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5
  • PHP version: 5
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 19, 2012, 10:44:08 am
Works for me as well - great job. Thanks alot!

Dave Melkman

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: CiviCRM 4.0.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.14
  • PHP version: 5.3.6
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
September 28, 2012, 07:49:28 am
Just to add, I had the same problem and the code worked a treat and I can now see all my custom data again. Thanks Lobo.  :)

jarune

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: Drupal
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
October 10, 2012, 02:45:34 am
Works for me too but why is the patch based on the previous one instead of on the original code base (4.2)
When will this patch be in core?

jdaniluk

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • CiviCRM version: 4.2.0
  • CMS version: Drupal 7.14
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
October 26, 2012, 09:27:24 am
I have what sounds like the same problem.  Hopefully this fix will do the trick for me, too.

I have 8 groups of custom data, 2 for events and 6 for contacts.  Under CiviCRM 4.0.3,  views integration was working for all the custom data groups I needed on the Drupal side.  I recently updated to CiviCRM 4.2 and updated Drupal core, and I find that some of the custom data has dropped out of my existing views.  In a view of CiviCRM contacts, only 4 of my 6 custom data groups are now available.  I have rebuilt my settings.php and doublechecked all the CiviCRM database integration code, cleared the Drupal cache and the views cache.

I truly appreciate everybody's efforts in this forum for reporting the issues, discovering fixes, and reporting on the results of the fixes. You guys are the greatest!

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Some (not all) custom data not available to Drupal Views after upgrade to 4.2
January 30, 2013, 09:00:58 am
I'm having the same issue but when trying to apply the patch I get the following:
Code: [Select]
patching file CustomGroup.php
Reversed (or previously applied) patch detected!  Assume -R?
I'm using CiviCRM 4.2.4 and Drupal 6.26. I assume that my installation of CiviCRM already has the patch installed; however, I can still only see two sets of custom fields and they happen to have the gid's of 1 and 2. Nothing else is showing up in my Drupal View. Any thoughts as to what I need to do?

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Some (not all) custom data not available to Drupal Views after upgrade to 4.2

This forum was archived on 2017-11-26.