From c9e317872004cdd7e58a9474d17a1b85888c5873 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 3 Oct 2015 18:22:06 -0400 Subject: Fix issue when unlinking Gitlab account --- app/Model/Base.php | 16 ++++++++++++++++ app/Model/User.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'app/Model') diff --git a/app/Model/Base.php b/app/Model/Base.php index a15f071c..902ab269 100644 --- a/app/Model/Base.php +++ b/app/Model/Base.php @@ -96,6 +96,22 @@ abstract class Base extends \Core\Base } } + /** + * Force some fields to be null if empty + * + * @access public + * @param array $values Input array + * @param string[] $keys List of keys + */ + public function convertNullFields(array &$values, array $keys) + { + foreach ($keys as $key) { + if (array_key_exists($key, $values) && empty($values[$key])) { + $values[$key] = null; + } + } + } + /** * Build SQL condition for a given time range * diff --git a/app/Model/User.php b/app/Model/User.php index 5792a549..fd2ec954 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -279,7 +279,7 @@ class User extends Base $this->removeFields($values, array('confirmation', 'current_password')); $this->resetFields($values, array('is_admin', 'is_ldap_user', 'is_project_admin', 'disable_login_form')); - $this->removeEmptyFields($values, array('gitlab_id')); + $this->convertNullFields($values, array('gitlab_id')); $this->convertIntegerFields($values, array('gitlab_id')); } -- cgit v1.2.3