Skip to content
Snippets Groups Projects

Resolve #3490037 "Min drupal 10.3"

2 files
+ 28
15
Compare changes
  • Side-by-side
  • Inline
Files
2
<?php
declare(strict_types=1);
namespace Drupal\private_message\Service;
use Drupal\Core\Database\Connection;
@@ -24,7 +26,7 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
/**
* {@inheritdoc}
*/
public function isBanned(int $user_id): bool {
public function isBanned(int|string $user_id): bool {
$select = $this
->database
->select('private_message_ban', 'pmb');
@@ -41,6 +43,8 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
* {@inheritdoc}
*/
public function isCurrentUserBannedByUser(int $user_id): bool {
@trigger_error(__METHOD__ . '() is deprecated in private_message:4.0.0 and is removed from private_message:5.0.0. No replacement is provided. See https://www.drupal.org/node/3490530', E_USER_DEPRECATED);
$select = $this
->database
->select('private_message_ban', 'pmb');
@@ -56,7 +60,7 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
/**
* {@inheritdoc}
*/
public function getBannedUsers(int $user_id): array {
public function getBannedUsers(int|string $user_id): array {
return $this
->database
->select('private_message_ban', 'pmb')
@@ -69,8 +73,8 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
/**
* {@inheritdoc}
*/
public function unbanUser(int $user_id) {
$ban = $this->findBanEntity($this->currentUser->id(), $user_id);
public function unbanUser(int|string $user_id): void {
$ban = $this->findBanEntity((int) $this->currentUser->id(), (int) $user_id);
if (!$ban) {
// The user is not banned; just return.
return;
@@ -83,8 +87,8 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
/**
* {@inheritdoc}
*/
public function banUser(int $user_id) {
$ban = $this->findBanEntity($this->currentUser->id(), $user_id);
public function banUser(int|string $user_id): void {
$ban = $this->findBanEntity((int) $this->currentUser->id(), (int) $user_id);
if ($ban) {
// The user is already banned; just return.
return;
@@ -122,7 +126,9 @@ class PrivateMessageBanManager implements PrivateMessageBanManagerInterface {
// reset() returns the first element of the array or FALSE if the array is
// empty, but we want the return value to be NULL if the array is empty.
return reset($bans) ?: NULL;
$ban = reset($bans) ?: NULL;
assert($ban === NULL || $ban instanceof PrivateMessageBanInterface);
return $ban;
}
}
Loading