diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index 0c0590c22c..f7b0834f36 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -86,10 +86,10 @@ public function getMaxThread(CommentInterface $comment) { ->condition('entity_type', $comment->getCommentedEntityTypeId()) ->condition('default_langcode', 1); $query->addExpression('MAX([thread])', 'thread'); - // @todo decide if we should handle this here. It is conforming to the - // interface. - return (string) $query->execute() - ->fetchField(); + // Result could be FALSE when no comments found. For datails see + // https://www.php.net/manual/en/pdostatement.fetchcolumn page. + return $query->execute() + ->fetchField() ?: ''; } /** @@ -103,8 +103,10 @@ public function getMaxThreadPerThread(CommentInterface $comment) { ->condition('thread', $comment->getParentComment()->getThread() . '.%', 'LIKE') ->condition('default_langcode', 1); $query->addExpression('MAX([thread])', 'thread'); + // Result could be FALSE when no comments found. For datails see + // https://www.php.net/manual/en/pdostatement.fetchcolumn page. return $query->execute() - ->fetchField(); + ->fetchField() ?: ''; } /**