Commit b7e24734 authored by quicksketch's avatar quicksketch

#402420: Cleanup Abandoned Database Rows Left Over from D5.

parent 111b60ca
......@@ -141,6 +141,33 @@ function filefield_update_6100() {
return $ret;
}
/**
* Set fid to NULL where files have been deleted.
*
* This is a double-cleanup from Drupal 5 versions, where fid used to be 0 for
* empty rows or sometimes referred to a nonexistent FID altogether.
*/
function filefield_update_6101() {
$ret = array();
module_load_include('inc', 'content', 'includes/content.crud');
$fields = content_fields();
foreach ($fields as $field) {
if ($field['type'] == 'filefield') {
$db_info = content_database_info($field);
if (isset($db_info['columns']['fid'])) {
$table = $db_info['table'];
$fid_column = $db_info['columns']['fid']['column'];
$list_column = $db_info['columns']['list']['column'];
$ret[] = update_sql("UPDATE {$table} SET $fid_column = NULL, $list_column = NULL WHERE $fid_column NOT IN (SELECT fid FROM {files})");
}
}
}
return $ret;
}
/**
* Move the list and descriptions column into the serialized data column.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment