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
Loading
Loading
Loading
Loading
+3 −2
Changes for core/modules/comment/src/CommentInterface.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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();

+6 −4
Changes for core/modules/comment/src/CommentStorageInterface.php: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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);

+1 −1
Changes for core/modules/comment/src/CommentViewBuilder.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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
+1 −1
Changes for core/modules/comment/src/Entity/Comment.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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]);