unpublish content option does not work

Created on 15 December 2020, over 4 years ago
Updated 11 May 2023, almost 2 years ago

Problem/Motivation

One option is to block the user and depublish content.
It does not depublish the content

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇫🇷France matoeil

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany Anybody Porta Westfalica

    Might be the same reasons as for 🐛 User associated contents are deleted Fixed ? Does this still happen?

  • 🇫🇷France mably

    It looks like unpublication is simply not implemented:

          case 'user_cancel_block':
          case 'user_cancel_block_unpublish':
            if ($user->isBlocked()) {
              // The user is already blocked. Do not block them again.
              return;
            }
            $this->notifyUserToPurge($user);
            $user->block();
            $user->save();
            $this->messenger->addStatus($this->t('%name has been disabled.', ['%name' => $user->getDisplayName()]));
            $logger->notice('Blocked user: %name %email.', [
              '%name' => $user->getAccountName(),
              '%email' => '<' . $user->getEmail() . '>',
            ]);
            break;
    

    Is this still a desired feature?

  • 🇫🇷France mably

    Ok, it's done here when we call the user_cancel hook:

        // When the 'user_cancel_delete' method is used, user_delete() is called,
        // which invokes hook_ENTITY_TYPE_predelete() and hook_ENTITY_TYPE_delete()
        // for the user entity. Modules should use those hooks to respond to the
        // account deletion.
        if ($method != 'user_cancel_delete') {
          // Allow modules to add further sets to this batch.
          /* @see \user_cancel() */
          $this->moduleHandler->invokeAll('user_cancel', [$edit, $user, $method]);
        }
    

    And then the Node module unpublishes the contents here:

      #[Hook('user_cancel')]
      public function userCancelBlockUnpublish($edit, UserInterface $account, $method): void {
        if ($method === 'user_cancel_block_unpublish') {
          $nids = $this->nodeStorage->getQuery()
            ->accessCheck(FALSE)
            ->condition('uid', $account->id())
            ->execute();
          $this->moduleHandler->invoke('node', 'mass_update', [$nids, ['status' => 0], NULL, TRUE]);
        }
      }
    

    Closing this issue.

  • 🇫🇷France mably

    Actually a functional test covers the unpublication feature. So it's definitely working now.

Production build 0.71.5 2024