Delete orphaned authors automatically?

franqui - February 19, 2009 - 13:06
Project:Bibliography Module
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

When you edit an entry and change the name of a contributor, the old contributor is not deleted in the biblio_update() hook. Thus, an orphaned contributor (which is probably misspelled) remains in the database.

It would be then desirable to remove orphaned contributors automatically, which can be done adding the query:

<?php
   db_query
('DELETE FROM {biblio_contributor_data} WHERE cid NOT IN (SELECT DISTINCT(cid) FROM {biblio_contributor})');
?>

In the biblio_update() hook, which removes contributors which are not related to a node. The same can be done for removed nodes in the biblio_delete() hook.

Would this have an undesired side effect?

#1

rjerome - February 19, 2009 - 13:41

The reason it's not done automatically is that in some cases you may want to prepopulate or retain authors in the database in order to enhance the autocomplete capability. i.e. a university might enter all it's faculty members so that when entering a new paper, auto-complete will produce consistent results.

I could make it an option to automatically delete orphans if so desired.

Ron.

#2

Benjamin Melançon - March 31, 2009 - 17:21

+1 for an option to delete orphaned authors automatically. Where we (some SCF sites) have all our data pulled in from pubmed, this helps us keep the data clean.

benjamin, Agaric Design Collective

#3

rjerome - March 31, 2009 - 21:18
Version:6.x-1.0-rc5» 6.x-1.x-dev
Status:needs review» fixed

This is now in the -dev release. Look for an option on the settings page under the "Authors" section. It is turned OFF by default.

Ron.

#4

Benjamin Melançon - April 2, 2009 - 12:26

Fantastic! Tested and approved, heh.

#5

System Message - April 16, 2009 - 12:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.