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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
Pages: 1 [2]

Author Topic: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities  (Read 4008 times)

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 06:36:10 am
could you please integrate this patch w/ you CRM/Mailing/BAO/Job.php  around line 434

remove these line of code  :
Code: [Select]
           require_once 'api/v2/Activity.php';
            if ( is_a( civicrm_activity_create($activity, 'Email'), 'CRM_Core_Error' ) ) {
                return false;
            }

add following lines of code :

Code: [Select]
           require_once 'api/v2/Activity.php';
            $isError = civicrm_activity_create( $activity );
            if ( is_a( $isError, 'CRM_Core_Error' ) ) {
                crm_core_error::debug( '$activity', $activity );
                exit( );
                return false;
            }

and let us know the out put.

thanks

kiran
« Last Edit: November 02, 2010, 06:51:11 am by Kiran Jagtap »
You Are Designed To Choose... Defined By Choice.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 06:57:58 am
here is the filed issue : http://issues.civicrm.org/jira/browse/CRM-7022

thanks

kiran
You Are Designed To Choose... Defined By Choice.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 08:18:20 am
Now we are doing more properly validations for single as well as an array of ids.

could you please integrate the patch : https://fisheye2.atlassian.com/changelog/CiviCRM?cs=30482

and let us know if it works for your installation.

thanks

kiran
You Are Designed To Choose... Defined By Choice.

grahamgilchrist

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 3
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 08:41:03 am
Quote from: Kiran Jagtap on November 02, 2010, 06:36:10 am
could you please integrate this patch w/ you CRM/Mailing/BAO/Job.php  around line 434

remove these line of code  :
Code: [Select]
           require_once 'api/v2/Activity.php';
            if ( is_a( civicrm_activity_create($activity, 'Email'), 'CRM_Core_Error' ) ) {
                return false;
            }

add following lines of code :

Code: [Select]
           require_once 'api/v2/Activity.php';
            $isError = civicrm_activity_create( $activity );
            if ( is_a( $isError, 'CRM_Core_Error' ) ) {
                crm_core_error::debug( '$activity', $activity );
                exit( );
                return false;
            }

and let us know the out put.

Sure no problem. I get no output from this. Debugging more with an extra line:

Code: [Select]
    require_once 'api/v2/Activity.php';
    $isError = civicrm_activity_create( $activity );
    echo print_r($isError, true);

    if ( is_a( $isError, 'CRM_Core_Error' ) ) {
          echo 'an error occurred';
          crm_core_error::debug( '$activity', $activity );
          exit( );
           return false;
     }

shows that the results of is_a are positive. I.e. it is not correctly identifying the error array.
This is what I get back from print_r($is_error)

Code: [Select]
Array
(
    [is_error] => 1
    [error_message] => Invalid Target Contact Id
)

but the 'an error has occurred' text never appears. So civiCRM is not identifying this as a core error, which is probably right since it is just rejecting invalid parameters?

grahamgilchrist

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 3
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 08:46:32 am
Quote from: Kiran Jagtap on November 02, 2010, 08:18:20 am
could you please integrate the patch : https://fisheye2.atlassian.com/changelog/CiviCRM?cs=30482

and let us know if it works for your installation.

Hi Kiran,
Thanks, that patch works great!

I am getting activities logged properly now, and observing the value of $is_error I get:

Code: [Select]

Array
(
    [is_error] => 0
    [id] => 43817
    [source_contact_id] => 102
    [source_record_id] => 183
    [activity_type_id] => 34
    [subject] => test of activity logging which appears to be broken
    [activity_date_time] => 20101102154132
    [duration] =>
    [location] =>
    [phone_id] =>
    [phone_number] =>
    [details] =>
    [status_id] => 2
    [priority_id] => 2
    [parent_id] =>
    [is_test] =>
    [medium_id] =>
    [is_auto] =>
    [relationship_id] =>
    [is_current_revision] =>
    [original_id] =>
    [is_deleted] =>
)

which is the correct response for a successful activity API call.

Thanks for all your help on this. I am now a happy person :)

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 09:57:57 am
Applying patch 30482 to 3.2.4 fixed it here too, thanks Kiran! :)

I think there's another little problem with the code, which explains why the failure of civicrm_activity_create was not detected.

Quote from: grahamgilchrist on November 02, 2010, 08:41:03 am
... it is not correctly identifying the error array.
This is what I get back from print_r($is_error)

Code: [Select]
Array
(
    [is_error] => 1
    [error_message] => Invalid Target Contact Id
)

but the 'an error has occurred' text never appears. So civiCRM is not identifying this as a core error, which is probably right since it is just rejecting invalid parameters?

The problem is that the code tests for an error like this:

Code: [Select]
            $isError = civicrm_activity_create( $activity );
            if ( is_a( $isError, 'CRM_Core_Error' ) ) {
                return false;
            }

However API functions do not return a CRM_Core_Error object, they return an array with 'is_error' => 1. E.g. on error, _civicrm_activity_check_params (api/v2/Activity.php) calls civicrm_create_error (api/v2/utils.php) which calls CRM_Core_Error::createAPIError, which creates an array with 'is_error' => 1.

I believe the return value of an API function should be tested withthe function civicrm_error (api/v2/utils.php):


Code: [Select]
            $isError = civicrm_activity_create( $activity );
            if ( civicrm_error( $isError ) ) {
                return false;
            }

Dave J

grahamgilchrist

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 3
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 10:11:50 am
Quote from: davej on November 02, 2010, 09:57:57 am
think there's another little problem with the code, which explains why the failure of civicrm_activity_create was not detected.

....

I believe the return value of an API function should be tested withthe function civicrm_error (api/v2/utils.php):

That seems like the right approach. I knew that check was going wrong somewhere but I just assumed it was there to prevent some kind of fatal error during the activity API call. Your solution seems the correct way.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Upgrade 3.1.3-3.2.3 Civimail no longer recording activities
November 02, 2010, 10:43:37 pm
Hello Dave,

Code: [Select]
I believe the return value of an API function should be tested withthe function civicrm_error (api/v2/utils.php):


           $isError = civicrm_activity_create( $activity );
            if ( civicrm_error( $isError ) ) {
                return false;
            }

agree.

fixed is here : https://fisheye2.atlassian.com/changelog/CiviCRM?cs=30494

good work grahamgilchrist and dave  :)

thanks

kiran
You Are Designed To Choose... Defined By Choice.

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrade 3.1.3-3.2.3 Civimail no longer recording activities

This forum was archived on 2017-11-26.