[3/5] Fix more warnings occurring with unset SSH keys

Message ID 20170227184955.25495-3-lfleischer@archlinux.org
State Accepted, archived
Headers show
Series [1/5] 404.php: Squelch warning on empty PATH_INFO | expand

Commit Message

Lukas Fleischer Feb. 27, 2017, 6:49 p.m. UTC
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
---
 web/lib/acctfuncs.inc.php | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch

diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index a6eab27..3c8f9ed 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -301,7 +301,9 @@  function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C=""
 		}
 
 		$uid = $dbh->lastInsertId();
-		account_set_ssh_keys($uid, $ssh_keys, $ssh_fingerprints);
+		if (isset($ssh_keys) && count($ssh_keys) > 0) {
+			account_set_ssh_keys($uid, $ssh_keys, $ssh_fingerprints);
+		}
 
 		$message = __("The account, %s%s%s, has been successfully created.",
 				"<strong>", htmlspecialchars($U,ENT_QUOTES), "</strong>");
@@ -364,7 +366,11 @@  function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C=""
 		$q.= " WHERE ID = ".intval($UID);
 		$result = $dbh->exec($q);
 
-		$ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints);
+		if (isset($ssh_keys) && count($ssh_keys) > 0) {
+			$ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints);
+		} else {
+			$ssh_key_result = true;
+		}
 
 		if (isset($_COOKIE["AURTZ"]) && ($_COOKIE["AURTZ"] != $TZ)) {
 			/* set new cookie for timezone */