Merge pull request #1442 from pi-hole/fix/null_comments_in_groups

Store NULL for empty descriptions and comments in the groups database tables
This commit is contained in:
Adam Warner
2020-06-05 19:17:57 +01:00
committed by GitHub

View File

@@ -66,7 +66,12 @@ if ($_POST['action'] == 'get_groups') {
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
}
if (!$stmt->bindValue(':desc', $_POST['desc'], SQLITE3_TEXT)) {
$desc = $_POST['desc'];
if (strlen($desc) === 0) {
// Store NULL in database for empty descriptions
$desc = null;
}
if (!$stmt->bindValue(':desc', $desc, SQLITE3_TEXT)) {
throw new Exception('While binding desc: ' . $db->lastErrorMsg());
}
@@ -106,7 +111,7 @@ if ($_POST['action'] == 'get_groups') {
}
$desc = $_POST['desc'];
if (strlen($desc) == 0) {
if (strlen($desc) === 0) {
// Store NULL in database for empty descriptions
$desc = null;
}
@@ -259,7 +264,7 @@ if ($_POST['action'] == 'get_groups') {
}
$comment = $_POST['comment'];
if (strlen($comment) == 0) {
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}
@@ -289,7 +294,7 @@ if ($_POST['action'] == 'get_groups') {
}
$comment = $_POST['comment'];
if (strlen($comment) == 0) {
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}
@@ -469,7 +474,12 @@ if ($_POST['action'] == 'get_groups') {
throw new Exception('While binding type: ' . $db->lastErrorMsg());
}
if (!$stmt->bindValue(':comment', $_POST['comment'], SQLITE3_TEXT)) {
$comment = $_POST['comment'];
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}
if (!$stmt->bindValue(':comment', $comment, SQLITE3_TEXT)) {
throw new Exception('While binding comment: ' . $db->lastErrorMsg());
}
@@ -564,7 +574,7 @@ if ($_POST['action'] == 'get_groups') {
}
$comment = $_POST['comment'];
if (strlen($comment) == 0) {
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}
@@ -741,7 +751,12 @@ if ($_POST['action'] == 'get_groups') {
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
}
if (!$stmt->bindValue(':comment', $_POST['comment'], SQLITE3_TEXT)) {
$comment = $_POST['comment'];
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}
if (!$stmt->bindValue(':comment', $comment, SQLITE3_TEXT)) {
throw new Exception('While binding comment: ' . $db->lastErrorMsg());
}
@@ -786,7 +801,7 @@ if ($_POST['action'] == 'get_groups') {
}
$comment = $_POST['comment'];
if (strlen($comment) == 0) {
if (strlen($comment) === 0) {
// Store NULL in database for empty comments
$comment = null;
}