\Drupal\comment\CommentStorage::getMaxThread() and \Drupal\comment\Entity\Comment::getThread() cause deprecations on PHP 8.1

Created on 30 September 2021, over 2 years ago
Updated 10 September 2023, 9 months ago

Problem/Motivation

\Drupal\comment\CommentStorage::getMaxThread() can cause deprecations on PHP 8.1 because it returns a NULL and passes it to a string function.
\Drupal\comment\Entity\Comment::getThread() can cause deprecations on PHP 8.1 because it can return a NULL.

Steps to reproduce

Run core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php on PHP 8.1

Proposed resolution

Maybe we need to adjust \Drupal\comment\CommentStorage::getMaxThreadPerThread() too... or work out a better fix.

Remaining tasks

None

User interface changes

None

API changes

The method Drupal\comment\CommentInterface::getThread() will return the value NULL when the method is called before the comment is saved.

The methods Drupal\comment\CommentStorageInterface::getMaxThread() and Drupal\comment\CommentStorageInterface::getMaxThreadPerThread() will return the value NULL when the commented entity has no comments.

Data model changes

None

Release notes snippet

TBD

πŸ“Œ Task
Status

Fixed

Version

9.3

Component
CommentΒ  β†’

Last updated 2 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024