I created a new site using Drupal 4.6.1 from scratch.

The weblink module has a problem: I can add weblinks just fine, but when I try to update existing links, I can't get Drupal to remember the new url. It just always reverts to the old url that was initially entered. Even if I look in the weblinks table using the command line mysql client, the old url is still there.

It seems as if drupal does not pick up the newly entered url while updating a weblink. Changes to the text body (description) are remembered.

CommentFileSizeAuthor
#5 weblink_10.patch497 bytesSteve Dondley

Comments

wbsoft’s picture

I fixed it myself but don't know if it is correct. I don't really understand the lid stuff in weblink.module.

I changed the function weblink_update (weblink.module line 148) like this:

function weblink_update($node) {
  $result = db_query("SELECT lid FROM {weblinks_node} WHERE nid = %d", $node->nid);
  while ($row = db_fetch_object($result)) {
    db_query("UPDATE {weblinks} SET url = '%s', url_md5 = '%s' WHERE lid = '%d'", $node->url, md5($node->url), $row->lid);
  }
}

(it uses the same logic as the weblink_delete function)

Bèr Kessels’s picture

lid is the link id. Care to commit a patch?

laura s’s picture

That fix did it. I've not created a patch but manually it would look something like:

line 148 function weblink_update($node) {

- db_query("UPDATE {weblinks} SET url = '%s', url_md5 = '%s' WHERE lid = '%d'", $node->url, md5($node->url), $node->lid);

+  $result = db_query("SELECT lid FROM {weblinks_node} WHERE nid = %d", $node->nid);
+  while ($row = db_fetch_object($result)) {
+   db_query("UPDATE {weblinks} SET url = '%s', url_md5 = '%s' WHERE lid = '%d'", $node->url, md5($node->url), $row->lid);
}
ron_mahon’s picture

Laura
Thanks For the update it works fine on my site.
There may have been some things wrong with the old web links but had lots of functionality.

I miss it
Best regards
Ron

Steve Dondley’s picture

StatusFileSize
new497 bytes

Here's a somewhat simpler patch.

I'm confused though: Why doesn't drupal load the entire node before passing it on to the _update hook?

Bèr Kessels’s picture

Status: Active » Fixed

fixed in HEAD. Thanks a lot for the last patch nysus. I like that simple approach a lot.

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)