[1.0.x] Author bulk assignment

Created on 17 October 2023, 9 months ago
Updated 10 November 2023, 8 months ago

Project description

  • This module allows to set the author of multiple entities at a time using a bulk action.
  • This module works with variety of entity types that provide an owner or author field, without just being limited to Node only.
  • This module adds the new bulk operation to the admin listing of the all the configured entity types from the module's configuration page.
  • Once configured, you will see a new bulk operation "Assign bulk item to author" in the actions list.
  • Selecting the new bulk operation will provide an additional autocomplete field to choose the assignee.

Project link

https://www.drupal.org/project/author_bulk_assignment

📌 Task
Status

Fixed

Component

module

Created by

fathima.asmat London, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fathima.asmat
  • Status changed to Needs review 9 months ago
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications , Application workflow , What to cover in an application review , and Tools to use for reviews .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues .

  • Status changed to Needs work 9 months ago
  • 🇮🇳India vishal.kadam Mumbai

    FILE: src/Form/SettingsForm.php

        $form['entity_types'] = [
          '#type' => 'checkboxes',
          '#title' => 'Entity types',
          '#description' => $this->t('Select the entity types that should have a bulk action for assigning the content to a different author form the admin listings'),
          '#options' => $entity_types,
          '#default_value' => $selected_entity_types,
        ];

    Form fields title must be translated strings.

  • fathima.asmat London, UK

    Ah, thanks @vishal.kadam - I have missed it from the title but added to description field. I have pushed the requested fix now, see https://git.drupalcode.org/project/author_bulk_assignment/-/commit/4a1f6...

  • Status changed to Needs review 9 months ago
  • 🇮🇳India vishal.kadam Mumbai

    Rest looks fine to me.

    Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.

  • fathima.asmat London, UK

    Normally, does it take really long for the other reviewers to review and verify the application? Drupal Con Liile might have caused some delays :D

  • Status changed to Needs work 8 months ago
  • 🇮🇳India harishh

    @fathima.asmat: Please remove .gitignore file.

  • Status changed to Needs review 8 months ago
  • 🇮🇳India vishal.kadam Mumbai

    .gitignore files are allowed. There is no need to delete them.

  • Status changed to Needs work 8 months ago
  • 🇮🇳India yogita30

    This warning message is not provide proper details for update entity permission to be required for the author.

  • Status changed to Needs review 8 months ago
  • 🇮🇳India vishal.kadam Mumbai

    @YogitaR This is not an issue created in a project queue.

    Comments in this queue are required to review the project files and report what needs to be changed. We do not debug projects.

  • fathima.asmat London, UK

    Thanks, Yogita, for the suggestion to clarify the warning message. As Vishal pointed out, this pertains to a security application issue for the project, and we should only use this for addressing security-related or breaking issues.

    Since the reported issue is more of an improvement, it needs to be created as an issue in the project's issue queue. I've just done that for you and marked it as resolved in a new release. Feel free to review and provide feedback on that project's issue here: https://www.drupal.org/project/author_bulk_assignment/issues/3398675 🐛 Make the warning message clearer when the author assignment fails for entities inaccessible for the selected assignee Fixed . I've credited you for your contribution in checking the module and suggesting the improvement. 😊

    Vishal, your continued feedback and advice are greatly appreciated! +1

  • fathima.asmat London, UK

    Could @apaderno or one of the core reviewers please kindly review this application and feedback? It is affecting our live deployment as our client is really pushing hard to get the security cover for this project before go live.

    Many thanks in advance.

  • 🇲🇩Moldova andrei.vesterli Chisinau

    Hi @fathima.asmat

    Thx a lot for your contribution to the Drupal community. A great respect from me. I did a smoke testing and a review of your module and here are some comments:

    Again, great job!

  • Status changed to Needs work 8 months ago
  • fathima.asmat London, UK

    Thanks andrei.vesterli for the feedback.

    I have added the suggested improvements to README, composer.json files along with the hook_help to the module.

    I haven't added a default install config for default settings as I don't want to keep the bulk option on for any entity type by default until the admin manually turns that option on after installation.

  • Status changed to Needs review 8 months ago
  • 🇲🇩Moldova andrei.vesterli Chisinau

    Hi @fathima.asmat

    Great! I have no comments here. This is OK from my side.

    Regards,
    Andrei

  • Status changed to Needs work 8 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    • What follows is a quick review of the project; it doesn't mean to be complete
    • For each point, the review usually shows some lines that should be fixed (except in the case the point is about the full content of a file); it doesn't show all the lines that need to be changed for the same reason
    • A review is about code that doesn't follow the coding standards, contains possible security issue, or doesn't correctly use the Drupal API; the single points aren't ordered, not even by importance

    src/Form/SettingsForm.php

    A form class that extends ConfigFormBase is for saving values in a configuration object. When the action done is different, the parent class must be different.

      /**
       * The entity type manager service.
       *
       * @var \Drupal\Core\Entity\EntityTypeManagerInterface
       */
      protected EntityTypeManagerInterface $entityTypeManager;
    

    Since the module is declared compatible with any Drupal 9 version, it cannot use PHP 7.4 features, as only Drupal 9,4 dropped the support for PHP 7.3 or lower versions.

      /**
       * {@inheritdoc}
       */
      public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entityTypeManager, MessengerInterface $messenger) {
        parent::__construct($config_factory);
        $this->entityTypeManager = $entityTypeManager;
        $this->messenger = $messenger;
      }
    

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace. It must also describe the accepted parameters.

              $action = Action::create([
                'id' => $action_id,
                'plugin' => 'entity:author_bulk_assignment_action:' . $definition->id(),
                'label' => 'Assign bulk ' . strtolower($definition->getSingularLabel()) . ' to author',
                'type' => $definition->id(),
              ]);
    

    The label must be a translatable string, as any other strings shown to site users.

      /**
       * {@inheritdoc}
       */
      protected function isApplicableEntity(EntityTypeInterface $entity_type) {
        // Any entity type that has an author field.
        // Either "owner" OR "uid" field.
        return $entity_type->hasKey('uid') || $entity_type->hasKey('owner');
      }
    

    Since that is not a method defined from the parent class, its description comment cannot contain {@inheritdoc}.

    author_bulk_assignment.install

      $actions_storage = \Drupal::entityTypeManager()
        ->getStorage('action');
      $entity_types = \Drupal::entityTypeManager()->getDefinitions();
      foreach ($entity_types as $entity_type) {
        if ($entity_type->hasKey('uid') || $entity_type->hasKey('owner')) {
          $actions = $actions_storage
            ->getQuery()
            ->condition('id', $entity_type->id() . '_author_bulk_assignment_action')
            ->execute();
          if ($actions) {
            $action_entities = $actions_storage->loadMultiple($actions);
            foreach ($action_entities as $action_entity) {
              if ($action_entity instanceof Action) {
                $action_entity->delete();
              }
            }
          }
        }
      }
    

    For what I recall, Drupal core already uninstall the entities a module that is uninstalled defined. There is no need to implement that code.

    author_bulk_assignment.libraries.yml

    version: VERSION

    VERSION is only used by Drupal core modules. With contributed modules, that would increase the library version when there are no changes in the library itself.

  • fathima.asmat London, UK

    Many thanks for your feedback, Apaderno. All your comments are addressed and the updates are pushed to 1.0.x branch.

  • Status changed to Needs review 8 months ago
  • Assigned to apaderno
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    FormBase has already a $messenger property, which does not need to be redefined. setMessenger() and getMessenger() should be used to initialize that property and to get the value stored in that property.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Thank you for your contribution! I am going to update your account.

    These are some recommended readings to help with excellent maintainership:

    You can find more contributors chatting on the Slack #contribute channel. So, come hang out and stay involved .
    Thank you, also, for your patience with the review process.
    Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review . I encourage you to learn more about that process and join the group of reviewers.

    I thank all the reviewers.

  • Status changed to Fixed 8 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • fathima.asmat London, UK

    Great news, thanks everyone!!!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024