Port Related Links module to drupal 6.x
reikiman - February 16, 2008 - 19:47
| Project: | Related links |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | Drupal, error, relatedlink |
Description
I ran the coder (code review) module and it led me through some changes. There are a few remaining issues;
Line 1126: new hook_theme() function is required to register theme_ functions (Drupal Docs)
function theme_relatedlinks_types_table($form) {
severity: criticalLine 63: The menu system has been completely over-hauled in 6.x. (Drupal Docs)
if ($may_cache) {
severity: criticalLine 64: The menu system has been completely over-hauled in 6.x. (Drupal Docs)
$items[] = array(
severity: criticalLine 72: The menu system has been completely over-hauled in 6.x. (Drupal Docs)
$items[] = array(
severity: criticalLine 80: The menu system has been completely over-hauled in 6.x. (Drupal Docs)
$items[] = array(
relatedlinks.install
severity: criticalclick to read moreLine 10: A new schema API has been added in 6.x (Drupal Docs)
switch ($GLOBALS['db_type']) {
Explanation: This patch caused changes to the format of hook_install(), hook_uninstall(), and hook_update_N(). No longer are switch statements done on $GLOBALS['db_type']; instead, use the variety of schema API functions to perform table manipulation.
severity: criticalclick to read moreLine 102: A new schema API has been added in 6.x (Drupal Docs)
switch ($GLOBALS['db_type']) {
Explanation: This patch caused changes to the format of hook_install(), hook_uninstall(), and hook_update_N(). No longer are switch statements done on $GLOBALS['db_type']; instead, use the variety of schema API functions to perform table manipulation.
severity: criticalclick to read moreLine 140: A new schema API has been added in 6.x (Drupal Docs)
switch ($GLOBALS['db_type']) {| Attachment | Size |
|---|---|
| relatedlinks.diff | 6.11 KB |

#1
If you have the time, please update your patch against 5.x.2.x-dev. Much appreciated - thanks!
#2
Patch via latest 5.x.2.x-dev, code clean up with coder.
Able to install required tables, access/update setting pages.
Still need works and input.
#3
Hi,
I've applied the patch and checked it, but got some problems which I was able to fix:
1. The path to the relatedlinks.js file was wrong and so file_get_contents() threw an error. The path used was "/modules/..." (note the leading slash, which makes this path an absolute one (at least on a *nix system)). I've added a "." in front of it, thus making it a relative one. I don't know which impact this change has, so someone will review this, I could only say, that this works for me.
2. The theme_relatedlinks() method was not registered, I've fixed this.
I'll append a patch file against the patched source tree. Maybe this is usefull to you, or to other people.
Edit: I have issues using the add manual links thingy while editing a node (everytime I edit a node, the links get changed (even if I don't edit them)) and broken.
Stephan
#4
Are you missing some files in your patch, mehlvogel?
Thanks,
-K
#5
Hi,
hmm I don't think there are missing files. But as I've solved my problem from above and added some functionality I needed, I'll just try to append a new patch file. Tell me whether you have problems with it as I'm not very experienced in using the diff program, so hopefully the patch file is useable.
I've appended a patch against 5.x.2.x-dev. It should completely contain the patches posted above and the following additions:
- Corrected the RegEx used to parse the text area in the relatedlinks.js, as the old one has divided a URL by chars like '://' in my Firefox 3 and thus breaking the links when editing a node (as I'm not very experienced in using Javascript, this may cause problems on other browsers).
- Added support for multilingual environments, by only showing discovered nodes of the same language (this behaviour may be disabled in the admin section).
- Fixed the path in relatedlinks_form_alter() as described above.
- Fixed the call to _relatedlinks_taxonomy_select_nodes() in _relatedlinks_get_discovered_links(). The parameter count wasn't correct.
- Fixed the theme hook as described above.
I hope, my changes are useful for you.
Stephan
#6
Stephan,
While I do appreciate the changes, it would be best if this issue deals _only_ with the D6 port - no bug fixes and no new features please. Those will need to be spun off into separate issues with separate patches and at the present moment, for D5 unless they are D6 related features.
Thanks again. I'm going to be AWOL for a bit, but I'll check back later.
-K
#7
Hi,
allright :), if I'm doing some more changes to that plugin, I'll keep that in mind. So I think, the part related to D6 is completely in my first patch file, if I've forgotten something you need, tell me.
Stephan
#8
Is there any news on a timeline for this project? The last post was two weeks ago.
Can anyone suggest any alternate modules/techniques that can achieve a similar functionality in D6?
#9
I applied patch from #2 and only hunk #3 failed. I assume from Zen's and Stephan's comments in #6 and #7 that #2 is the patch to work from.
#10
Oh, and the port should happen against DRUPAL-5--2? Or will recent changes make it over to the HEAD branch? Thanks.
#11
Yes, please - against 5--2-dev. But more importantly, the patch should be bereft of any new features or bug fixes which should be handled via separate issues.
Cheers!
#12
Patch from hswong3i in #2 rerolled. Applies against DRUPAL-5--2. Module installs and configuration works. I haven't tested anything else yet though.
#13
I applied this last patch and found 2 issues:
1. Autocomplete fields (title, url) in node edit form don't work. I've tried to fix this but didn't get it.
2. There is one theme_ function (relatedlinks) missing in hook_theme.
#14
Would someone be so nice and integrate the patches in an initial D6 release?
Thanks for your support!!!
#15
Rerolled to take care of the missing theme function. Verified autocomplete field not working on node add/edit form. I looked at what might be wrong but haven't discovered it yet. I looked at what nodereference module for CCK 6 does to autocomplete and with just a quick visual compare they look quite a bit different though perhaps something can be learned from noderef's style.
#16
Attachment didn't make it ... here we go again ...
#17
The problem with autocomplete is that you have to call Drupal.attachBehaviors() function after adding content to the page from javascript code.
From drupal.js
Developers implementing AHAH/AJAX in their* solutions should also call this function after new page content has been
* loaded, feeding in an element to be processed, in order to attach all
* behaviors to the new content.
Just add Drupal.attachBehaviors() after you add the textfield and it works.
#18
subscribe
#19
@pl2, I'm not sure where you are saying to add Drupal.attachBehaviors(), can you roll a patch or post the code? thanks
#20
@coltrane, this fixes the autocomplete issue. You may call attachBehaviors or just call the behaviour function that you need for your elements to work, as in this case.
#21
subs
#22
Love this module. Will help test a 6.x-dev branch. Subscribing.
#23
subscribe
#24
subscribe
#25
I am running Drupal Core 6.3. I've downloaded relatedlinks-5.x-2.x-dev.tar.gz, untarred it and applied patches relatedlinks-6.x-222609-15.patch & relatedlinks-js-6.x.patch. When I go to Administer > Modules I see 'Related Links 5.x-2.x-dev Displays links related to content. This version is incompatible with the 6.3 version of Drupal core.' Have I missed something or can't this be used with 6.3?
Er, scrub that - it was TinyMCE causing the problem with Related Links all along, works fine if TinyMCE disabled.
#26
Any update on when we might see an official alpha or beta port for 6?
#27
subscribe
#28
+1
#29
sub
#30
subscribe
#31
Any news of a new release of Relatedlinks for drupal6??
I am trying to put relatedlinks in drupal 6.4, I am very new on drupal and not very much experience.
I followed all instruction to patche the modul and still tell me is incompatible . Could somebody help me with a relatedlink modul ready patched .Thanks very much.
Lumi
Somebody help and the module workk now in Drupal 6 but only in admin.For all other users or anonymos does not show the links.Any thoughts????
#32
I'm waiting for this module upgrade , too
#33
subscribing.
#34
Subscribe
#35
Subscribe
#36
subscribing
#37
subs
#38
Hi folks, Just a quick update - I've rolled the patches together and deployed this on my 6.8 installation. So far, I've not been able to find any problems specific to RelatedLinks - the only problem I have found is a JS problem with Google Chrome (Add/Update functionality is broken).
I'll keep playing and raise any issues I find. Thanks for the hard work.
#39
When are we likely to see a 6.x-dev release?
#40
When are we likely to see a 6.x-dev release?
#41
subscribe
#42
Those that want 6.x, try the Similiar mod
#43
@spiffyd: the similar module doesn't really seem to do the same as this.
Anyway, I too have applied all the patches and it seems to be working ok for me so far.
#44
subscribe
#45
subscribe
#46
here's a patch, to 5.x.2.x-dev, and a full tar ball following the path laid out in #25. It works on a drupal 6.9 install.
I added the core=6.x to the info file and a bogus version just to make it easy to see on the modules page.
#47
Noticed one bug. I don't know if this is specific tho the Drupal 6 version or not, but since there is no D6 -dev release, this is probably the most appropriate this...
If I add an invalid link (a link to a node that doesn't exist), then the link does not save. It all seems to be fine, and I get no warning that the link is invalid and therefore it will not be added, but when I do finally click save, the link is not actually saved.
#48
The schema of term_node has changed to include a vid column. Thats means we have multiple nid => term records which ruins the taxonomy calculation AFAICT. Nodes with many versions (i.e. have ben edited a few times) are considered more related which is clearly wrong. The latest patch does not address this. I only took a quick look so I could be wrong here.
#49
I solved this in another module with COUNT(DISTINCT(tn.tid))
#50
Get this error with v6 installed when applying taxonomies to uploads:
# user warning: Duplicate entry '255' for key 1 query: INSERT INTO relatedlinks_tracker (nid, keywords) VALUES (422, '') in ../modules/relatedlinks/relatedlinks.module on line 848.
# user warning: Duplicate entry '255' for key 1 query: INSERT INTO relatedlinks_tracker (nid, keywords) VALUES (423, '') in ../modules/relatedlinks/relatedlinks.module on line 848.
#51
I see the same errors.
It was caused by the function _relatedlinks_update_discovered_links(), in which it always do _relatedlinks_add_links() and _relatedlinks_insert_tracker() , even if the link already has been added to the node.
The function _relatedlinks_update_discovered_links() was called from the relatedlinks_block(), and it is always called even though I have block caching on.
Could some one please provide a fix to this? I don't have the time these days. Thanks!
#52
subscribe, any updates on this
#53
updateing title to make it easily identifiable in my issue queue.
#54
The issues is the structure of the relatedlinks_tracker table the nid field is set to be a tinyint which has a maximum of 255, the same is true of the lid field in the relatedlinks table. So trying to insert a value of 422 into the nid field mysql converts the to 255 (as that is the maximum value) which it did previously for an earlier post and consequently you get a duplicate key error.
the solution is to change the type of the nid and lid field in relataedlinks_tracker and relatedlinks tables respectively to int in lieu of tinyint.
#55
How far away is the D6 version from completion?
I'd be willing to pay someone to finish putting this together and release even a working dev version for D6 early next week.
If there is a lot of work to do on it, maybe a few of us could chip in to have someone finish it.
#56
subscribe
#57
subscribe
#58
I've quickly consolidated the above patches and made it work with D6, any wants to try it and let me know if there are any problems?
#59
I am trying this now and I have not seen any troubles yet....I will post back as soon as I see something funny.
#60
I've tested #58 and works fine on my localhost
#61
I tested on localhost and the internal site does not work. I mean when entering an internal related page the database does a query and does not auto complete.
#62
Invisigoth's version (comment #58) works for me.
THANK YOU! :)
(Why not make it live on the modules page so people can find it?)
#63
Will certainly do this shortly:-)
#64
Just fixed the table myself after reaching 255 in the in the auto_increment of lid.
Anyways... it seems to me in the fix #58 above the "nid" is still of tinyint type, meaning after adding a node #255 it won't work.
Or may be I missed something.
#65
Is someone still intending to make the Drupal 6 version of this module from comment #58 a live release? Those who've tried it, is it still working without problems for you?
Thanks.
#66
I tried this mod and got this error:--
user warning: Duplicate entry '255' for key 1 query: INSERT INTO relatedlinks_tracker (nid, keywords) VALUES (341, '') in /home/singh123/public_html/www/indiauser.com/sites/all/modules/inder/relatedlinks/relatedlinks.module on line 848.
#67
I got it fixed by Using few code changes. However have not checked rest of code:-
/*** Insert a record into the relatedlinks_tracker table.
*
* @param $nid
* Node ID of the node to insert a tracker record for.
* @param $keywords
* Search module keywords that will allow discovered links to be calculated
* using the search module.
*/
function _relatedlinks_insert_tracker($nid, $keywords) {
if(trim($keywords)){
$test_obj=db_fetch_object(db_query("SELECT * from {relatedlinks_tracker} where nid='%d' AND keywords='%s'", $nid, $keywords));
if(!$test_obj->nid)//means no result from db
db_query("INSERT INTO {relatedlinks_tracker} (nid, keywords) VALUES (%d, '%s')", $nid, $keywords);
else
db_query("UPDATE {relatedlinks_tracker} SET keywords = '%s' WHERE nid = %d", $keywords, $nid);
}
}
#68
subscribe
#69
Ok I tried to repair the next error after applying the last patch, but somehow cannot get it working.
/**
* Insert related links into the database.
*
* @param $nid
* Node ID of the node to add links for.
* @param $links
* An associative array of URLs and titles.
* @param $type
* The type of the links being inserted as denoted by the type constants.
*/
function _relatedlinks_add_links($nid, $links, $type) {
foreach ($links as $link) {
foreach ($links as $link) {
$test_obj = db_fetch_object(db_query("SELECT * FROM {relatedlinks} WHERE nid=%d AND url='%s' AND title='%s' AND type=%d", $nid, $link['url'], trim($link['title']), $type));
if(!$test_obj->nid) {
db_query("INSERT INTO {relatedlinks} (nid, url, title, type) VALUES (%d, '%s', '%s', %d)", $nid, $link['url'], trim($link['title']), $type);}
else {
db_query("UPDATE {relatedlinks} SET url='%s' AND $type=%d WHERE nid = %d AND title='%s'", $link['url'], $type, $nid, trim($link['title']));
}
}
}
}
#70
subscribe
#71
Here's a quick little patch that fixes two annoyances:
1. ignore mailto links
2. Strip html from the link title
the tar file in #58 appears to be working for me on a site that is being upgraded from D5 to D6.