Issue #3240167 by andypost, alexpott, daffie, larowlan: \Drupal\comment\CommentStorage::getMaxThread() and \Drupal\comment\Entity\Comment::getThread() cause deprecations on PHP 8.1
parent
0867d5a4a9
commit
6fb2c098e3
|
@ -211,8 +211,9 @@ interface CommentInterface extends ContentEntityInterface, EntityChangedInterfac
|
|||
/**
|
||||
* 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 @@ interface CommentStorageInterface extends ContentEntityStorageInterface {
|
|||
* @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 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
|
||||
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 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
|||
// 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]);
|
||||
|
|
Loading…
Reference in New Issue