Comments

hongpong’s picture

Project: Features » Strongarm
Version: 6.x-1.x-dev » 6.x-2.0

I think this more properly belongs with Strongarm than Features.

Grayside’s picture

Project: Strongarm » Features
Version: 6.x-2.0 » 7.x-1.x-dev

The Contact form settings are already exported by Strongarm, except for the Category settings which *cannot* be exported by Strongarm. Instead, the Contact module must have db-level features integration. This will need to go in the Features module, in a separate integration module, or be included in the http://drupal.org/project/contact module, though that module is intended for backport code only.

febbraro’s picture

Title: Export Contact module form settings as strongarm Feature entry » Integrate Contact module Categories with Features
Status: Active » Postponed (maintainer needs more info)

If someone wants to work up a patch for integrating Contact into the main Features module, I'll consider it. I have never used Contact though, so I will probably never get around to writing it.

mpotter’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Closing this for lack of activity. Please re-open this issue if you can reproduce it in the latest version.

boombatower’s picture

It's a feature request not a bug so should be reproducible since it doesn't exist, but since no one is implementing it can close.

webastien’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new806 bytes

Attached to this post, a code I've written today for exporting contact categories.
Would be probably better but it works for me.

It would be nice if features' maintainers include it into a next release, after community review.

fureigh’s picture

Here's a patch that incorporates the above (thanks, webastien, your code was extremely helpful to me today!) and adds another necessary change in features.module.

hefox’s picture

Status: Needs review » Needs work
+++ b/includes/features.contact.inc
@@ -0,0 +1,75 @@
+<?php
+/**

File block needed

+++ b/includes/features.contact.inc
@@ -0,0 +1,75 @@
+    $options["category_{$category->cid}"] = "category_{$category->cid}";

cid is a numeric key? :/

Assuming cid is a numeric automatically inc column, this won't work out as a site could have a contact category unrelated to that current cid.

fureigh’s picture

Thanks, hefox.

Also, after further testing it appears that currently, only the first category gets imported.

mohit_aghera’s picture

Fixed the few issues, working now. I can export both the categories now.

mohit_aghera’s picture

Few changes in the category display. Added category display name instead of category id

kristiaanvandeneynde’s picture

Edit: whoops, posted in wrong issue somehow.

ohthehugemanatee’s picture

Noting that the patch in #11 worked well for me.

jstoller’s picture

Priority: Minor » Normal
Status: Needs work » Needs review

Setting to Needs Review, to trigger testbot.

hefox’s picture

Reuploaded patch to see if testbot responds o.O

hefox’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Needs to be against 2.x

hefox’s picture

nevergone’s picture

Status: Needs review » Reviewed & tested by the community

I'm tested #17 and Features 7.x-2.0 and works well! Thanks!

hefox’s picture

Status: Reviewed & tested by the community » Needs work

cid is still being used -- that won't work for sites with existing but different categories, no?

mohit_aghera’s picture

@hefox: thanks for pointing out the issue.
Now checking the last insert id and then inserting exported contact category. So there won't be any issue of duplication categoryid.
Let's test it again :)

mohit_aghera’s picture

Status: Needs work » Needs review
jstoller’s picture

Status: Needs review » Needs work

I just upgraded my site and applied the patch from #20. When doing a forced revert of a feature module containing contacts, I get the following error:

WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Website feedback' for key 'category': INSERT INTO       [error]
{contact} (cid, category, recipients, reply, weight, selected) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2,
:db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array
(
    [:db_insert_placeholder_0] => 6
    [:db_insert_placeholder_1] => Website feedback
    [:db_insert_placeholder_2] => person1@example.com,person2@example.com
    [:db_insert_placeholder_3] => 
    [:db_insert_placeholder_4] => 10
    [:db_insert_placeholder_5] => 0
)
 in contact_categories_features_rebuild() (line 74 of
/path/to/webroot/sites/all/modules/contrib/features/includes/features.contact.inc).
Cannot modify header information - headers already sent by (output started at /Users/jstoller/.composer/vendor/drush/drush/includes/output.inc:38)   [warning]
bootstrap.inc:1233
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry &#039;Website feedback&#039; for key &#039;category&#039;: INSERT INTO {contact} (cid, category, recipients, reply, weight, selected) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array
(
    [:db_insert_placeholder_0] => 6
    [:db_insert_placeholder_1] => Website feedback
    [:db_insert_placeholder_2] => person1@example.com,person2@example.com
    [:db_insert_placeholder_3] => 
    [:db_insert_placeholder_4] => 10
    [:db_insert_placeholder_5] => 0
)
 in contact_categories_features_rebuild() (line 74 of /path/to/webroot/sites/all/modules/contrib/features/includes/features.contact.inc).
Drush command terminated abnormally due to an unrecoverable error. 

It seems like features is trying to add all the contact categories as new categories, even though they're already in the database, so it's getting an error because "Website feedback" already exists.

jstoller’s picture

It seems like you first need to check for an existing category with the same name as the one being reverted. If it exists, then update that cid and, if not, then add a new cid.

subhojit777’s picture

Patch in #20 is working in normal installation (I mean normal Drupal site without upgrade).

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new4.14 KB

Updated patch and removing cid in export to avoid un-necessary issues.

edutrul’s picture

Sorry the patch #25 is not working for me

mohit_aghera’s picture

@edutrul
Can you please tell me which features module version you are using.
I tested with 7.x-2.x-dev branch and Drupal 7.34, seems working fine for me.
Update - working fine with 7.x-2.2 and Drupal 7.34 as well.

hefox’s picture

Status: Needs review » Needs work

Some coding style/spacing issues.

db_* should likely be a bit more spaces, like the db_merges are all on one line and there's a db_select in a foreach -- hard to read

one db_select is before if () { } in _revert, but it insdie if cause useless db_select if that if is false

mohit_aghera’s picture

Assigned: Unassigned » mohit_aghera
Status: Needs work » Needs review
StatusFileSize
new4.24 KB

Code re-factoring as suggested in feedback.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Committed to f56b50e.

  • mpotter committed f56b50e on 7.x-2.x authored by mohit_aghera
    Issue #1198102 by mohit_aghera, hefox, fureigh: Integrate Contact module...
hefox’s picture

Status: Fixed » Needs work

Commit was missing the inclusion of the new file :(

Anyhow, spotted at least one basic code style issues with the patch, (an if(, aka missing space), should be run through coder to catch any more.

pachabhaiya’s picture

#33 +1

claudiu.cristea’s picture

New patch fixing code standards issues and reading the missed file. RTBC per #30.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 35: integrate_contact-1198102-35.patch, failed testing.

The last submitted patch, 35: integrate_contact-1198102-35.patch, failed testing.

claudiu.cristea’s picture

Assigned: mohit_aghera » Unassigned
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new3.6 KB
new3.53 KB

Oops! Wrong patch.

claudiu.cristea’s picture

StatusFileSize
new316 bytes
new3.53 KB

nitpick.

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Sorry this took so long. A simple case of forgetting to "git add" the new file. Fixed in 01b103d.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

forestmars’s picture

Thanks @mpotter, this was really useful.