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']) {

AttachmentSize
relatedlinks.diff6.11 KB

#1

Zen - February 29, 2008 - 07:17

If you have the time, please update your patch against 5.x.2.x-dev. Much appreciated - thanks!

#2

hswong3i - March 27, 2008 - 19:49
Version:5.x-1.x-dev» HEAD
Category:bug report» task
Status:active» needs work

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.

AttachmentSize
relatedlinks-6.x.patch 30.52 KB

#3

mehlvogel - March 28, 2008 - 07:13

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

AttachmentSize
relatedlinks_theme_hook.patch 786 bytes

#4

Zen - March 30, 2008 - 05:16

Are you missing some files in your patch, mehlvogel?

Thanks,
-K

#5

mehlvogel - March 30, 2008 - 11:43

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

AttachmentSize
relatedlinks.patch 21.5 KB

#6

Zen - March 30, 2008 - 15:29

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

mehlvogel - March 30, 2008 - 17:47

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

cutv - April 14, 2008 - 16:48

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

coltrane - May 14, 2008 - 19:59

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

coltrane - May 14, 2008 - 20:00
Version:HEAD» 5.x-2.x-dev

Oh, and the port should happen against DRUPAL-5--2? Or will recent changes make it over to the HEAD branch? Thanks.

#11

Zen - May 16, 2008 - 06:15

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

coltrane - May 19, 2008 - 21:25
Status:needs work» needs review

Patch from hswong3i in #2 rerolled. Applies against DRUPAL-5--2. Module installs and configuration works. I haven't tested anything else yet though.

AttachmentSize
relatedlinks-6.x-222609.patch 19.65 KB

#13

Pedro Lozano - May 29, 2008 - 12:33

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

mbach - June 19, 2008 - 15:01

Would someone be so nice and integrate the patches in an initial D6 release?
Thanks for your support!!!

#15

coltrane - June 19, 2008 - 22:36
Status:needs review» needs work

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

coltrane - June 19, 2008 - 22:37

Attachment didn't make it ... here we go again ...

AttachmentSize
relatedlinks-6.x-222609-15.patch 19.68 KB

#17

Pedro Lozano - June 20, 2008 - 09:42

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

george@dynapres.nl - July 3, 2008 - 09:12

subscribe

#19

coltrane - July 29, 2008 - 17:42

@pl2, I'm not sure where you are saying to add Drupal.attachBehaviors(), can you roll a patch or post the code? thanks

#20

Pedro Lozano - July 29, 2008 - 22:13

@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.

AttachmentSize
relatedlinks-js-6.x.patch 549 bytes

#21

Psicomante - August 22, 2008 - 21:31

subs

#22

Dave Reid - August 27, 2008 - 04:45

Love this module. Will help test a 6.x-dev branch. Subscribing.

#23

nsilberman - August 29, 2008 - 12:16

subscribe

#24

dbooth - September 2, 2008 - 12:33

subscribe

#25

dbooth - September 8, 2008 - 14:17

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

JeremyL - September 18, 2008 - 19:03

Any update on when we might see an official alpha or beta port for 6?

#27

dennys - September 24, 2008 - 14:41

subscribe

#28

Antinoo - September 25, 2008 - 21:38

+1

#29

jonga - September 29, 2008 - 06:07

sub

#30

theabacus - October 14, 2008 - 19:56

subscribe

#31

lumi_v - November 7, 2008 - 21:48

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

jmesam - November 18, 2008 - 00:34

I'm waiting for this module upgrade , too

#33

mrfelton - November 24, 2008 - 12:58

subscribing.

#34

mimhakkuh - November 24, 2008 - 17:23

Subscribe

#35

clint.davis - December 3, 2008 - 04:04

Subscribe

#36

burgs - December 3, 2008 - 17:25

subscribing

#37

spiffyd - December 17, 2008 - 09:41

subs

#38

aledt - December 28, 2008 - 00:43

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

DerekAhmedzai - January 13, 2009 - 10:09

When are we likely to see a 6.x-dev release?

#40

marvix - January 17, 2009 - 19:46

When are we likely to see a 6.x-dev release?

#41

darumaki - January 25, 2009 - 10:04

subscribe

#42

spiffyd - January 26, 2009 - 00:17

Those that want 6.x, try the Similiar mod

#43

mrfelton - January 26, 2009 - 11:14

@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

scott859 - February 1, 2009 - 21:13

subscribe

#45

gustav - February 4, 2009 - 06:57

subscribe

#46

jalama - February 6, 2009 - 02:30

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.

AttachmentSize
relatedlinks-25.patch 20.05 KB
relatedlinks-6.x.tar_.gz 27.93 KB

#47

mrfelton - February 6, 2009 - 16:10

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

moshe weitzman - February 6, 2009 - 18:28

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

moshe weitzman - March 11, 2009 - 16:00

I solved this in another module with COUNT(DISTINCT(tn.tid))

#50

tjbcham - March 18, 2009 - 13:53

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

nnn - April 17, 2009 - 03:58

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

shah_waliuallah - May 26, 2009 - 23:41

subscribe, any updates on this

#53

mrfelton - May 27, 2009 - 07:33
Title:Port to drupal 6.0» Port Related Links module to drupal 6.x

updateing title to make it easily identifiable in my issue queue.

#54

jalama - June 5, 2009 - 20:13

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

J. Cohen - June 20, 2009 - 20:34

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

Starminder - June 22, 2009 - 02:16

subscribe

#57

billybag - June 27, 2009 - 00:42

subscribe

#58

invisigoth - June 28, 2009 - 02:54

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?

AttachmentSize
relatedlinks.tar_.gz 45.38 KB

#59

markalosey - June 28, 2009 - 19:44

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

federico - June 29, 2009 - 19:38

I've tested #58 and works fine on my localhost

#61

qalkozai - July 17, 2009 - 04:41

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

J. Cohen - July 29, 2009 - 17:31

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

invisigoth - August 26, 2009 - 04:46

Will certainly do this shortly:-)

#64

vlad79 - October 12, 2009 - 19:52

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

authentictech - October 24, 2009 - 16:56

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

inders - October 30, 2009 - 13:56

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

inders - October 30, 2009 - 14:01

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

grateful_drupal_user - November 10, 2009 - 06:42

subscribe

#69

kansaj - November 10, 2009 - 08:09

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

NicolasH - November 12, 2009 - 04:44

subscribe

#71

bkat - November 25, 2009 - 07:21

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.

AttachmentSize
relatedlinks.strip_tags.patch 798 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.