function commons_update_3102 in Drupal Commons 7.3
Reset the default avatar if the associated file doesn't exist in the file_managed table.
File
- ./
commons.install, line 602 - Install, update and uninstall functions for the Commons install profile.
Code
function commons_update_3102() {
$reset_avatar = FALSE;
$file = variable_get('user_picture_default', '');
if (!$file) {
$reset_avatar = TRUE;
}
if (!$reset_avatar) {
$results = db_select('file_managed', 'f')
->fields('f', array(
'fid',
))
->condition('filename', $file, '=')
->execute()
->fetchAll();
if (count($results) === 0) {
$reset_avatar = TRUE;
}
}
if ($reset_avatar) {
commons_set_default_avatar();
}
return array();
}