christianwach / civicrm-wp-profile-sync

Keeps a WordPress User profile in sync with a CiviCRM Contact and integrates WordPress and CiviCRM Entities with data synced via Advanced Custom Fields.
https://wordpress.org/plugins/civicrm-wp-profile-sync/
GNU General Public License v2.0
13 stars 17 forks source link

Bi-directional-Sync works but if wp-post created first, no civi-contact are created #33

Closed jbonlinea closed 2 years ago

jbonlinea commented 2 years ago

Hi there,

I'm opening this issue facing this behaviour.

It is basicallyy the exact same issue as this one #24 except that the "solution" do not work this time, and quite many updates have been done in the meantime, wp, civi, acf, etc.

Also, it appears that manualy syncing do not work. It starts, but nothing happens. It applies for the post type I'm dealing with, but I've tested a group to taxonomy sync and it was ok

I'm really puzzled and have now clues why is that so !

any help would be greatly appreciated :)

Cheers

christianwach commented 2 years ago

@jbonlinea Anything in your error logs?

jbonlinea commented 2 years ago

hi @christianwach

oh yes, a lot, not all civi-acf related tho, but some Civi specific I've left in case

[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 314
[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 311
[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_b in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 312
[13-Mar-2022 09:36:47 UTC] PHP Notice:  Undefined index: ID in /home/www/wp-content/plugins/kwagga-pods/kwwk_mediatheque.php on line 27
[13-Mar-2022 09:36:47 UTC] PHP Notice:  Undefined index: id in /home/www/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/TrashRestoreApiWrapper.php on line 26
[13-Mar-2022 09:36:47 UTC] Array
(
    [method] => CiviCRM_WP_Profile_Sync_CiviCRM_Contact::create
    [params] => Array
        (
            [version] => 3
            [debug] => 1
            [display_name] => testlog loglog
            [contact_type] => Individual
            [is_deleted] => 0
        )

    [result] => Array
        (
            [is_error] => 1
            [error_message] => One of parameters  (value: ) is not of the type Integer
        )
    [trace] => #0 /home/www/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1733): CRM_Utils_Type::validate('', 'Integer')
#1 /home/www/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1697): CRM_Core_DAO::composeQuery('select `is_dele...', Array, true)
#2 /home/www/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/TrashRestoreApiWrapper.php(12): CRM_Core_DAO::singleValueQuery('select `is_dele...', Array)
#3 /home/www/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/TrashRestoreApiWrapper.php(26): CRM_Civirules_TrashRestoreApiWrapper->isDeleted(NULL)
#4 /home/www/wp-content/plugins/civicrm/civicrm/Civi/API/Subscriber/WrapperAdapter.php(56): CRM_Civirules_TrashRestoreApiWrapper->fromApiInput(Array)
#5 /home/www/wp-content/plugins/gantry5/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\API\Subscriber\WrapperAdapter->onApiPrepare(Object(Civi\API\Event\PrepareEvent), 'civi.api.prepar...', Object(Civi\Core\CiviEventDispatcher))
#6 /home/www/wp-content/plugins/gantry5/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'civi.api.prepar...', Object(Civi\API\Event\PrepareEvent))
#7 /home/www/wp-content/plugins/civicrm/civicrm/Civi/Core/CiviEventDispatcher.php(198): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('civi.api.prepar...', Object(Civi\API\Event\PrepareEvent))
#8 /home/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(240): Civi\Core\CiviEventDispatcher->dispatch('civi.api.prepar...', Object(Civi\API\Event\PrepareEvent))
#9 /home/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(148): Civi\API\Kernel->prepare(Object(Civi\API\Provider\MagicFunctionProvider), Array)
#10 /home/www/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest(Array)
#11 /home/www/wp-content/plugins/civicrm/civicrm/api/api.php(22): Civi\API\Kernel->runSafe('Contact', 'create', Array)
#12 /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/civicrm/cwps-civicrm-contact.php(711): civicrm_api('Contact', 'create', Array)
#13 /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/classes/cwps-acf-contact.php(1167): CiviCRM_WP_Profile_Sync_CiviCRM_Contact->create(Array)
#14 /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/classes/cwps-acf-contact.php(228): CiviCRM_Profile_Sync_ACF_CiviCRM_Contact->create_from_post(Object(WP_Post))
#15 /home/www/wp-includes/class-wp-hook.php(307): CiviCRM_Profile_Sync_ACF_CiviCRM_Contact->post_saved(Array)
#16 /home/www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#17 /home/www/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#18 /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/classes/cwps-acf-mapper.php(3027): do_action('cwps/acf/mapper...', Array)
#19 /home/www/wp-includes/class-wp-hook.php(307): CiviCRM_Profile_Sync_ACF_Mapper->post_saved(5707, Object(WP_Post), true)
#20 /home/www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#21 /home/www/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#22 /home/www/wp-includes/post.php(4687): do_action('save_post', 5707, Object(WP_Post), true)
#23 /home/www/wp-includes/post.php(4789): wp_insert_post(Array, false, true)
#24 /home/www/wp-admin/includes/post.php(426): wp_update_post(Array)
#25 /home/www/wp-admin/post.php(227): edit_post()
#26 {main}

)

[13-Mar-2022 09:36:47 UTC] PHP Notice:  Trying to access array offset on value of type bool in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/classes/cwps-acf-contact.php on line 244
[13-Mar-2022 09:36:48 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 314
[13-Mar-2022 09:36:48 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 311
[13-Mar-2022 09:36:48 UTC] PHP Notice:  Undefined index: contact_type_b in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 312
christianwach commented 2 years ago

@jbonlinea I've trimmed down the logs to something a bit more manageable.

Here are a couple of things I would look at:

[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 314
[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_a in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 311
[13-Mar-2022 09:36:46 UTC] PHP Notice:  Undefined index: contact_type_b in /home/www/wp-content/plugins/civicrm-wp-profile-sync/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php on line 312

These log entries suggest that you have some Relationships that have no Contact Types (A and/or B) assigned to them. You should review your Relationship Types in CiviCRM and make sure they are valid.

#2 /home/www/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/TrashRestoreApiWrapper.php(12): CRM_Core_DAO::singleValueQuery('select `is_dele...', Array)
#3 /home/www/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/TrashRestoreApiWrapper.php(26): CRM_Civirules_TrashRestoreApiWrapper->isDeleted(NULL)

These entries in the backtrace show that CiviRules is intervening in to the "create Contact" process. You should review your rules and also try the process without CiviRules active. If the problem persists, there may be a bug in this plugin. If not, I suggest you have a misconfiguration in CiviCRM and/or CiviRules.

jbonlinea commented 2 years ago

Hi, Thank's for this, I had seen theses lines but did not know how to interpret it and act upon.

regarding civicrm relationship, all of them have an A nd B contact type (I actually only have create one relationship type that I do not use yet)

Regarding Civirules, I have only one rule that is trigged when a "Contact is added to Group". The rule works, but

So I guess Civirules has to be incriminated ?! right ? I guess I should open a ticket on CiviRule repo !

Thank's for your help ;)

christianwach commented 2 years ago

@jbonlinea So I think the contact_type_id bit was solved by #36 and I can confirm the problem with CiviRules. This is a bug in CiviRules as can be shown by the following API call without this plugin being present:

$result = civicrm_api3('Contact', 'create', [
  'contact_type' => "Individual",
  'display_name' => "Foo Bar",
  'is_deleted' => 0,
]);

I'll post this on the CIviRules issue too.

christianwach commented 2 years ago

@jbonlinea Okay, so there is definitely a bug in CiviRules, but 3604e4cd3328d8d1abc583a01f8321aedb5166ce should avoid hitting it.

jbonlinea commented 2 years ago

@jbonlinea Okay, so there is definitely a bug in CiviRules, but 3604e4c should avoid hitting it.

Excellent !

Thank's