Attached patch converts functionality of the existing D6 Synonyms HEAD to D7.

Note that, as a result of changes in D7 (i.e. taxonomy terms are now fields (and are themselves fieldable), and synonyms are no longer defined within core) this patch basically constitutes a complete rewrite of the module, but it should fulfil the same purpose as before.

The approach taken is as follows:
- On installation, a new synonym field is created and attached to every vocabulary.
- An instance of the field is also added to every new vocabulary on creation (handled by hook_taxonomy_vocabulary_insert).
- Two new functions recreate the synonym functionality previously provided by core taxonomy module - synonyms_get_synonyms() and synonyms_get_synonym_root().
- hook_node_update_index recreates the functionality previously provided by hook_nodeapi ($op = 'update index'), looping through each synonym of every term attached to a node when it is indexed, and adding them to the search index.
- I've also included an update hook for anybody upgrading from D6 with existing synonyms in the taxonomy_term_synonym table. Note that to test importing existing synonyms you must be using a build of Drupal-7 after 25/03/2010, or else you'll lose the existing taxonomy hierarchy (see http://drupal.org/node/749304 for details)

Comments

bojanz’s picture

Status: Needs review » Fixed

Commited. Thanks!

Status: Fixed » Closed (fixed)

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

tanoshimi’s picture

StatusFileSize
new2.97 KB

For some reason, the D7 branch in CVS doesn't seem to have the synonyms.install file created in the above patch.
Attached patch should fix this, and also makes a small change to keep in line with D7 HEAD changes from object_type to entity_type for field instances.

tanoshimi’s picture

Status: Closed (fixed) » Active
bojanz’s picture

Status: Active » Fixed

Commited.

dman’s picture

Great, I was hoping this would happen.
I've tried temporarily making my own synonyms field for a D7 upgrade of taxonomy_xml, and learnt a lot about the fields system from doing so, but I was hoping that I could bring my version into line with this module or similar as a suggested dependency!
Now I can scrap (or at least reduce) the part of my code that was doing this.

Status: Fixed » Closed (fixed)

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

mxt’s picture

Status: Closed (fixed) » Active

The D7 version of this module is still in DEV: do you have any plans to release a first official D7 version ?

Thank you very much.

bojanz’s picture

All the code since the 5.x days was actually done by tanoshimi, I have no idea how good the code is now.
If you give me feedback regarding completeness, I can tag something (alpha, beta, final..)

protools’s picture

autocomplit and synonyms - how to ?
i have term1 and synonym-term1 -

if user don't now how write term1, but now how write synonym-term1 ...

in autocomplit if we write synonym-term1 - nothing display ...

litwol’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Status: Active » Needs work

I've done a quick code review of D7 branch. Consensus: Code is bad.

Reason why its bad: There are direct queries against fieldAPI created database tables. This will break when site runs on databases other than mysql (mongodb is very popular).

Proper solution: Instead of performing direct queries against mysql table, developer should be using drupal API to query entity data. See this API http://api.drupal.org/api/drupal/includes--entity.inc/class/EntityFieldQ...

bojanz’s picture

I am happy to give anyone commit access in order to have it done properly.

EntityFieldQuery didn't even exist when tanoshimi contributed the code, a lot has changed in D7 since then.

litwol’s picture

I'm doing some work on related functionality now. i could use commit/maintainer access.

bojanz’s picture

I gave you access.

se7en76’s picture

Subscribed

bachbach’s picture

hi, thanks a lot for this work !

any news with #11 ?

bachbach’s picture

Status: Needs work » Needs review
StatusFileSize
new3.48 KB

about #11
here is a patch against 7.x-1.x-dev with the use of fieldapi instead of direct mysql query

bojanz’s picture

Status: Needs review » Needs work

Please respect coding standards, the indentation is wrong and full of tabs.

litwol’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.92 KB

Works well :)

Here's what i've tested:
1. Tested both sql and mongodb field storage. This module worked in both cases (this unblocks my previous review at #11)
2. (unrelated to the patch, but worth a note) taxonomy/term/% under mongodb field storage does not work because taxonomy.module uses direct db queries :( :( sad sad @taxonomy.module

Attached new patch that combined #17 and cleans spaces and alignment.

litwol’s picture

Status: Needs work » Needs review

Just realized i shouldn't set new patch as RTBC. pardon.

litwol’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.92 KB

New patch with minor coding standards fix. added spaces in the conditional block ("if(" -> "if (")

crantok’s picture

Only just found this module. Tried patch from #21.

Edited term "hostname" in vocabulary "tags". Added synonym "host-name". Navigated to

/tags/host-name

and saw, at the top

Synonyms: 
hostname

followed by content tagged with "host-name", but no content tagged with "hostname".

If this is all the functionality that requires testing then #21 works for me.

litwol’s picture

@crantok: that is out of scope of this module for the time being. Right now this module advertises to work only on /search/ result pages. not on taxonomy related pages.

crantok’s picture

That sounds even better. Just tested that too. Searching for either of the synonyms "hostname" or "host-name" returns all nodes tagged with either term. I made sure my test content did not have the text of either term in body and title of the nodes. So, again, #21 is working for me.

Edit: Reread thread and saw that DB is salient information. I'm on MySQL.

bucefal91’s picture

Status: Needs review » Fixed

My greetings gentlemen, I have just created a solid 7.x branch and made a release, I found this module while working on my own D7 project and found that this is the functionality I need, however at that time the module didn't have any 7.x release. So I developed my own. Everybody is welcome to check it out and play around with it. I will try to support at least 7.x branch as much as I can.

Status: Fixed » Closed (fixed)

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

quotesbro’s picture

Assigned: tanoshimi » Unassigned
Priority: Normal » Major
Status: Closed (fixed) » Active

It looks like function synonyms_convert_taxonomy_term_synonym_table_to_fields() from the initial patch (https://drupal.org/files/issues/synonyms_D7.patch) was removed, and now there is no way to upgrade D6 sysnonyms to D7.

I tried to simply copy this function to the current 7.x-dev and comment out line // db_drop_table('taxonomy_term_synonym');
and then call synonyms_convert_taxonomy_term_synonym_table_to_fields(), but D6 synonyms doesn't appear in the 7.x module table. I guess some logic was changed so this function need to be rewritten and to be commited back in 7.x-1.x-dev.

bucefal91’s picture

Status: Active » Needs work

Ufffff... I honestly dedicated 2-3 hours trying to write an upgrade path from 6.x core to Synonyms 7.x - I haven't had luck :( I am gonna put it aside and I'll be working on other drupal modules I am maintaining. Sorry, but it's not a priority for me.

I am attaching a patch of what I had before I gave up on it. It could be working, I never was able to actually test it on real 6.x installation and its upgrading. Maybe it will work for you?

bucefal91’s picture

Status: Needs work » Needs review
StatusFileSize
new1.96 KB

Here's the patch. It didn't want to accept it from the 1st time for some reason...

quotesbro’s picture

StatusFileSize
new1.98 KB

Thank you, Alexander!
I corrected db_select() a little bit so synonyms_import_synonyms() looks to be working now. My 'field_data_synonyms_synonyms' table now contains synonyms imported from 6.x table, and I can see it on the term edit pages.

bucefal91’s picture

Oh, great! I am going to leave this patch out here for some time, I'd like to hear that it works for at least one more person than you. But if there is no feedback in long time, I'll commit it anyway. Sounds good?

quotesbro’s picture

Sure, I'd like someone else to test this patch before you commit it.

bucefal91’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Drupal 6 is no longer supported. Given nobody else spoke about migration path from D6 to D7 synonyms, I think it is safe to close this issue as "won't fix".