diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index fe3a1fb..da0c9a7 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -49,7 +49,7 @@ public function validate($value, Constraint $constraint) { if ($typed_data instanceof StringInterface && !is_scalar($value)) { $valid = FALSE; } - if ($typed_data instanceof UriInterface && filter_var($value, FILTER_VALIDATE_URL) === FALSE) { + if ($typed_data instanceof UriInterface && $value !== '' && filter_var($value, FILTER_VALIDATE_URL) === FALSE) { $valid = FALSE; } // @todo: Move those to separate constraint validators. @@ -67,6 +67,9 @@ public function validate($value, Constraint $constraint) { } if (!$valid) { + debug($value); + /** @var \Drupal\Core\TypedData\TypedDataInterface $typed_data */ + debug($typed_data->getPropertyPath()); // @todo: Provide a good violation message for each problem. $this->context->addViolation($constraint->message, array( '%value' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value) diff --git a/core/modules/comment/src/CommentAccessControlHandler.php b/core/modules/comment/src/CommentAccessControlHandler.php index 3b62b92..7775105 100644 --- a/core/modules/comment/src/CommentAccessControlHandler.php +++ b/core/modules/comment/src/CommentAccessControlHandler.php @@ -62,7 +62,6 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_ $is_admin_edit = $items->getEntity()->id() && $account->hasPermission('administer comments'); $admin_fields = array('created', 'uid', 'status'); if (in_array($field_definition->getName(), $admin_fields)) { - var_dump($is_admin_edit, $field_definition->getName()); return $is_admin_edit; } @@ -71,7 +70,6 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_ $entity = \Drupal::entityManager()->getStorage($comment->getCommentedEntityTypeId())->load($comment->getCommentedEntityId()); $comment_field_definition = \Drupal::entityManager()->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$comment->getFieldName()]; $anonymous_contact = $comment_field_definition->getSetting('anonymous'); - var_dump($is_admin_edit || ($account->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT), $field_definition->getName()); return $is_admin_edit || ($account->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT); } diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php index da4b453..17034b0 100644 --- a/core/modules/comment/src/Tests/CommentAnonymousTest.php +++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php @@ -61,8 +61,8 @@ function testAnonymous() { // Ensure anonymous users cannot post in the name of registered users. $edit = array( - 'name' => $this->admin_user->getUsername(), - 'mail' => $this->randomMachineName() . '@example.com', + 'name[0][value]' => $this->admin_user->getUsername(), + 'mail[0][value]' => $this->randomMachineName() . '@example.com', 'subject[0][value]' => $this->randomMachineName(), 'comment_body[0][value]' => $this->randomMachineName(), ); @@ -86,7 +86,7 @@ function testAnonymous() { // Post comment with contact info (required). $author_name = $this->randomMachineName(); $author_mail = $this->randomMachineName() . '@example.com'; - $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name' => $author_name, 'mail' => $author_mail)); + $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name[0][value]' => $author_name, 'mail[0][value]' => $author_mail)); $this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.'); // Make sure the user data appears correctly when editing the comment. diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php index 94e423c..f5af803 100644 --- a/core/modules/comment/src/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php @@ -75,19 +75,19 @@ function testCommentInterface() { ))); // Test changing the comment author to "Anonymous". - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => '')); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name[0][value]' => '')); $this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.'); // Test changing the comment author to an unverified user. $random_name = $this->randomMachineName(); $this->drupalGet('comment/' . $comment->id() . '/edit'); - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $random_name)); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name[0][value]' => $random_name)); $this->drupalGet('node/' . $this->node->id()); $this->assertText($random_name . ' (' . t('not verified') . ')', 'Comment author successfully changed to an unverified user.'); // Test changing the comment author to a verified user. $this->drupalGet('comment/' . $comment->id() . '/edit'); - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $this->web_user->getUsername())); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name[0][value]' => $this->web_user->getUsername())); $this->assertTrue($comment->getAuthorName() == $this->web_user->getUsername() && $comment->getOwnerId() == $this->web_user->id(), 'Comment author successfully changed to a registered user.'); $this->drupalLogout(); diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php index 8d188c3..ee77cfd 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php @@ -85,9 +85,9 @@ function testCommentEditPreviewSave() { $date = new DrupalDateTime('2008-03-02 17:23'); $edit['subject[0][value]'] = $this->randomMachineName(8); $edit['comment_body[0][value]'] = $this->randomMachineName(16); - $edit['name'] = $web_user->getUsername(); - $edit['date[date]'] = $date->format('Y-m-d'); - $edit['date[time]'] = $date->format('H:i:s'); + $edit['name[0][value]'] = $web_user->getUsername(); + $edit['created[0][value][date]'] = $date->format('Y-m-d'); + $edit['created[0][value][time]'] = $date->format('H:i:s'); $raw_date = $date->getTimestamp(); $expected_text_date = format_date($raw_date); $expected_form_date = $date->format('Y-m-d'); @@ -99,15 +99,15 @@ function testCommentEditPreviewSave() { $this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".'); $this->assertText($edit['subject[0][value]'], 'Subject displayed.'); $this->assertText($edit['comment_body[0][value]'], 'Comment displayed.'); - $this->assertText($edit['name'], 'Author displayed.'); + $this->assertText($edit['name[0][value]'], 'Author displayed.'); $this->assertText($expected_text_date, 'Date displayed.'); // Check that the subject, comment, author and date fields are displayed with the correct values. $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.'); $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); - $this->assertFieldByName('name', $edit['name'], 'Author field displayed.'); - $this->assertFieldByName('date[date]', $edit['date[date]'], 'Date field displayed.'); - $this->assertFieldByName('date[time]', $edit['date[time]'], 'Time field displayed.'); + $this->assertFieldByName('name[0][value]', $edit['name[0][value]'], 'Author field displayed.'); + $this->assertFieldByName('created[0][value][date]', $edit['created[0][value][date]'], 'Date field displayed.'); + $this->assertFieldByName('created[0][value][time]', $edit['created[0][value][time]'], 'Time field displayed.'); // Check that saving a comment produces a success message. $this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, t('Save')); @@ -117,17 +117,17 @@ function testCommentEditPreviewSave() { $this->drupalGet('comment/' . $comment->id() . '/edit'); $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.'); $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); - $this->assertFieldByName('name', $edit['name'], 'Author field displayed.'); - $this->assertFieldByName('date[date]', $expected_form_date, 'Date field displayed.'); - $this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.'); + $this->assertFieldByName('name[0][value]', $edit['name[0][value]'], 'Author field displayed.'); + $this->assertFieldByName('created[0][value][date]', $expected_form_date, 'Date field displayed.'); + $this->assertFieldByName('created[0][value][time]', $expected_form_time, 'Time field displayed.'); // Submit the form using the displayed values. $displayed = array(); $displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value")); $displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']")); - $displayed['name'] = (string) current($this->xpath("//input[@id='edit-name']/@value")); - $displayed['date[date]'] = (string) current($this->xpath("//input[@id='edit-date-date']/@value")); - $displayed['date[time]'] = (string) current($this->xpath("//input[@id='edit-date-time']/@value")); + $displayed['name[0][value]'] = (string) current($this->xpath("//input[@id='edit-name-0-value']/@value")); + $displayed['created[0][value][date]'] = (string) current($this->xpath("//input[@id='edit-created-0-value-date']/@value")); + $displayed['created[0][value][time]'] = (string) current($this->xpath("//input[@id='edit-created-0-value-time']/@value")); $this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save')); // Check that the saved comment is still correct. @@ -136,7 +136,7 @@ function testCommentEditPreviewSave() { $comment_loaded = Comment::load($comment->id()); $this->assertEqual($comment_loaded->getSubject(), $edit['subject[0][value]'], 'Subject loaded.'); $this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[0][value]'], 'Comment body loaded.'); - $this->assertEqual($comment_loaded->getAuthorName(), $edit['name'], 'Name loaded.'); + $this->assertEqual($comment_loaded->getAuthorName(), $edit['name[0][value]'], 'Name loaded.'); $this->assertEqual($comment_loaded->getCreatedTime(), $raw_date, 'Date loaded.'); $this->drupalLogout(); diff --git a/core/modules/comment/src/Tests/CommentStatisticsTest.php b/core/modules/comment/src/Tests/CommentStatisticsTest.php index 6b7bf01..901910f 100644 --- a/core/modules/comment/src/Tests/CommentStatisticsTest.php +++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php @@ -97,7 +97,7 @@ function testCommentNodeCommentStatistics() { // Post comment #3 as anonymous. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', array('name' => $this->randomMachineName())); + $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', array('name[0][value]' => $this->randomMachineName())); $comment_loaded = Comment::load($anonymous_comment->id()); // Checks the new values of node comment statistics with comment #3. diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index 05f139d..7e39c05 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -323,7 +323,7 @@ public function setCommentSettings($name, $value, $message, $field_name = 'comme * Contact info is available. */ function commentContactInfoAvailable() { - return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->drupalGetContent()); + return preg_match('/(input).*?(name="name\[0\]\[value\]").*?(input).*?(name="mail\[0\]\[value\]").*?(input).*?(name="homepage\[0\]\[value\]")/s', $this->drupalGetContent()); } /** diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldWidgetSettingsTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldWidgetSettingsTest.php index 09b922c..da2076d 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldWidgetSettingsTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldWidgetSettingsTest.php @@ -102,6 +102,7 @@ public function testWidgetSettings() { $component = $form_display->getComponent('field_test_email'); $expected['type'] = 'email_default'; $expected['weight'] = 4; + $expected['settings'] = array('size' => 60, 'placeholder' => ''); $this->assertEqual($component, $expected, 'Email field settings are correct.'); // Link field. diff --git a/core/modules/rdf/src/Tests/CommentAttributesTest.php b/core/modules/rdf/src/Tests/CommentAttributesTest.php index 82fd967..f291b6a 100644 --- a/core/modules/rdf/src/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php @@ -155,9 +155,9 @@ public function testCommentRdfaMarkup() { // Posts comment #2 as anonymous user. $anonymous_user = array(); - $anonymous_user['name'] = $this->randomMachineName(); - $anonymous_user['mail'] = 'tester@simpletest.org'; - $anonymous_user['homepage'] = 'http://example.org/'; + $anonymous_user['name[0][value]'] = $this->randomMachineName(); + $anonymous_user['mail[0][value]'] = 'tester@simpletest.org'; + $anonymous_user['homepage[0][value]'] = 'http://example.org/'; $comment2 = $this->saveComment($this->node->id(), 0, $anonymous_user); // Tests comment #2 as anonymous user.