@@ -53,6 +53,25 @@ public function __construct(Properties $properties)
5353 $ this ->loadQueries ();
5454 }
5555
56+ /**
57+ * Get first nonempty property value.
58+ *
59+ * @param mixed ...$keys Property keys.
60+ *
61+ * @return mixed
62+ */
63+ private function firstNonemptyProperty (...$ keys )
64+ {
65+ foreach ($ keys as $ key ) {
66+ $ value = $ this ->properties [$ key ];
67+ if (!empty ($ value )) {
68+ return $ value ;
69+ }
70+ }
71+
72+ return null ;
73+ }
74+
5675 /**
5776 * Load queries to the array.
5877 */
@@ -64,19 +83,19 @@ private function loadQueries()
6483
6584 $ gAdmin = $ this ->properties [DB ::GROUP_ADMIN_COLUMN ];
6685 $ gGID = $ this ->properties [DB ::GROUP_GID_COLUMN ];
67- $ gName = $ this ->properties [ DB ::GROUP_NAME_COLUMN ] || $ this -> properties [ DB ::GROUP_GID_COLUMN ] ;
86+ $ gName = $ this ->firstNonemptyProperty ( DB ::GROUP_NAME_COLUMN , DB ::GROUP_GID_COLUMN ) ;
6887
6988 $ uActive = $ this ->properties [DB ::USER_ACTIVE_COLUMN ];
7089 $ uAvatar = $ this ->properties [DB ::USER_AVATAR_COLUMN ];
7190 $ uDisabled = $ this ->properties [DB ::USER_DISABLED_COLUMN ];
7291 $ uEmail = $ this ->properties [DB ::USER_EMAIL_COLUMN ];
7392 $ uHome = $ this ->properties [DB ::USER_HOME_COLUMN ];
74- $ uName = $ this ->properties [ DB ::USER_NAME_COLUMN ] || $ this -> properties [ DB ::USER_USERNAME_COLUMN ] || $ this -> properties [ DB ::USER_UID_COLUMN ] ;
93+ $ uName = $ this ->firstNonemptyProperty ( DB ::USER_NAME_COLUMN , DB ::USER_USERNAME_COLUMN , DB ::USER_UID_COLUMN ) ;
7594 $ uPassword = $ this ->properties [DB ::USER_PASSWORD_COLUMN ];
7695 $ uQuota = $ this ->properties [DB ::USER_QUOTA_COLUMN ];
7796 $ uSalt = $ this ->properties [DB ::USER_SALT_COLUMN ];
7897 $ uUID = $ this ->properties [DB ::USER_UID_COLUMN ];
79- $ uUsername = $ this ->properties [ DB ::USER_USERNAME_COLUMN ] || $ this -> properties [ DB ::USER_UID_COLUMN ] ;
98+ $ uUsername = $ this ->firstNonemptyProperty ( DB ::USER_USERNAME_COLUMN , DB ::USER_UID_COLUMN ) ;
8099
81100 $ ugGID = $ this ->properties [DB ::USER_GROUP_GID_COLUMN ];
82101 $ ugUID = $ this ->properties [DB ::USER_GROUP_UID_COLUMN ];
0 commit comments