Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Do not yet enforce that the user ID should be an integer.
Browse files Browse the repository at this point in the history
The core entity API often returns the user ID as a string value even though it
is defined as an integer in the base field definitions. Let's wait until core
is more strict about returning the right data type.
  • Loading branch information
pfrenssen committed Jul 22, 2019
1 parent 8ff95dd commit 0074d58
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/MembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, OgG
* {@inheritdoc}
*/
public function getUserGroupIds($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {

This comment has been minimized.

Copy link
@amitaibu

amitaibu Jul 23, 2019

Member

👍

trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -82,7 +82,7 @@ public function getUserGroupIds($user_id, array $states = [OgMembershipInterface
* {@inheritdoc}
*/
public function getUserGroups($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -95,7 +95,7 @@ public function getUserGroups($user_id, array $states = [OgMembershipInterface::
* {@inheritdoc}
*/
public function getMemberships($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public function getMemberships($user_id, array $states = [OgMembershipInterface:
* {@inheritdoc}
*/
public function getMembership(EntityInterface $group, $user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -149,7 +149,7 @@ public function getMembership(EntityInterface $group, $user_id, array $states =
* {@inheritdoc}
*/
public function getUserGroupIdsByRoleIds($user_id, array $role_ids, array $states = [OgMembershipInterface::STATE_ACTIVE], bool $require_all_roles = TRUE): array {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -172,7 +172,7 @@ public function getUserGroupIdsByRoleIds($user_id, array $role_ids, array $state
* {@inheritdoc}
*/
public function getUserGroupsByRoleIds($user_id, array $role_ids, array $states = [OgMembershipInterface::STATE_ACTIVE], bool $require_all_roles = TRUE): array {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand Down Expand Up @@ -415,7 +415,7 @@ public function getGroupContentIds(EntityInterface $entity, array $entity_types
* {@inheritdoc}
*/
public function isMember(EntityInterface $group, $user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -429,7 +429,7 @@ public function isMember(EntityInterface $group, $user_id, array $states = [OgMe
* {@inheritdoc}
*/
public function isMemberPending(EntityInterface $group, $user_id) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand All @@ -441,7 +441,7 @@ public function isMemberPending(EntityInterface $group, $user_id) {
* {@inheritdoc}
*/
public function isMemberBlocked(EntityInterface $group, $user_id) {
if (!is_int($user_id)) {
if ($user_id instanceof AccountInterface) {
trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED);
$user_id = $user_id->id();
}
Expand Down

0 comments on commit 0074d58

Please sign in to comment.