Drupal 5.8, Weblinks 5.x-1.14

When using Web Links Overview to re-assign a weblink to a different category I get the message "A link with that URL already exists" and I have to abort the edit. I cannot find a workaround other than to delete the original weblink then re-create it in the correct category.

CommentFileSizeAuthor
#8 weblinks.module.gz11.78 KBrmiddle

Comments

jupiterchild’s picture

Update:

Carrying out any weblink edit e.g. change title, results in the same error message as above.

rmiddle’s picture

Need to check this. I put code in that is the node is the same to skip. I guess I need to a little more checking.

Thanks
Robert

jupiterchild’s picture

I'm working around this by using Web Links edit to add a single character to the end of the URL, re-assigning the URL to the correct Category then removing the additional character and reverting to the original URL.

rmiddle’s picture

I am looking in that and should have a fix but the end of today. Validation was just added so it is possible that you have two copies of the same link in you DB already. For a quick fix I am making the Validation optional.

Thanks
Robert

nancydru’s picture

Robert, there is a typo in that code: A missing "s" in the variable name on the query.

  $url_exits_nid = db_result(db_query("SELECT nid FROM {weblinks} l WHERE l.url='%s'", $node->url));
  if ($url_exists) {
    if ($node->nid != $url_exists_nid) {
nancydru’s picture

Okay, I just did some debugging and here's what I noticed: A new node (which should have dupe checking) has no "nid" at validation time. An updated node will already have a "nid".

jupiterchild’s picture

I checked the code in my weblinks.module and the '$url_exits_nid' is correctly coded as '$url_exists_nid' in my version.

rmiddle’s picture

StatusFileSize
new11.78 KB

Not that simple I wonder how this worked when I tried it and it worked?

jupiterchild,

You are using drupal 5 correct. Is so replace weblink.module with the one attached here and see if the issue is fixed?

rmiddle’s picture

Status: Active » Needs review
rmiddle’s picture

NancyDru,

I fixed the typo in the 6 code. and commited to cvs for 6. 5 code didn't have a typo but also had $node in it not the form_state like it should have in 5.x land.

Thanks
Robert

PS. I still intend to make the validation code optional so people who want dupes or have a lot of dupes already in there DB can turn it off.

jupiterchild’s picture

OK, I have carried out a few tests and that seems to have fixed this (editing) issue. I am now able to move the Web Link from one category to another and save without error. I can also carry out other edits without error.

FYI re: http://drupal.org/node/282316
If I try and create a duplicate Web Link then I still get the "A link with that URL already exists."

rmiddle’s picture

This version was about making the dupe check work right. I will add a interface and add the ability to make it optional before the next release.

Thanks
Robert

jupiterchild’s picture

Thanks for your help, much appreciated. This module is now much improved and at last providing an easy to use weblinks manager, something Drupal has needed for quite some time.

rmiddle’s picture

Status: Needs review » Fixed

I think this is two important to wait for me to add the option boxes going to release before the options are done. Marking the issue as fixes some the dupe code is working.

nancydru’s picture

Status: Fixed » Closed (fixed)