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)
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 753968-upgrade-6.x.patch | 1.98 KB | quotesbro |
| #29 | 753968-upgrade-6.x-28.patch | 1.96 KB | bucefal91 |
| #21 | synonyms_port_d7_1.patch | 3.92 KB | litwol |
| #19 | synonyms_port_d7_0.patch | 3.92 KB | litwol |
| #17 | patch_commit_2ebd2514def2.patch | 3.48 KB | bachbach |
Comments
Comment #1
bojanz commentedCommited. Thanks!
Comment #3
tanoshimi commentedFor 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.
Comment #4
tanoshimi commentedComment #5
bojanz commentedCommited.
Comment #6
dman commentedGreat, 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.
Comment #8
mxtThe 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.
Comment #9
bojanz commentedAll 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..)
Comment #10
protools commentedautocomplit 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 ...
Comment #11
litwol commentedI'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...
Comment #12
bojanz commentedI 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.
Comment #13
litwol commentedI'm doing some work on related functionality now. i could use commit/maintainer access.
Comment #14
bojanz commentedI gave you access.
Comment #15
se7en76 commentedSubscribed
Comment #16
bachbach commentedhi, thanks a lot for this work !
any news with #11 ?
Comment #17
bachbach commentedabout #11
here is a patch against 7.x-1.x-dev with the use of fieldapi instead of direct mysql query
Comment #18
bojanz commentedPlease respect coding standards, the indentation is wrong and full of tabs.
Comment #19
litwol commentedWorks 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.
Comment #20
litwol commentedJust realized i shouldn't set new patch as RTBC. pardon.
Comment #21
litwol commentedNew patch with minor coding standards fix. added spaces in the conditional block ("if(" -> "if (")
Comment #22
crantok commentedOnly just found this module. Tried patch from #21.
Edited term "hostname" in vocabulary "tags". Added synonym "host-name". Navigated to
and saw, at the top
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.
Comment #23
litwol commented@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.
Comment #24
crantok commentedThat 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.
Comment #25
bucefal91 commentedMy 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.
Comment #27
quotesbro commentedIt 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.
Comment #28
bucefal91 commentedUfffff... 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?
Comment #29
bucefal91 commentedHere's the patch. It didn't want to accept it from the 1st time for some reason...
Comment #30
quotesbro commentedThank 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.
Comment #31
bucefal91 commentedOh, 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?
Comment #32
quotesbro commentedSure, I'd like someone else to test this patch before you commit it.
Comment #33
bucefal91 commentedDrupal 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".