can't update the url in weblinks in Drupal 4.6

wbsoft - June 8, 2005 - 14:51
Project:Weblink
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

#1

wbsoft - June 8, 2005 - 15:44

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:

<?php
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)

#2

Bèr Kessels - June 19, 2005 - 15:52

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

#3

laura s - July 15, 2005 - 05:12

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);
}

#4

ron_mahon - July 16, 2005 - 20:04

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

#5

Steve Dondley - July 18, 2005 - 21:38

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?

AttachmentSize
weblink_10.patch 497 bytes

#6

Bèr Kessels - July 23, 2005 - 19:29
Status:active» fixed

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

#7

Anonymous - August 6, 2005 - 22:00

#8

Anonymous - August 20, 2005 - 22:01

#9

Anonymous - August 20, 2005 - 22:01

#10

Anonymous - September 3, 2005 - 22:20

#11

Anonymous - September 17, 2005 - 22:40

#12

Anonymous - October 1, 2005 - 22:40
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.