Issue #2969549 by marcel66, martin107: Fix "The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0." deprecation

merge-requests/1654/head
Alex Pott 2018-05-05 22:36:51 +01:00
parent 21d4930304
commit 84d5e36141
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
24 changed files with 32 additions and 34 deletions

View File

@ -36,7 +36,7 @@ class UnpublishedBlockTest extends BrowserTestBase {
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$this->assertTrue($page->has('css', '.block-block-content' . $block_content->uuid())); $this->assertTrue($page->has('css', '.block-block-content' . $block_content->uuid()));
$block_content->setPublished(FALSE); $block_content->setUnpublished();
$block_content->save(); $block_content->save();
$this->drupalGet('<front>'); $this->drupalGet('<front>');

View File

@ -523,7 +523,7 @@ function comment_user_cancel($edit, $account, $method) {
case 'user_cancel_block_unpublish': case 'user_cancel_block_unpublish':
$comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]); $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) { foreach ($comments as $comment) {
$comment->setPublished(CommentInterface::NOT_PUBLISHED); $comment->setUnpublished();
$comment->save(); $comment->save();
} }
break; break;

View File

@ -82,7 +82,7 @@ class CommentController extends ControllerBase {
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @return \Symfony\Component\HttpFoundation\RedirectResponse
*/ */
public function commentApprove(CommentInterface $comment) { public function commentApprove(CommentInterface $comment) {
$comment->setPublished(TRUE); $comment->setPublished();
$comment->save(); $comment->save();
$this->messenger()->addStatus($this->t('Comment approved.')); $this->messenger()->addStatus($this->t('Comment approved.'));

View File

@ -78,7 +78,7 @@ class UnpublishByKeywordComment extends ConfigurableActionBase implements Contai
$text = $this->renderer->renderPlain($build); $text = $this->renderer->renderPlain($build);
foreach ($this->configuration['keywords'] as $keyword) { foreach ($this->configuration['keywords'] as $keyword) {
if (strpos($text, $keyword) !== FALSE) { if (strpos($text, $keyword) !== FALSE) {
$comment->setPublished(FALSE); $comment->setUnpublished();
$comment->save(); $comment->save();
break; break;
} }

View File

@ -42,7 +42,7 @@ class CommentSelection extends DefaultSelection {
// In order to create a referenceable comment, it needs to published. // In order to create a referenceable comment, it needs to published.
/** @var \Drupal\comment\CommentInterface $comment */ /** @var \Drupal\comment\CommentInterface $comment */
$comment->setPublished(TRUE); $comment->setPublished();
return $comment; return $comment;
} }

View File

@ -78,7 +78,7 @@ class CommentAccessTest extends BrowserTestBase {
$assert->statusCodeEquals(403); $assert->statusCodeEquals(403);
// Publishing the node grants access. // Publishing the node grants access.
$this->unpublishedNode->setPublished(TRUE)->save(); $this->unpublishedNode->setPublished()->save();
$this->drupalGet($comment_url); $this->drupalGet($comment_url);
$assert->statusCodeEquals(200); $assert->statusCodeEquals(200);
} }
@ -112,7 +112,7 @@ class CommentAccessTest extends BrowserTestBase {
$assert->statusCodeEquals(403); $assert->statusCodeEquals(403);
// Publishing the node grants access. // Publishing the node grants access.
$this->unpublishedNode->setPublished(TRUE)->save(); $this->unpublishedNode->setPublished()->save();
$this->drupalGet($comment_url); $this->drupalGet($comment_url);
$assert->statusCodeEquals(200); $assert->statusCodeEquals(200);
} }

View File

@ -166,7 +166,7 @@ class CommentInterfaceTest extends CommentTestBase {
$this->setCommentsPerPage(50); $this->setCommentsPerPage(50);
// Attempt to reply to an unpublished comment. // Attempt to reply to an unpublished comment.
$reply_loaded->setPublished(FALSE); $reply_loaded->setUnpublished();
$reply_loaded->save(); $reply_loaded->save();
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $reply_loaded->id()); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $reply_loaded->id());
$this->assertResponse(403); $this->assertResponse(403);

View File

@ -2,7 +2,6 @@
namespace Drupal\Tests\comment\Kernel\Views; namespace Drupal\Tests\comment\Kernel\Views;
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface; use Drupal\comment\CommentManagerInterface;
use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Url; use Drupal\Core\Url;
@ -84,7 +83,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase {
$this->assertEqual(\Drupal::l('Approve', $url), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.'); $this->assertEqual(\Drupal::l('Approve', $url), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.');
// Approve the comment. // Approve the comment.
$comment->setPublished(CommentInterface::PUBLISHED); $comment->setPublished();
$comment->save(); $comment->save();
$view = Views::getView('test_comment'); $view = Views::getView('test_comment');
$view->preview(); $view->preview();
@ -97,7 +96,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase {
// anonymous user. // anonymous user.
$account_switcher->switchTo(new AnonymousUserSession()); $account_switcher->switchTo(new AnonymousUserSession());
// Set the comment as unpublished again. // Set the comment as unpublished again.
$comment->setPublished(CommentInterface::NOT_PUBLISHED); $comment->setUnpublished();
$comment->save(); $comment->save();
$view = Views::getView('test_comment'); $view = Views::getView('test_comment');
@ -168,7 +167,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase {
$this->assertFalse((string) $replyto_comment, "I can't reply to an unapproved comment."); $this->assertFalse((string) $replyto_comment, "I can't reply to an unapproved comment.");
// Approve the comment. // Approve the comment.
$comment->setPublished(CommentInterface::PUBLISHED); $comment->setPublished();
$comment->save(); $comment->save();
$view = Views::getView('test_comment'); $view = Views::getView('test_comment');
$view->preview(); $view->preview();

View File

@ -98,14 +98,14 @@ class ContentTranslationOperationsTest extends NodeTestBase {
'access content' => TRUE, 'access content' => TRUE,
] ]
); );
$node->setPublished(FALSE)->save(); $node->setUnpublished()->save();
$this->drupalGet($node->urlInfo('drupal:content-translation-overview')); $this->drupalGet($node->urlInfo('drupal:content-translation-overview'));
$this->assertResponse(403); $this->assertResponse(403);
$this->drupalLogout(); $this->drupalLogout();
// Ensure the 'Translate' local task does not show up anymore when disabling // Ensure the 'Translate' local task does not show up anymore when disabling
// translations for a content type. // translations for a content type.
$node->setPublished(TRUE)->save(); $node->setPublished()->save();
user_role_change_permissions( user_role_change_permissions(
Role::AUTHENTICATED_ID, Role::AUTHENTICATED_ID,
[ [
@ -136,7 +136,7 @@ class ContentTranslationOperationsTest extends NodeTestBase {
$this->assertFalse(content_translation_translate_access($node)->isAllowed()); $this->assertFalse(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache(); $access_control_handler->resetCache();
$node->setPublished(TRUE); $node->setPublished();
$node->save(); $node->save();
$this->assertTrue(content_translation_translate_access($node)->isAllowed()); $this->assertTrue(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache(); $access_control_handler->resetCache();

View File

@ -112,7 +112,7 @@ class EditorPrivateFileReferenceFilterTest extends BrowserTestBase {
// When the published node is also unpublished, the image should also // When the published node is also unpublished, the image should also
// become inaccessible to anonymous users. // become inaccessible to anonymous users.
$published_node->setPublished(FALSE)->save(); $published_node->setUnpublished()->save();
$this->drupalGet($published_node->toUrl()); $this->drupalGet($published_node->toUrl());
$this->assertSession()->statusCodeEquals(403); $this->assertSession()->statusCodeEquals(403);
@ -121,7 +121,7 @@ class EditorPrivateFileReferenceFilterTest extends BrowserTestBase {
// Disallow anonymous users to view the entity, which then should also // Disallow anonymous users to view the entity, which then should also
// disallow them to view the image. // disallow them to view the image.
$published_node->setPublished(TRUE)->save(); $published_node->setPublished()->save();
Role::load(RoleInterface::ANONYMOUS_ID) Role::load(RoleInterface::ANONYMOUS_ID)
->revokePermission('access content') ->revokePermission('access content')
->save(); ->save();

View File

@ -428,7 +428,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity'); $this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity');
// Publish the node and try again. // Publish the node and try again.
$node->setPublished(TRUE); $node->setPublished();
$errors = $entity->validate(); $errors = $entity->validate();
$this->assertEqual(0, count($errors)); $this->assertEqual(0, count($errors));
@ -478,7 +478,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$this->assertEqual($errors[1]->getPropertyPath(), 'field_test_node.1.target_id'); $this->assertEqual($errors[1]->getPropertyPath(), 'field_test_node.1.target_id');
// Publish one of the nodes and try again. // Publish one of the nodes and try again.
$saved_unpublished_node->setPublished(TRUE); $saved_unpublished_node->setPublished();
$saved_unpublished_node->save(); $saved_unpublished_node->save();
$errors = $entity->validate(); $errors = $entity->validate();
$this->assertEqual(1, count($errors)); $this->assertEqual(1, count($errors));
@ -486,7 +486,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity'); $this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity');
// Publish the last invalid node and try again. // Publish the last invalid node and try again.
$unsaved_unpublished_node->setPublished(TRUE); $unsaved_unpublished_node->setPublished();
$errors = $entity->validate(); $errors = $entity->validate();
$this->assertEqual(0, count($errors)); $this->assertEqual(0, count($errors));
@ -510,7 +510,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_comment.0.entity'); $this->assertEqual($errors[0]->getPropertyPath(), 'field_test_comment.0.entity');
// Publish the comment and try again. // Publish the comment and try again.
$comment->setPublished(TRUE); $comment->setPublished();
$errors = $entity->validate(); $errors = $entity->validate();
$this->assertEqual(0, count($errors)); $this->assertEqual(0, count($errors));

View File

@ -214,7 +214,7 @@ class FilePrivateTest extends FileFieldTestBase {
$edit['files[' . $field_name . '_0]'] = $file_system->realpath($test_file->getFileUri()); $edit['files[' . $field_name . '_0]'] = $file_system->realpath($test_file->getFileUri());
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
$new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$new_node->setPublished(FALSE); $new_node->setUnpublished();
$new_node->save(); $new_node->save();
$file = File::load($new_node->{$field_name}->target_id); $file = File::load($new_node->{$field_name}->target_id);
$this->assertTrue($file->isPermanent(), 'File is permanent.'); $this->assertTrue($file->isPermanent(), 'File is permanent.');

View File

@ -217,7 +217,7 @@ class NodeForm extends ContentEntityForm {
public function updateStatus($entity_type_id, NodeInterface $node, array $form, FormStateInterface $form_state) { public function updateStatus($entity_type_id, NodeInterface $node, array $form, FormStateInterface $form_state) {
$element = $form_state->getTriggeringElement(); $element = $form_state->getTriggeringElement();
if (isset($element['#published_status'])) { if (isset($element['#published_status'])) {
$node->setPublished($element['#published_status']); $element['#published_status'] ? $node->setPublished() : $node->setUnpublished();
} }
} }

View File

@ -25,7 +25,7 @@ class UnpublishByKeywordNode extends ConfigurableActionBase {
foreach ($this->configuration['keywords'] as $keyword) { foreach ($this->configuration['keywords'] as $keyword) {
$elements = node_view(clone $node); $elements = node_view(clone $node);
if (strpos(\Drupal::service('renderer')->render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) { if (strpos(\Drupal::service('renderer')->render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) {
$node->setPublished(FALSE); $node->setUnpublished();
$node->save(); $node->save();
break; break;
} }

View File

@ -42,7 +42,7 @@ class NodeSelection extends DefaultSelection {
// In order to create a referenceable node, it needs to published. // In order to create a referenceable node, it needs to published.
/** @var \Drupal\node\NodeInterface $node */ /** @var \Drupal\node\NodeInterface $node */
$node->setPublished(TRUE); $node->setPublished();
return $node; return $node;
} }

View File

@ -32,7 +32,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
// Create a "Llama" node. // Create a "Llama" node.
$node = Node::create(['type' => 'camelids']); $node = Node::create(['type' => 'camelids']);
$node->setTitle('Llama') $node->setTitle('Llama')
->setPublished(TRUE) ->setPublished()
->save(); ->save();
return $node; return $node;

View File

@ -284,7 +284,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$translation = $node->addTranslation($langcode, $values[$langcode]); $translation = $node->addTranslation($langcode, $values[$langcode]);
// Publish and promote the translation to frontpage. // Publish and promote the translation to frontpage.
$translation->setPromoted(TRUE); $translation->setPromoted(TRUE);
$translation->setPublished(TRUE); $translation->setPublished();
} }
$node->save(); $node->save();

View File

@ -67,7 +67,7 @@ abstract class BlockContentResourceTestBase extends EntityResourceTestBase {
'format' => 'plain_text', 'format' => 'plain_text',
], ],
]) ])
->setPublished(FALSE); ->setUnpublished();
$block_content->save(); $block_content->save();
return $block_content; return $block_content;
} }

View File

@ -107,7 +107,7 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
]); ]);
$comment->setSubject('Llama') $comment->setSubject('Llama')
->setOwnerId(static::$auth ? $this->account->id() : 0) ->setOwnerId(static::$auth ? $this->account->id() : 0)
->setPublished(TRUE) ->setPublished()
->setCreatedTime(123456789) ->setCreatedTime(123456789)
->setChangedTime(123456789); ->setChangedTime(123456789);
$comment->save(); $comment->save();

View File

@ -106,7 +106,7 @@ abstract class MediaResourceTestBase extends EntityResourceTestBase {
]); ]);
$media $media
->setName('Llama') ->setName('Llama')
->setPublished(TRUE) ->setPublished()
->setCreatedTime(123456789) ->setCreatedTime(123456789)
->setOwnerId(static::$auth ? $this->account->id() : 0) ->setOwnerId(static::$auth ? $this->account->id() : 0)
->setRevisionUserId(static::$auth ? $this->account->id() : 0) ->setRevisionUserId(static::$auth ? $this->account->id() : 0)

View File

@ -81,7 +81,7 @@ abstract class NodeResourceTestBase extends EntityResourceTestBase {
$node = Node::create(['type' => 'camelids']); $node = Node::create(['type' => 'camelids']);
$node->setTitle('Llama') $node->setTitle('Llama')
->setOwnerId(static::$auth ? $this->account->id() : 0) ->setOwnerId(static::$auth ? $this->account->id() : 0)
->setPublished(TRUE) ->setPublished()
->setCreatedTime(123456789) ->setCreatedTime(123456789)
->setChangedTime(123456789) ->setChangedTime(123456789)
->setRevisionCreationTime(123456789) ->setRevisionCreationTime(123456789)

View File

@ -123,7 +123,7 @@ class RssTest extends TaxonomyTestBase {
$this->drupalGet('taxonomy/term/all/feed'); $this->drupalGet('taxonomy/term/all/feed');
$this->assertRaw($raw_xml, "Raw text '$raw_xml' is found."); $this->assertRaw($raw_xml, "Raw text '$raw_xml' is found.");
// Unpublish the article and check that it is not shown in the feed. // Unpublish the article and check that it is not shown in the feed.
$node->setPublished(FALSE)->save(); $node->setUnpublished()->save();
$this->drupalGet('taxonomy/term/all/feed'); $this->drupalGet('taxonomy/term/all/feed');
$this->assertNoRaw($raw_xml); $this->assertNoRaw($raw_xml);
} }

View File

@ -30,7 +30,7 @@ class StandardJavascriptTest extends JavascriptTestBase {
$node = Node::create(['type' => 'article']) $node = Node::create(['type' => 'article'])
->setTitle($this->randomMachineName()) ->setTitle($this->randomMachineName())
->setPromoted(TRUE) ->setPromoted(TRUE)
->setPublished(TRUE); ->setPublished();
$node->save(); $node->save();
// Front page: one placeholder, for messages. // Front page: one placeholder, for messages.

View File

@ -124,7 +124,6 @@ trait DeprecationListenerTrait {
'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.', 'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.',
'assertNoCacheTag() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseHeaderNotContains() instead. See https://www.drupal.org/node/2864029.', 'assertNoCacheTag() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseHeaderNotContains() instead. See https://www.drupal.org/node/2864029.',
'assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.', 'assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.',
'The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0.',
'The Drupal\config\Tests\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. See https://www.drupal.org/node/2916197.', 'The Drupal\config\Tests\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. See https://www.drupal.org/node/2916197.',
'Drupal\system\Tests\Menu\AssertBreadcrumbTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait', 'Drupal\system\Tests\Menu\AssertBreadcrumbTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait',
'\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait', '\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait',