Skip to content
Snippets Groups Projects
Commit 6fb2c098 authored by catch's avatar catch
Browse files

Issue #3240167 by andypost, alexpott, daffie, larowlan:...

Issue #3240167 by andypost, alexpott, daffie, larowlan: \Drupal\comment\CommentStorage::getMaxThread() and \Drupal\comment\Entity\Comment::getThread() cause deprecations on PHP 8.1
parent 0867d5a4
No related branches found
No related tags found
No related merge requests found
......@@ -211,8 +211,9 @@ public function setCreatedTime($created);
/**
* Returns the alphadecimal representation of the comment's place in a thread.
*
* @return string
* The alphadecimal representation of the comment's place in a thread.
* @return string|null
* The alphadecimal representation of the comment's place in a thread. NULL
* is returned before a comment is saved.
*/
public function getThread();
......
......@@ -17,9 +17,10 @@ interface CommentStorageInterface extends ContentEntityStorageInterface {
* @param \Drupal\comment\CommentInterface $comment
* A comment entity.
*
* @return string
* @return string|null
* The maximum encoded thread value among the top level comments of the
* node $comment belongs to.
* node $comment belongs to. NULL is returned when the commented entity has
* no comments.
*/
public function getMaxThread(CommentInterface $comment);
......@@ -29,8 +30,9 @@ public function getMaxThread(CommentInterface $comment);
* @param \Drupal\comment\CommentInterface $comment
* A comment entity.
*
* @return string
* The maximum encoded thread value among all replies of $comment.
* @return string|null
* The maximum encoded thread value among all replies of $comment. NULL is
* returned when the commented entity has no comments.
*/
public function getMaxThreadPerThread(CommentInterface $comment);
......
......@@ -124,7 +124,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
foreach ($entities as $id => $entity) {
if ($build[$id]['#comment_threaded']) {
$comment_indent = count(explode('.', $entity->getThread())) - 1;
$comment_indent = count(explode('.', (string) $entity->getThread())) - 1;
if ($comment_indent > $current_indent) {
// Set 1 to indent this comment from the previous one (its parent).
// Set only one extra level of indenting even if the difference in
......
......@@ -102,7 +102,7 @@ public function preSave(EntityStorageInterface $storage) {
// by retrieving the maximum thread level.
$max = $storage->getMaxThread($this);
// Strip the "/" from the end of the thread.
$max = rtrim($max, '/');
$max = rtrim((string) $max, '/');
// We need to get the value at the correct depth.
$parts = explode('.', $max);
$n = Number::alphadecimalToInt($parts[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment