commit cd650947b96d33a77707fa65927ef64439d73142 Author: hemant gupta Date: Wed Dec 6 18:06:02 2017 +0530 2559833-41.patch diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index ea8f469035..d6b4174f7f 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Path\CurrentPathStack; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; @@ -112,7 +111,7 @@ public function form(array $form, FormStateInterface $form_state) { // If not replying to a comment, use our dedicated page callback for new // Comments on entities. - if ($entity->url() == $this->currentPath->getPath() && !$comment->id() && !$comment->hasParentComment()) { + if ($entity->tourl()->toString() == $this->currentPath->getPath() && !$comment->id() && !$comment->hasParentComment()) { $form['#action'] = $this->url('comment.reply', ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name]); } @@ -404,7 +403,7 @@ public function save(array $form, FormStateInterface $form_state) { drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]), 'error'); // Redirect the user to the entity they are commenting on. } - if ($entity->url() == $this->currentPath->getPath() && $uri->access()) { + if ($entity->tourl()->toString() == $this->currentPath->getPath() && $uri->access()) { $form_state->setRedirectUrl($uri); } } diff --git a/core/modules/comment/tests/src/CommentBlockContentTest.php b/core/modules/comment/tests/src/CommentBlockContentTest.php index 4ddab400c7..d9efb6dbe5 100644 --- a/core/modules/comment/tests/src/CommentBlockContentTest.php +++ b/core/modules/comment/tests/src/CommentBlockContentTest.php @@ -6,19 +6,24 @@ use Drupal\block_content\Entity\BlockContentType; use Drupal\Component\Utility\Unicode; use Drupal\Core\Url; -use Drupal\simpletest\WebTestBase; use Drupal\comment\Entity\CommentType; use Drupal\user\RoleInterface; +use Drupal\Tests\BrowserTestBase; /** * Tests use of comment field on entity-type without a canonical path. * * @group comment */ -class CommentBlockContentTest extends WebTestBase { +class CommentBlockContentTest extends BrowserTestBase { use CommentTestTrait; + /** + * Modules to install. + * + * @var array + */ public static $modules = ['comment', 'user', 'block_content', 'block']; /**