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
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:
<?phpfunction 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
lid is the link id. Care to commit a patch?
#3
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
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
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?
#6
fixed in HEAD. Thanks a lot for the last patch nysus. I like that simple approach a lot.
#7
#8
#9
#10
#11
#12