Skip to content
Snippets Groups Projects

Issue #3322894: Comment form gives deprecated warnings on PHP 8.1 when comment is empty

Closed Issue #3322894: Comment form gives deprecated warnings on PHP 8.1 when comment is empty
3 unresolved threads
Closed Juanjo López requested to merge issue/drupal-3322894:3322894--comment-form into 9.5.x
3 unresolved threads
Files
2
@@ -313,7 +313,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
// Validate the comment's subject. If not specified, extract from comment
// body.
if (trim($comment->getSubject()) == '') {
if ($comment->hasField('comment_body')) {
if ($comment->hasField('comment_body') && !$comment->comment_body->isEmpty()) {
// The body may be in any format, so:
// 1) Filter it into HTML
// 2) Strip out all HTML tags
@@ -323,7 +323,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
}
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment->getSubject() == '') {
if (trim($comment->getSubject()) == '') {
$comment->setSubject($this->t('(No subject)'));
}
}
Loading