Fixed profile_delete_profile_and_clean_users to not fail when a profile is not assigned to an user

This commit is contained in:
fermin831 2018-12-04 11:36:18 +01:00
parent 973bd5f98c
commit 4aa21a86d8

View File

@ -152,10 +152,15 @@ function profile_delete_profile ($id_profile) {
* @return bool Whether or not it's deleted in both tables * @return bool Whether or not it's deleted in both tables
*/ */
function profile_delete_profile_and_clean_users ($id_profile) { function profile_delete_profile_and_clean_users ($id_profile) {
return
(bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile)) && $profile_deletion = (bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile));
(bool)db_process_sql_delete('tusuario_perfil', array('id_perfil' => $id_profile))
; // Delete in tusuario_perfil only if is needed
if (!(bool)db_get_value('id_perfil', 'tusuario_perfil', 'id_perfil', $id_profile)) {
return $profile_deletion;
}
return $profile_deletion &&
(bool)db_process_sql_delete('tusuario_perfil', array('id_perfil' => $id_profile));
} }
/** /**