JMAConsulting / biz.jmaconsulting.mte

Mandrill Emails Extension for CiviCRM
10 stars 21 forks source link

Cannot Install Mandrill extension on CiviCRM 4.4.4 - DB Error?? #30

Closed aaronchow closed 10 years ago

aaronchow commented 10 years ago

To Whom It May Concern, I have CiviCRM 4.4.4 / Drupal 7.26 installed. When I tried to install Mandrill Transactionals Email 1.2, it throws me a DB error message with the following information in the logfile. I also try to install it on a clean installation with the same result. There are couple more people experiencing the same thing, and one of the CiviCRM forum members say this may be due to the recent changes in CiviCRM, so the installer fails at some point (http://forum.civicrm.org/index.php/topic,31468.0.html).

Thank you for writing the extension, and we're hoping to use your extension with CiviCRM. Please let us know if you need me to provide any further information.

Sincerely,

Aaron

[info] $Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => handle )

[code] => -1
[message] => DB Error: unknown error
[mode] => 16
[debug_info] => ALTER TABLE `civicrm_mailing_event_queue` 

ADD activity_id INT UNSIGNED NULL DEFAULT NULL COMMENT 'Activity id of activity type email and bulk mail.' [nativecode=1060 * Duplicate column name 'activity_id'] [type] => DB_Error [user_info] => ALTER TABLE civicrm_mailing_event_queue ADD activity_id INT UNSIGNED NULL DEFAULT NULL COMMENT 'Activity id of activity type email and bulk mail.' [nativecode=1060 * Duplicate column name 'activity_id'] [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="ALTER TABLE civicrm_mailing_event_queue ADD activity_id INT UNSIGNED NULL DEFAULT NULL COMMENT 'Activity id of activity type email and bulk mail.' [nativecode=1060 \ Duplicate column name 'activity_id']"] )

[info] $backTrace = #0 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Error.php(197): CRM_Core_Error::backtrace("backTrace", TRUE)

1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))

2 /path_to_my_website/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))

3 /path_to_my_website/sites/all/modules/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE civicrm_mailing_event_queue \n ADD activity_id INT UNSIGNED ...")

4 /path_to_my_website/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "ALTER TABLE civicrm_mailing_event_queue \n ADD activity_id INT UNSIGNED ...")

5 /path_to_my_website/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "ALTER TABLE civicrm_mailing_event_queue \n ADD activity_id INT UNSIGNED ...", "DB_Error", TRUE)

6 /path_to_my_website/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-1, NULL, NULL, NULL, "1060 \ Duplicate column name 'activity_id'")

7 /path_to_my_website/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()

8 /path_to_my_website/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("ALTER TABLE civicrm_mailing_event_queue \n ADD activity_id INT UNSIGNED ...")

9 /path_to_my_website/sites/all/modules/civicrm/CRM/Utils/File.php(284): DB_common->query("ALTER TABLE civicrm_mailing_event_queue \n ADD activity_id INT UNSIGNED ...")

10 /path_to_my_website/civi.custom/extensions/biz.jmaconsulting.mte-1.2/CRM/Mte/Upgrader/Base.php(285): CRM_Utils_File::sourceSQLFile("mysql://database_name:######@localhost/datebase_name?new_link=true", "/*\n \ Mandrill Transactional Email extension integrates CiviCRM's non-bulk ...", NULL, TRUE)

11 /path_to_my_website/civi.custom/extensions/biz.jmaconsulting.mte-1.2/mte.civix.php(72): CRM_Mte_Upgrader_Base->onInstall()

12 /path_to_my_website/civi.custom/extensions/biz.jmaconsulting.mte-1.2/mte.php(55): _mte_civix_civicrm_install()

13 /path_to_my_website/sites/all/modules/civicrm/CRM/Extension/Manager/Module.php(64): mte_civicrm_install()

14 /path_to_my_website/sites/all/modules/civicrm/CRM/Extension/Manager/Module.php(44): CRM_Extension_Manager_Module->callHook(Object(CRM_Extension_Info), "install")

15 /path_to_my_website/sites/all/modules/civicrm/CRM/Extension/Manager.php(220): CRM_Extension_Manager_Module->onPreInstall(Object(CRM_Extension_Info))

16 /path_to_my_website/sites/all/modules/civicrm/CRM/Admin/Form/Extensions.php(188): CRM_Extension_Manager->install((Array:1))

17 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Form.php(261): CRM_Admin_Form_Extensions->postProcess()

18 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()

19 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next")

20 /path_to_my_website/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next")

21 /path_to_my_website/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next")

22 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Controller.php(345): HTML_QuickForm_Page->handle("next")

23 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(381): CRM_Core_Controller->run()

24 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(178): CRM_Core_Page_Basic->edit(1, NULL)

25 /path_to_my_website/sites/all/modules/civicrm/CRM/Admin/Page/Extensions.php(127): CRM_Core_Page_Basic->run()

26 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Invoke.php(323): CRM_Admin_Page_Extensions->run((Array:3), NULL)

27 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Invoke.php(72): CRM_Core_Invoke::runItem((Array:13))

28 /path_to_my_website/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))

29 /path_to_my_website/sites/all/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3))

30 [internal function](): civicrm_invoke("admin", "extensions")

31 /path_to_my_website/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:2))

32 /path_to_my_website/index.php(21): menu_execute_active_handler()

33 {main}

Edzelopez commented 10 years ago

Hi,

There have been some schema changes for CiviCRM 4.4.4. We are working on releasing a v4.4.4 compatible version of the extension. Currently, there is a workaround. you could delete L37 from mte_install.sql Also, to keep up with the schema changes, you would need to change L69 of mte.php to read $saveJob = new CRM_Mailing_DAO_MailingJob(); instead of $saveJob = new CRM_Mailing_DAO_Job();

Hth, Edsel

emilyf commented 10 years ago

Will this affect CiviCRM 4.4.3? Looks like the 1.2 stable release is compatible through 4.4...should the extension listing be changed to reflect what minor version it works with?

JoeMurray commented 10 years ago

Hi Emily,

Yes, we'll be changing the documentation for 1.2 to indicate it is compatible to 4.4.3, and releasing a new one shortly for 4.4.4+. Hoping you could help test the install for that and update the instructions.

Thanks again for your offer!

bdombro commented 10 years ago

Hey all,

I was having the same errors, and then I applied your fix. Now I get this error:

Database Error Code: Can't create table 'drupal_dev.#sql-377_75c0' (errno: 121), 1005
Additional Details:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -15
    [message] => DB Error: can not create
    [mode] => 16
    [debug_info] => ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75c0' (errno: 121)]
    [type] => DB_Error
    [user_info] => ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75c0' (errno: 121)]
    [to_string] => [db_error: message="DB Error: can not create" code=-15 mode=callback callback=CRM_Core_Error::handle prefix="" info="ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75c0' (errno: 121)]"]
)

When I delete the next line, the install still has errors. This is the line I'm talking about:

ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`);

I get this error:

Database Error Code: Can't create table 'drupal_dev.#sql-377_75d6' (errno: 121), 1005
Additional Details:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -15
    [message] => DB Error: can not create
    [mode] => 16
    [debug_info] => ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75d6' (errno: 121)]
    [type] => DB_Error
    [user_info] => ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75d6' (errno: 121)]
    [to_string] => [db_error: message="DB Error: can not create" code=-15 mode=callback callback=CRM_Core_Error::handle prefix="" info="ALTER TABLE `civicrm_mailing_event_queue`
  ADD CONSTRAINT `FK_civicrm_mailing_event_queue_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) [nativecode=1005 ** Can't create table 'drupal_dev.#sql-377_75d6' (errno: 121)]"]
)
bdombro commented 10 years ago

I ended up rolling back to 4.4.3, then making the fix you recommended below:

Also, to keep up with the schema changes, you would need to change L69 of mte.php to read $saveJob = new CRM_Mailing_DAO_MailingJob(); instead of $saveJob = new CRM_Mailing_DAO_Job();

JoeMurray commented 10 years ago

EmilyF: We are expecting to put a version for <4.4.3 and another for 4.4.4+ in the next couple of days. bdombro: We are unable to reproduce your [nativecode=1005 \ Can't create table 'drupal_dev.#sql-377_75d6' (errno: 121)] MySQL error. Is it possible that the mysql user for CiviCRM does not have the MySQL permissions for creating tables? Could you check and respond? Thx.

JoeMurray commented 10 years ago

EmilyF: Could you try installing now for repo? If you would like a Zip file to download containing the repo you can get it from one of these pages, or you can post here and Pradeep or I will post it for download.

We'd appreciate it if others also tested and helped with documentation of new version including new place for specifying MTE params for mail.

pradpnayak commented 10 years ago

Here is the link of zip file https://github.com/JMAConsulting/biz.jmaconsulting.mte/archive/master.zip

emilyf commented 10 years ago

Hi Joe: I will definitely test this out; I had been hoping for last week as this week I am traveling. But I hope to get to it early next week. Will post back, thanks.

emilyf commented 10 years ago

Just a quick update - my travel plans confounded my schedule a little more than anticipated. Getting this in the schedule as soon as possible. Will be testing it out on 2 separate projects during the month of April, getting one project upgraded to Civi 4.4. this week so can hopefully start testing and documenting next week.

JoeMurray commented 10 years ago

Thanks for the update emilyf.

laryn commented 10 years ago

I've tried installation on a 4.4.4 site and keep getting database errors after clicking the install button. I've tried downloading first through the extensions directory and then manually using the master.zip file linked above.

This seems to be the problem:

#6 /path/to/drupal/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-1, NULL, NULL, NULL, "1060 ** Duplicate column name 'activity_id'")

But in case I missed something, here's the whole backtrace:

Apr 08 11:56:17  [info] $backTrace = #0 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Error.php(197): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#2 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE `civicrm_mailing_event_queue` \n  ADD `activity_id` INT UNSIGNED ...")
#4 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "ALTER TABLE `civicrm_mailing_event_queue` \n  ADD `activity_id` INT UNSIGNED ...")
#5 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "ALTER TABLE `civicrm_mailing_event_queue` \n  ADD `activity_id` INT UNSIGNED ...", "DB_Error", TRUE)
#6 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-1, NULL, NULL, NULL, "1060 ** Duplicate column name 'activity_id'")
#7 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
#8 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("ALTER TABLE `civicrm_mailing_event_queue` \n  ADD `activity_id` INT UNSIGNED ...")
#9 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Utils/File.php(284): DB_common->query("ALTER TABLE `civicrm_mailing_event_queue` \n  ADD `activity_id` INT UNSIGNED ...")
#10 /path/to/drupal/public_html/sites/all/civicrm_extensions/biz.jmaconsulting.mte/CRM/Mte/Upgrader/Base.php(285): CRM_Utils_File::sourceSQLFile("mysql://db-credentials-here?new_link=true", "/**\n * Mandrill Transactional Email extension integrates CiviCRM's non-bulk ...", NULL, TRUE)
#11 /path/to/drupal/public_html/sites/all/civicrm_extensions/biz.jmaconsulting.mte/mte.civix.php(72): CRM_Mte_Upgrader_Base->onInstall()
#12 /path/to/drupal/public_html/sites/all/civicrm_extensions/biz.jmaconsulting.mte/mte.php(55): _mte_civix_civicrm_install()
#13 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Extension/Manager/Module.php(64): mte_civicrm_install()
#14 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Extension/Manager/Module.php(44): CRM_Extension_Manager_Module->callHook(Object(CRM_Extension_Info), "install")
#15 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Extension/Manager.php(220): CRM_Extension_Manager_Module->onPreInstall(Object(CRM_Extension_Info))
#16 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Admin/Form/Extensions.php(188): CRM_Extension_Manager->install((Array:1))
#17 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Form.php(261): CRM_Admin_Form_Extensions->postProcess()
#18 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()
#19 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next")
#20 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next")
#21 /path/to/drupal/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next")
#22 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Controller.php(345): HTML_QuickForm_Page->handle("next")
#23 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(381): CRM_Core_Controller->run()
#24 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Page/Basic.php(178): CRM_Core_Page_Basic->edit(1, NULL)
#25 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Admin/Page/Extensions.php(127): CRM_Core_Page_Basic->run()
#26 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(323): CRM_Admin_Page_Extensions->run((Array:3), NULL)
#27 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(72): CRM_Core_Invoke::runItem((Array:13))
#28 /path/to/drupal/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#29 /path/to/drupal/public_html/sites/all/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3))
#30 [internal function](): civicrm_invoke("admin", "extensions")
#31 /path/to/drupal/public_html/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:2))
#32 /path/to/drupal/public_html/index.php(21): menu_execute_active_handler()
#33 {main}
varununi7 commented 10 years ago

Hi Joe,

We enabled the Mandrill extension along with CiviSMTP (for bulk email processing). All our emails (bulk, transactional) etc. have been logged as activities for contacts.

The problem is that the civicrm_mailing_event_queue, civicrm_mailing_event_opened, civicrm_mailing_event_bounce etc. all these objects are showing no values. So we are not able to have any tracking on any transactional emails.

Any pointers to what must be debugged or what should be done please?

JoeMurray commented 10 years ago

Can you create a new issue for this, varununi7? Also, can you check that the webhook is configured correctly? Thanks.

JoeMurray commented 10 years ago

Laryn, we changed the problematic file. We are holding off a release only so that we can test against the 4.5 version as soon as it comes out. But 4.4.x should be working fine right now from the repo's master branch.

laryn commented 10 years ago

Thanks Joe, the install works now.

Only problem now is I can't find the config page in the System menu (even after clearing caches via menu, and manually deleting templates_c). Is it possible that isn't being added for some reason?

pradpnayak commented 10 years ago

To setup Setup Outbound Email for Mandrill Navigate to Administer >> System Settings >> Mandrill Smtp Settings. Enter the following: SMTP Server: smtp.mandrillapp.com SMTP Port: 587 Authentication: Yes SMTP Username: (from first step above, e.g. mail@yourorg.org) SMTP Password: (copy and paste API Key from first step above, e.g. 12345678-abcd-1234-efgh-123456789012) Click Save & Send Test Email Note the value of the field Mandrill Post URL, for example by copying and pasting it into a file for use later in this setup. Check that you received the test email.

To check and change the Mandrill Secrete Navigate to

Go to Administer > System Settings > Option Groups. Beside Mandrill Secret, click on Options. Click edit beside Secret Code. Change the value, then click Save. Navigate to Administer >> System Settings >> Mandrill Smtp Settings, click on SMTP, copy the value of Mandrill Post URL. Note that this step is necessary since it also activates the use of this callback URL. Use that new value to configure the Post to URL value of the webhook for Mandrill.

More info on https://github.com/JMAConsulting/biz.jmaconsulting.mte/blob/1.3/README.md

laryn commented 10 years ago

Thanks, @pradpnayak -- the problem is that there is no menu item at: Administer >> System Settings >> Mandrill Smtp Settings

It hasn't shown up in the menus. The option group does show up, however.

laryn commented 10 years ago

Followup: I installed fresh on a different domain and the menus are correct. Still trying to figure out why the other install won't refresh the menus... (I have rebuilt them using /index.php?q=civicrm/menu/rebuild&reset=1)

laryn commented 10 years ago

Followup to the followup: The other install didn't get the menu item inserted correctly because it is a multisite and the install hardcodes domain_id=1 in the sql that adds the item to the navigation. I updated that in the db directly to be the correct domain_id and now have the item in the menu.