If remove the user who wasn't removed from Licesnes. Next time remove the license of the user from Licenses. It will show error
Error: Call to a member function removeRole() on null in Drupal\commerce_license\Plugin\Commerce\LicenseType\Role->revokeLicense() (line 70 of /var/websites/ascmus_org/web/modules/contrib/commerce_license/src/Plugin/Commerce/LicenseType/Role.php)
Add code in "/src/Plugin/Commerce/LicenseType/Role.php"
public function revokeLicense(LicenseInterface $license) {
// Get the role ID that this license grants.
$role_id = $license->license_role->first()->target_id;
// Get the owner of the license and remove that role.
$owner = $license->getOwner();
+ // Skip if the owner doesn't exist
+ if (empty($owner)) {
+ return;
+ }
$owner->removeRole($role_id);
$owner->save();
// TODO: Log this, as it's something admins should see?
}
Comments
Comment #2
mohit.bansal623 commentedComment #3
mohit.bansal623 commentedComment #4
mohit.bansal623 commentedComment #5
mohit.bansal623 commentedAs per the error, I have fixed the issue. The class has been moved to a new directory. From Kernel it has been moved to Traits.
Applying the patch for the same.
Comment #7
jsacksick commentedThis should be fixed in dev (See #3194917: Licenses should leverage the EntityOwnerTrait), now that we leverage the Commerce EntityOwnerTrait, an owner is always returned.