From 2b44d584e6e8d153fdba50ba42e411ac9b98a4de Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 12 Mar 2024 12:14:51 +0000 Subject: [PATCH] Revert "Issue #3413949 by andypost, quietone, Spokje, taraskorpach, smustgrave, Wim Leers, DanielVeza: Move some Action plugins to Action module" This reverts commit 63a2ba06aa535a46286ebc10f3c87a77b85d7afd. --- core/modules/action/action.module | 18 --- .../action/config/schema/action.schema.yml | 30 ---- .../src/Plugin/Action/AssignOwnerNode.php | 147 ------------------ .../Action/UnpublishByKeywordComment.php | 131 ---------------- .../Plugin/Action/UnpublishByKeywordNode.php | 81 ---------- .../Kernel/Migrate/d6/MigrateActionsTest.php | 59 ------- .../Kernel/Migrate/d7/MigrateActionsTest.php | 59 ------- .../comment/config/schema/comment.schema.yml | 11 ++ .../Action/UnpublishByKeywordComment.php | 122 +++++++++++++-- .../tests/src/Kernel/CommentActionsTest.php} | 10 +- .../Action/UnpublishByKeywordCommentTest.php | 31 ---- .../migrate_drupal/d6/Upgrade6Test.php | 2 +- .../migrate_drupal/d7/Upgrade7Test.php | 2 +- .../tests/src/Functional/d6/Upgrade6Test.php | 2 +- .../tests/src/Functional/d7/Upgrade7Test.php | 2 +- .../node/config/schema/node.schema.yml | 19 +++ .../src/Plugin/Action/AssignOwnerNode.php | 139 +++++++++++++++-- .../Plugin/Action/UnpublishByKeywordNode.php | 74 +++++++-- .../Action}/UnpublishByKeywordActionTest.php | 6 +- .../src/Unit/Action/AssignOwnerNodeTest.php | 28 ---- .../Action/UnpublishByKeywordActionTest.php | 27 ---- .../migrate_drupal/d6/UpgradeTest.php | 2 +- .../migrate_drupal/d7/UpgradeTest.php | 2 +- core/modules/system/migrations/d6_action.yml | 3 - core/modules/system/migrations/d7_action.yml | 3 - .../Kernel/Migrate/d6/MigrateActionsTest.php | 3 + .../Kernel/Migrate/d7/MigrateActionsTest.php | 3 + 27 files changed, 355 insertions(+), 661 deletions(-) delete mode 100644 core/modules/action/config/schema/action.schema.yml delete mode 100644 core/modules/action/src/Plugin/Action/AssignOwnerNode.php delete mode 100644 core/modules/action/src/Plugin/Action/UnpublishByKeywordComment.php delete mode 100644 core/modules/action/src/Plugin/Action/UnpublishByKeywordNode.php delete mode 100644 core/modules/action/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php delete mode 100644 core/modules/action/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php rename core/modules/{action/tests/src/Kernel/UnpublishByKeywordCommentTest.php => comment/tests/src/Kernel/CommentActionsTest.php} (95%) delete mode 100644 core/modules/comment/tests/src/Unit/Action/UnpublishByKeywordCommentTest.php rename core/modules/{action/tests/src/Kernel => node/tests/src/Kernel/Action}/UnpublishByKeywordActionTest.php (93%) delete mode 100644 core/modules/node/tests/src/Unit/Action/AssignOwnerNodeTest.php delete mode 100644 core/modules/node/tests/src/Unit/Action/UnpublishByKeywordActionTest.php diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 0e4229debc4e..deb7d2557737 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -8,7 +8,6 @@ use Drupal\Core\Url; use Drupal\action\Form\ActionAddForm; use Drupal\action\Form\ActionEditForm; -use Drupal\system\Plugin\migrate\source\Action; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -53,20 +52,3 @@ function action_entity_type_build(array &$entity_types) { ->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}') ->setLinkTemplate('collection', '/admin/config/system/actions'); } - -/** - * Implements hook_migration_plugins_alter(). - */ -function action_migration_plugins_alter(array &$migrations) { - foreach ($migrations as $migration_id => $migration) { - // Add Actions plugins in actions module. - /** @var \Drupal\migrate\Plugin\migrate\source\SqlBase $source_plugin */ - $source_plugin = \Drupal::service('plugin.manager.migration') - ->createStubMigration($migration) - ->getSourcePlugin(); - if (is_a($source_plugin, Action::class) && isset($migration['process']['plugin'])) { - $migrations[$migration_id]['process']['plugin'][0]['map']['comment_unpublish_by_keyword_action'] = 'comment_unpublish_by_keyword_action'; - $migrations[$migration_id]['process']['plugin'][0]['map']['node_unpublish_by_keyword_action'] = 'node_unpublish_by_keyword_action'; - } - } -} diff --git a/core/modules/action/config/schema/action.schema.yml b/core/modules/action/config/schema/action.schema.yml deleted file mode 100644 index 3627201766ef..000000000000 --- a/core/modules/action/config/schema/action.schema.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Schema for the configuration files of the Action module. -action.configuration.comment_unpublish_by_keyword_action: - type: mapping - label: 'Unpublish comment containing keyword(s) configuration' - mapping: - keywords: - type: sequence - label: 'Keywords' - sequence: - type: string - label: 'Keyword' - -action.configuration.node_unpublish_by_keyword_action: - type: mapping - label: 'Unpublish content containing keyword(s) configuration' - mapping: - keywords: - type: sequence - label: 'Keywords' - sequence: - type: string - label: 'Keyword' - -action.configuration.node_assign_owner_action: - type: mapping - label: 'Change the author of content configuration' - mapping: - owner_uid: - type: text - label: 'Username' diff --git a/core/modules/action/src/Plugin/Action/AssignOwnerNode.php b/core/modules/action/src/Plugin/Action/AssignOwnerNode.php deleted file mode 100644 index 6aad7da8f7c9..000000000000 --- a/core/modules/action/src/Plugin/Action/AssignOwnerNode.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\action\Plugin\Action; - -use Drupal\Core\Action\ConfigurableActionBase; -use Drupal\Core\Action\Attribute\Action; -use Drupal\Core\Database\Connection; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\user\Entity\User; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Assigns ownership of a node to a user. - */ -#[Action( - id: 'node_assign_owner_action', - label: new TranslatableMarkup('Change the author of content'), - type: 'node' -)] -class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactoryPluginInterface { - - /** - * The database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $connection; - - /** - * Constructs a new AssignOwnerNode action. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin ID for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Database\Connection $connection - * The database connection. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $connection) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->connection = $connection; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, - $container->get('database') - ); - } - - /** - * {@inheritdoc} - */ - public function execute($entity = NULL) { - /** @var \Drupal\node\NodeInterface $entity */ - $entity->setOwnerId($this->configuration['owner_uid'])->save(); - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return [ - 'owner_uid' => '', - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $description = $this->t('The username of the user to which you would like to assign ownership.'); - $count = $this->connection->query("SELECT COUNT(*) FROM {users}")->fetchField(); - - // Use dropdown for fewer than 200 users; textbox for more than that. - if (intval($count) < 200) { - $options = []; - $result = $this->connection->query("SELECT [uid], [name] FROM {users_field_data} WHERE [uid] > 0 AND [default_langcode] = 1 ORDER BY [name]"); - foreach ($result as $data) { - $options[$data->uid] = $data->name; - } - $form['owner_uid'] = [ - '#type' => 'select', - '#title' => $this->t('Username'), - '#default_value' => $this->configuration['owner_uid'], - '#options' => $options, - '#description' => $description, - ]; - } - else { - $form['owner_uid'] = [ - '#type' => 'entity_autocomplete', - '#title' => $this->t('Username'), - '#target_type' => 'user', - '#selection_settings' => [ - 'include_anonymous' => FALSE, - ], - '#default_value' => User::load($this->configuration['owner_uid']), - // Validation is done in static::validateConfigurationForm(). - '#validate_reference' => FALSE, - '#size' => '6', - '#maxlength' => '60', - '#description' => $description, - ]; - } - return $form; - } - - /** - * {@inheritdoc} - */ - public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { - $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE [uid] = :uid AND [default_langcode] = 1', 0, 1, [':uid' => $form_state->getValue('owner_uid')])->fetchField(); - if (!$exists) { - $form_state->setErrorByName('owner_uid', $this->t('Enter a valid username.')); - } - } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { - $this->configuration['owner_uid'] = $form_state->getValue('owner_uid'); - } - - /** - * {@inheritdoc} - */ - public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { - /** @var \Drupal\node\NodeInterface $object */ - $result = $object->access('update', $account, TRUE) - ->andIf($object->getOwner()->access('edit', $account, TRUE)); - - return $return_as_object ? $result : $result->isAllowed(); - } - -} diff --git a/core/modules/action/src/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/action/src/Plugin/Action/UnpublishByKeywordComment.php deleted file mode 100644 index c859645f5cf5..000000000000 --- a/core/modules/action/src/Plugin/Action/UnpublishByKeywordComment.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\action\Plugin\Action; - -use Drupal\Component\Utility\Tags; -use Drupal\Core\Action\ConfigurableActionBase; -use Drupal\Core\Action\Attribute\Action; -use Drupal\Core\Entity\EntityViewBuilderInterface; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Render\RendererInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Unpublishes a comment containing certain keywords. - */ -#[Action( - id: 'comment_unpublish_by_keyword_action', - label: new TranslatableMarkup('Unpublish comment containing keyword(s)'), - type: 'comment' -)] -class UnpublishByKeywordComment extends ConfigurableActionBase implements ContainerFactoryPluginInterface { - - /** - * The comment entity builder handler. - * - * @var \Drupal\Core\Entity\EntityViewBuilderInterface - */ - protected $viewBuilder; - - /** - * The renderer. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** - * Constructs an UnpublishByKeywordComment object. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin ID for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityViewBuilderInterface $comment_view_builder - * The comment entity builder handler. - * @param \Drupal\Core\Render\RendererInterface $renderer - * The renderer. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityViewBuilderInterface $comment_view_builder, RendererInterface $renderer) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->viewBuilder = $comment_view_builder; - $this->renderer = $renderer; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager')->getViewBuilder('comment'), - $container->get('renderer') - ); - } - - /** - * {@inheritdoc} - */ - public function execute($comment = NULL) { - $build = $this->viewBuilder->view($comment); - $text = (string) $this->renderer->renderInIsolation($build); - foreach ($this->configuration['keywords'] as $keyword) { - if (str_contains($text, $keyword)) { - $comment->setUnpublished(); - $comment->save(); - break; - } - } - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return [ - 'keywords' => [], - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['keywords'] = [ - '#title' => $this->t('Keywords'), - '#type' => 'textarea', - '#description' => $this->t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), - '#default_value' => Tags::implode($this->configuration['keywords']), - ]; - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { - $this->configuration['keywords'] = Tags::explode($form_state->getValue('keywords')); - } - - /** - * {@inheritdoc} - */ - public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { - /** @var \Drupal\comment\CommentInterface $object */ - $result = $object->access('update', $account, TRUE) - ->andIf($object->status->access('edit', $account, TRUE)); - - return $return_as_object ? $result : $result->isAllowed(); - } - -} diff --git a/core/modules/action/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/action/src/Plugin/Action/UnpublishByKeywordNode.php deleted file mode 100644 index 66885635fdb5..000000000000 --- a/core/modules/action/src/Plugin/Action/UnpublishByKeywordNode.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\action\Plugin\Action; - -use Drupal\Component\Utility\Tags; -use Drupal\Core\Action\ConfigurableActionBase; -use Drupal\Core\Action\Attribute\Action; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; - -/** - * Unpublishes a node containing certain keywords. - */ -#[Action( - id: 'node_unpublish_by_keyword_action', - label: new TranslatableMarkup('Unpublish content containing keyword(s)'), - type: 'node' -)] -class UnpublishByKeywordNode extends ConfigurableActionBase { - - /** - * {@inheritdoc} - */ - public function execute($node = NULL) { - $elements = \Drupal::entityTypeManager() - ->getViewBuilder('node') - ->view(clone $node); - $render = (string) \Drupal::service('renderer')->renderInIsolation($elements); - foreach ($this->configuration['keywords'] as $keyword) { - if (str_contains($render, $keyword) || str_contains($node->label(), $keyword)) { - $node->setUnpublished(); - $node->save(); - break; - } - } - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return [ - 'keywords' => [], - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['keywords'] = [ - '#title' => $this->t('Keywords'), - '#type' => 'textarea', - '#description' => $this->t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), - '#default_value' => Tags::implode($this->configuration['keywords']), - ]; - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { - $this->configuration['keywords'] = Tags::explode($form_state->getValue('keywords')); - } - - /** - * {@inheritdoc} - */ - public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { - /** @var \Drupal\node\NodeInterface $object */ - $access = $object->access('update', $account, TRUE) - ->andIf($object->status->access('edit', $account, TRUE)); - - return $return_as_object ? $access : $access->isAllowed(); - } - -} diff --git a/core/modules/action/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php b/core/modules/action/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php deleted file mode 100644 index 0ad84dd9254b..000000000000 --- a/core/modules/action/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Drupal\Tests\action\Kernel\Migrate\d6; - -use Drupal\system\Entity\Action; -use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; - -/** - * Tests migration of action items. - * - * @group migrate_drupal_6 - */ -class MigrateActionsTest extends MigrateDrupal6TestBase { - - protected static $modules = ['action', 'comment', 'node']; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - $this->executeMigration('d6_action'); - } - - /** - * Tests Drupal 6 action migration to Drupal 8. - */ - public function testActions() { - // Test advanced actions. - $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]); - $this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]); - } - - /** - * Asserts various aspects of an Action entity. - * - * @param string $id - * The expected Action ID. - * @param string $label - * The expected Action label. - * @param string $type - * The expected Action type. - * @param array $configuration - * The expected Action configuration. - * - * @internal - */ - protected function assertEntity(string $id, string $label, string $type, array $configuration): void { - $action = Action::load($id); - - $this->assertInstanceOf(Action::class, $action); - /** @var \Drupal\system\Entity\Action $action */ - $this->assertSame($id, $action->id()); - $this->assertSame($label, $action->label()); - $this->assertSame($type, $action->getType()); - $this->assertSame($configuration, $action->get('configuration')); - } - -} diff --git a/core/modules/action/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php b/core/modules/action/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php deleted file mode 100644 index 9801847183d3..000000000000 --- a/core/modules/action/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Drupal\Tests\action\Kernel\Migrate\d7; - -use Drupal\system\Entity\Action; -use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; - -/** - * Tests migration of action items. - * - * @group action - */ -class MigrateActionsTest extends MigrateDrupal7TestBase { - - protected static $modules = ['action', 'comment', 'node']; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - $this->executeMigration('d7_action'); - } - - /** - * Tests Drupal 7 action migration to Drupal 8. - */ - public function testActions() { - // Test advanced actions. - $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]); - $this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]); - } - - /** - * Asserts various aspects of an Action entity. - * - * @param string $id - * The expected Action ID. - * @param string $label - * The expected Action label. - * @param string $type - * The expected Action type. - * @param array $configuration - * The expected Action configuration. - * - * @internal - */ - protected function assertEntity(string $id, string $label, string $type, array $configuration): void { - $action = Action::load($id); - - $this->assertInstanceOf(Action::class, $action); - /** @var \Drupal\system\Entity\Action $action */ - $this->assertSame($id, $action->id()); - $this->assertSame($label, $action->label()); - $this->assertSame($type, $action->getType()); - $this->assertSame($configuration, $action->get('configuration')); - } - -} diff --git a/core/modules/comment/config/schema/comment.schema.yml b/core/modules/comment/config/schema/comment.schema.yml index 33b3e55ac3ab..87d5a45a3454 100644 --- a/core/modules/comment/config/schema/comment.schema.yml +++ b/core/modules/comment/config/schema/comment.schema.yml @@ -24,6 +24,17 @@ field.widget.settings.comment_default: type: mapping label: 'Comment display format settings' +action.configuration.comment_unpublish_by_keyword_action: + type: mapping + label: 'Unpublish comment containing keyword(s) configuration' + mapping: + keywords: + type: sequence + label: 'Keywords' + sequence: + type: string + label: 'Keyword' + comment.type.*: type: config_entity label: 'Comment type settings' diff --git a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php index be16b10a4e03..fd26bbc58e4c 100644 --- a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php +++ b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php @@ -2,26 +2,128 @@ namespace Drupal\comment\Plugin\Action; -use Drupal\action\Plugin\Action\UnpublishByKeywordComment as ActionUnpublishByKeywordComment; +use Drupal\Component\Utility\Tags; +use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Action\Attribute\Action; use Drupal\Core\Entity\EntityViewBuilderInterface; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\RendererInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Unpublishes a comment containing certain keywords. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\action\Plugin\Action\UnpublishByKeywordComment instead. - * - * @see https://www.drupal.org/node/3424506 */ -class UnpublishByKeywordComment extends ActionUnpublishByKeywordComment { +#[Action( + id: 'comment_unpublish_by_keyword_action', + label: new TranslatableMarkup('Unpublish comment containing keyword(s)'), + type: 'comment' +)] +class UnpublishByKeywordComment extends ConfigurableActionBase implements ContainerFactoryPluginInterface { /** - * {@inheritdoc} + * The comment entity builder handler. + * + * @var \Drupal\Core\Entity\EntityViewBuilderInterface + */ + protected $viewBuilder; + + /** + * The renderer. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + + /** + * Constructs an UnpublishByKeywordComment object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin ID for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityViewBuilderInterface $comment_view_builder + * The comment entity builder handler. + * @param \Drupal\Core\Render\RendererInterface $renderer + * The renderer. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityViewBuilderInterface $comment_view_builder, RendererInterface $renderer) { - @trigger_error(__CLASS__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\UnpublishByKeywordComment instead. See https://www.drupal.org/node/3424506', E_USER_DEPRECATED); - parent::__construct($configuration, $plugin_id, $plugin_definition, $comment_view_builder, $renderer); + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->viewBuilder = $comment_view_builder; + $this->renderer = $renderer; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager')->getViewBuilder('comment'), + $container->get('renderer') + ); + } + + /** + * {@inheritdoc} + */ + public function execute($comment = NULL) { + $build = $this->viewBuilder->view($comment); + $text = $this->renderer->renderInIsolation($build); + foreach ($this->configuration['keywords'] as $keyword) { + if (str_contains($text, $keyword)) { + $comment->setUnpublished(); + $comment->save(); + break; + } + } + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'keywords' => [], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form['keywords'] = [ + '#title' => $this->t('Keywords'), + '#type' => 'textarea', + '#description' => $this->t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), + '#default_value' => Tags::implode($this->configuration['keywords']), + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['keywords'] = Tags::explode($form_state->getValue('keywords')); + } + + /** + * {@inheritdoc} + */ + public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { + /** @var \Drupal\comment\CommentInterface $object */ + $result = $object->access('update', $account, TRUE) + ->andIf($object->status->access('edit', $account, TRUE)); + + return $return_as_object ? $result : $result->isAllowed(); } } diff --git a/core/modules/action/tests/src/Kernel/UnpublishByKeywordCommentTest.php b/core/modules/comment/tests/src/Kernel/CommentActionsTest.php similarity index 95% rename from core/modules/action/tests/src/Kernel/UnpublishByKeywordCommentTest.php rename to core/modules/comment/tests/src/Kernel/CommentActionsTest.php index 4b5daef05bb8..525c58b09dee 100644 --- a/core/modules/action/tests/src/Kernel/UnpublishByKeywordCommentTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentActionsTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\Tests\action\Kernel; +namespace Drupal\Tests\comment\Kernel; use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\CommentType; @@ -12,17 +12,17 @@ use Drupal\system\Entity\Action; /** - * {@inheritdoc} + * Tests actions provided by the Comment module. * - * @group action + * @group comment */ -class UnpublishByKeywordCommentTest extends EntityKernelTestBase { +class CommentActionsTest extends EntityKernelTestBase { use CommentTestTrait; /** * {@inheritdoc} */ - protected static $modules = ['action', 'comment', 'entity_test']; + protected static $modules = ['comment', 'entity_test']; /** * Keywords used for testing. diff --git a/core/modules/comment/tests/src/Unit/Action/UnpublishByKeywordCommentTest.php b/core/modules/comment/tests/src/Unit/Action/UnpublishByKeywordCommentTest.php deleted file mode 100644 index 3047ad241f44..000000000000 --- a/core/modules/comment/tests/src/Unit/Action/UnpublishByKeywordCommentTest.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\comment\Unit\Action; - -use Drupal\comment\Plugin\Action\UnpublishByKeywordComment; -use Drupal\Core\Entity\EntityViewBuilderInterface; -use Drupal\Core\Render\RendererInterface; -use Drupal\Tests\UnitTestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; - -/** - * @group comment - * @group legacy - */ -class UnpublishByKeywordCommentTest extends UnitTestCase { - - use ExpectDeprecationTrait; - - /** - * Tests deprecation message. - */ - public function testUnpublishByKeywordAction() { - $comment_view_builder = $this->createMock(EntityViewBuilderInterface::class); - $renderer = $this->createMock(RendererInterface::class); - $this->expectDeprecation('Drupal\comment\Plugin\Action\UnpublishByKeywordComment is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\UnpublishByKeywordComment instead. See https://www.drupal.org/node/3424506'); - $this->assertIsObject(new UnpublishByKeywordComment([], 'foo', [], $comment_view_builder, $renderer)); - } - -} diff --git a/core/modules/forum/tests/src/Functional/migrate_drupal/d6/Upgrade6Test.php b/core/modules/forum/tests/src/Functional/migrate_drupal/d6/Upgrade6Test.php index 8a8a8fc01400..a8d90bdfe2d6 100644 --- a/core/modules/forum/tests/src/Functional/migrate_drupal/d6/Upgrade6Test.php +++ b/core/modules/forum/tests/src/Functional/migrate_drupal/d6/Upgrade6Test.php @@ -52,7 +52,7 @@ protected function getSourceBasePath() { */ protected function getEntityCounts() { return [ - 'action' => 24, + 'action' => 27, 'base_field_override' => 22, 'block' => 33, 'block_content' => 1, diff --git a/core/modules/forum/tests/src/Functional/migrate_drupal/d7/Upgrade7Test.php b/core/modules/forum/tests/src/Functional/migrate_drupal/d7/Upgrade7Test.php index 09c360464055..bb7660b367e1 100644 --- a/core/modules/forum/tests/src/Functional/migrate_drupal/d7/Upgrade7Test.php +++ b/core/modules/forum/tests/src/Functional/migrate_drupal/d7/Upgrade7Test.php @@ -63,7 +63,7 @@ protected function getSourceBasePath() { */ protected function getEntityCounts() { return [ - 'action' => 24, + 'action' => 27, 'base_field_override' => 3, 'block' => 26, 'block_content' => 1, diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php index 80aeb2697e26..2daba096b76c 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php @@ -96,7 +96,7 @@ protected function getEntityCounts() { 'search_page' => 3, 'shortcut' => 2, 'shortcut_set' => 1, - 'action' => 30, + 'action' => 33, 'menu' => 8, 'path_alias' => 8, 'taxonomy_term' => 15, diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php index 327e86167f25..bf3cff61ad19 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php @@ -99,7 +99,7 @@ protected function getEntityCounts() { 'search_page' => 3, 'shortcut' => 6, 'shortcut_set' => 2, - 'action' => 24, + 'action' => 27, 'menu' => 7, 'taxonomy_term' => 25, 'taxonomy_vocabulary' => 8, diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml index 08fe92cc401e..1c6e759964f3 100644 --- a/core/modules/node/config/schema/node.schema.yml +++ b/core/modules/node/config/schema/node.schema.yml @@ -69,6 +69,14 @@ search.plugin.node_search: type: integer label: 'Influence' +action.configuration.node_assign_owner_action: + type: mapping + label: 'Change the author of content configuration' + mapping: + owner_uid: + type: text + label: 'Username' + action.configuration.node_unpromote_action: type: action_configuration_default label: 'Demote selected content from front page configuration' @@ -85,6 +93,17 @@ action.configuration.node_make_unsticky_action: type: action_configuration_default label: 'Make selected content unsticky configuration' +action.configuration.node_unpublish_by_keyword_action: + type: mapping + label: 'Unpublish content containing keyword(s) configuration' + mapping: + keywords: + type: sequence + label: 'Keywords' + sequence: + type: string + label: 'Keyword' + block.settings.node_syndicate_block: type: block_settings label: 'Syndicate block' diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php index 8e4bbf17047b..e764f91a478a 100644 --- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php +++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php @@ -2,25 +2,144 @@ namespace Drupal\node\Plugin\Action; +use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Action\Attribute\Action; use Drupal\Core\Database\Connection; -use Drupal\action\Plugin\Action\AssignOwnerNode as ActionAssignOwnerNode; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\user\Entity\User; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Assigns ownership of a node to a user. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\action\Plugin\Action\AssignOwnerNode instead. - * - * @see https://www.drupal.org/node/3424506 */ -class AssignOwnerNode extends ActionAssignOwnerNode { +#[Action( + id: 'node_assign_owner_action', + label: new TranslatableMarkup('Change the author of content'), + type: 'node' +)] +class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactoryPluginInterface { /** - * {@inheritdoc} + * The database connection. + * + * @var \Drupal\Core\Database\Connection + */ + protected $connection; + + /** + * Constructs a new AssignOwnerNode action. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin ID for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Database\Connection $connection + * The database connection. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $connection) { - @trigger_error(__CLASS__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\AssignOwnerNode instead. See https://www.drupal.org/node/3424506', E_USER_DEPRECATED); - parent::__construct($configuration, $plugin_id, $plugin_definition, $connection); + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->connection = $connection; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static($configuration, $plugin_id, $plugin_definition, + $container->get('database') + ); + } + + /** + * {@inheritdoc} + */ + public function execute($entity = NULL) { + /** @var \Drupal\node\NodeInterface $entity */ + $entity->setOwnerId($this->configuration['owner_uid'])->save(); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'owner_uid' => '', + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $description = $this->t('The username of the user to which you would like to assign ownership.'); + $count = $this->connection->query("SELECT COUNT(*) FROM {users}")->fetchField(); + + // Use dropdown for fewer than 200 users; textbox for more than that. + if (intval($count) < 200) { + $options = []; + $result = $this->connection->query("SELECT [uid], [name] FROM {users_field_data} WHERE [uid] > 0 AND [default_langcode] = 1 ORDER BY [name]"); + foreach ($result as $data) { + $options[$data->uid] = $data->name; + } + $form['owner_uid'] = [ + '#type' => 'select', + '#title' => $this->t('Username'), + '#default_value' => $this->configuration['owner_uid'], + '#options' => $options, + '#description' => $description, + ]; + } + else { + $form['owner_uid'] = [ + '#type' => 'entity_autocomplete', + '#title' => $this->t('Username'), + '#target_type' => 'user', + '#selection_settings' => [ + 'include_anonymous' => FALSE, + ], + '#default_value' => User::load($this->configuration['owner_uid']), + // Validation is done in static::validateConfigurationForm(). + '#validate_reference' => FALSE, + '#size' => '6', + '#maxlength' => '60', + '#description' => $description, + ]; + } + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE [uid] = :uid AND [default_langcode] = 1', 0, 1, [':uid' => $form_state->getValue('owner_uid')])->fetchField(); + if (!$exists) { + $form_state->setErrorByName('owner_uid', $this->t('Enter a valid username.')); + } + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['owner_uid'] = $form_state->getValue('owner_uid'); + } + + /** + * {@inheritdoc} + */ + public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { + /** @var \Drupal\node\NodeInterface $object */ + $result = $object->access('update', $account, TRUE) + ->andIf($object->getOwner()->access('edit', $account, TRUE)); + + return $return_as_object ? $result : $result->isAllowed(); } } diff --git a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php index 3d9976462591..ffe0e5e255b4 100644 --- a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php +++ b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php @@ -2,24 +2,78 @@ namespace Drupal\node\Plugin\Action; -use Drupal\action\Plugin\Action\UnpublishByKeywordNode as ActionUnpublishByKeywordNode; +use Drupal\Component\Utility\Tags; +use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Action\Attribute\Action; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Unpublishes a node containing certain keywords. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\action\Plugin\Action\UnpublishByKeywordNode instead. - * - * @see https://www.drupal.org/node/3424506 */ -class UnpublishByKeywordNode extends ActionUnpublishByKeywordNode { +#[Action( + id: 'node_unpublish_by_keyword_action', + label: new TranslatableMarkup('Unpublish content containing keyword(s)'), + type: 'node' +)] +class UnpublishByKeywordNode extends ConfigurableActionBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition) { - @trigger_error(__CLASS__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\UnpublishByKeywordNode instead. See https://www.drupal.org/node/3424506', E_USER_DEPRECATED); - parent::__construct($configuration, $plugin_id, $plugin_definition); + public function execute($node = NULL) { + $elements = \Drupal::entityTypeManager() + ->getViewBuilder('node') + ->view(clone $node); + $render = \Drupal::service('renderer')->render($elements); + foreach ($this->configuration['keywords'] as $keyword) { + if (str_contains($render, $keyword) || str_contains($node->label(), $keyword)) { + $node->setUnpublished(); + $node->save(); + break; + } + } + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'keywords' => [], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form['keywords'] = [ + '#title' => $this->t('Keywords'), + '#type' => 'textarea', + '#description' => $this->t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), + '#default_value' => Tags::implode($this->configuration['keywords']), + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['keywords'] = Tags::explode($form_state->getValue('keywords')); + } + + /** + * {@inheritdoc} + */ + public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { + /** @var \Drupal\node\NodeInterface $object */ + $access = $object->access('update', $account, TRUE) + ->andIf($object->status->access('edit', $account, TRUE)); + + return $return_as_object ? $access : $access->isAllowed(); } } diff --git a/core/modules/action/tests/src/Kernel/UnpublishByKeywordActionTest.php b/core/modules/node/tests/src/Kernel/Action/UnpublishByKeywordActionTest.php similarity index 93% rename from core/modules/action/tests/src/Kernel/UnpublishByKeywordActionTest.php rename to core/modules/node/tests/src/Kernel/Action/UnpublishByKeywordActionTest.php index 4019f5179c1c..779633065b20 100644 --- a/core/modules/action/tests/src/Kernel/UnpublishByKeywordActionTest.php +++ b/core/modules/node/tests/src/Kernel/Action/UnpublishByKeywordActionTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\Tests\action\Kernel; +namespace Drupal\Tests\node\Kernel\Action; use Drupal\Core\Render\RenderContext; use Drupal\KernelTests\KernelTestBase; @@ -9,14 +9,14 @@ use Drupal\system\Entity\Action; /** - * @group action + * @group node */ class UnpublishByKeywordActionTest extends KernelTestBase { /** * {@inheritdoc} */ - protected static $modules = ['action', 'node', 'system', 'user', 'field']; + protected static $modules = ['node', 'system', 'user', 'field']; /** * {@inheritdoc} diff --git a/core/modules/node/tests/src/Unit/Action/AssignOwnerNodeTest.php b/core/modules/node/tests/src/Unit/Action/AssignOwnerNodeTest.php deleted file mode 100644 index e8d04008e16c..000000000000 --- a/core/modules/node/tests/src/Unit/Action/AssignOwnerNodeTest.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\node\Unit\Action; - -use Drupal\Core\Database\Connection; -use Drupal\node\Plugin\Action\AssignOwnerNode; -use Drupal\Tests\UnitTestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; - -/** - * @group node - * @group legacy - */ -class AssignOwnerNodeTest extends UnitTestCase { - - use ExpectDeprecationTrait; - - /** - * Tests deprecation of \Drupal\node\Plugin\Action\AssignOwnerNodeTest. - */ - public function testAssignOwnerNode() { - $this->expectDeprecation('Drupal\node\Plugin\Action\AssignOwnerNode is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\AssignOwnerNode instead. See https://www.drupal.org/node/3424506'); - $this->assertIsObject(new AssignOwnerNode([], 'foo', [], $this->prophesize(Connection::class)->reveal())); - } - -} diff --git a/core/modules/node/tests/src/Unit/Action/UnpublishByKeywordActionTest.php b/core/modules/node/tests/src/Unit/Action/UnpublishByKeywordActionTest.php deleted file mode 100644 index e11ce5e19e03..000000000000 --- a/core/modules/node/tests/src/Unit/Action/UnpublishByKeywordActionTest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\node\Unit\Action; - -use Drupal\node\Plugin\Action\UnpublishByKeywordNode; -use Drupal\Tests\UnitTestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; - -/** - * @group node - * @group legacy - */ -class UnpublishByKeywordActionTest extends UnitTestCase { - - use ExpectDeprecationTrait; - - /** - * Tests deprecation of \Drupal\node\Plugin\Action\UnpublishByKeywordNode. - */ - public function testUnpublishByKeywordAction() { - $this->expectDeprecation('Drupal\node\Plugin\Action\UnpublishByKeywordNode is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\action\Plugin\Action\UnpublishByKeywordNode instead. See https://www.drupal.org/node/3424506'); - $this->assertIsObject(new UnpublishByKeywordNode([], 'foo', [])); - } - -} diff --git a/core/modules/statistics/tests/src/Functional/migrate_drupal/d6/UpgradeTest.php b/core/modules/statistics/tests/src/Functional/migrate_drupal/d6/UpgradeTest.php index b90f82856930..8b77e47b3af9 100644 --- a/core/modules/statistics/tests/src/Functional/migrate_drupal/d6/UpgradeTest.php +++ b/core/modules/statistics/tests/src/Functional/migrate_drupal/d6/UpgradeTest.php @@ -53,7 +53,7 @@ protected function getSourceBasePath() { */ protected function getEntityCounts() { return [ - 'action' => 24, + 'action' => 27, 'base_field_override' => 18, 'block' => 33, 'block_content' => 1, diff --git a/core/modules/statistics/tests/src/Functional/migrate_drupal/d7/UpgradeTest.php b/core/modules/statistics/tests/src/Functional/migrate_drupal/d7/UpgradeTest.php index 4e8bcfd36439..539ca6fe5709 100644 --- a/core/modules/statistics/tests/src/Functional/migrate_drupal/d7/UpgradeTest.php +++ b/core/modules/statistics/tests/src/Functional/migrate_drupal/d7/UpgradeTest.php @@ -68,7 +68,7 @@ protected function getSourceBasePath() { */ protected function getEntityCounts() { return [ - 'action' => 24, + 'action' => 27, 'base_field_override' => 3, 'block' => 27, 'block_content' => 1, diff --git a/core/modules/system/migrations/d6_action.yml b/core/modules/system/migrations/d6_action.yml index 03941fa89822..f9df68296cb2 100644 --- a/core/modules/system/migrations/d6_action.yml +++ b/core/modules/system/migrations/d6_action.yml @@ -31,9 +31,6 @@ process: node_publish_action: entity:publish_action:node node_unpublish_action: entity:unpublish_action:node node_save_action: entity:save_action:node - comment_unpublish_by_keyword_action: 0 - node_unpublish_by_keyword_action: 0 - node_assign_owner_action: 0 bypass: true - plugin: skip_on_empty diff --git a/core/modules/system/migrations/d7_action.yml b/core/modules/system/migrations/d7_action.yml index c210cf2d2849..21a83aa40451 100644 --- a/core/modules/system/migrations/d7_action.yml +++ b/core/modules/system/migrations/d7_action.yml @@ -27,9 +27,6 @@ process: node_publish_action: entity:publish_action:node node_unpublish_action: entity:unpublish_action:node node_save_action: entity:save_action:node - comment_unpublish_by_keyword_action: 0 - node_unpublish_by_keyword_action: 0 - node_assign_owner_action: 0 bypass: true - plugin: skip_on_empty diff --git a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php index 198ced3024e2..deb65d081719 100644 --- a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php +++ b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateActionsTest.php @@ -33,6 +33,9 @@ public function testActions() { $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []); // Test advanced actions. + $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]); + $this->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', ["owner_uid" => "2"]); + $this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]); $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]); $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [ "recipient" => "test@example.com", diff --git a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php index 82c13832697d..395703524dcc 100644 --- a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php +++ b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateActionsTest.php @@ -33,6 +33,9 @@ public function testActions() { $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []); // Test advanced actions. + $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]); + $this->assertEntity('change_the_author_of_content', 'Change the author of content', 'node', ["owner_uid" => "2"]); + $this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]); $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]); $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [ "recipient" => "test@example.com", -- GitLab