Problem/Motivation

\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

Fix \Drupal\comment\Entity\Comment::getThread to not return NULL or comment up with something better.

Remaining tasks

review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
Issue tags: +PHP 8.1
Parent issue: » #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves)
StatusFileSize
new490 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 3240172-2.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review

Random JS test fail.

andypost’s picture

Issue summary: View changes
StatusFileSize
new533 bytes

I think it's better to remove useless call to "empty()" and just process result

it may need a test to fix current expectations from the method

andypost’s picture

StatusFileSize
new869 bytes
new1.37 KB

Here's a test

The last submitted patch, 6: 3240172-6-fail.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 6: 3240172-6.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB
andypost’s picture

StatusFileSize
new457 bytes

interdiff from #6

alexpott’s picture

Status: Needs review » Closed (duplicate)

@andypost rather than combining issues we should work out why the NULL return matters, document that and consider the best fix. That said I'm going to merge the thread part of this one with #3240167: \Drupal\comment\CommentStorage::getMaxThread() and \Drupal\comment\Entity\Comment::getThread() cause deprecations on PHP 8.1 because that's all about threads.