Condition userroles anonymous and authenticated users stopped working

Created on 4 July 2021, over 3 years ago
Updated 13 August 2024, 4 months ago

Problem/Motivation

Context condition userroles anonymous and authenticated users stopped working after installing latest dev or updating to 7.x-3.12. Other (own) userroles are working correct, also with 'make role a negative condition' selected.

Steps to reproduce

Select the role anonymous or authenticated as role condition. See that the reactions are not working.
Select a self made role and the reactions are working.

Proposed resolution

Please make userroles anonymous and authenticated users work again as condition. And also for 'make role a negative condition'.

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

🐛 Bug report
Status

Needs review

Version

3.12

Component

Code

Created by

🇳🇱Netherlands cmseasy

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.

  • 🇵🇭Philippines dsdeiz

    Yeah, experienced the same as well. For my case, it was because of the language. I wonder if it's a similar case.

    Context condition for user was expecting the translated role names for "anonymous" and "authenticated" while context list only had untranslated role names.

    I've attached the patch if that helps.

  • 🇳🇱Netherlands cmseasy

    I have a Dutch language site.
    The patch did work for custum roles.
    Not for anonymous (anonieme gebruiker) and authenticated (geverifieerde gebruiker).

  • 🇵🇭Philippines dsdeiz

    Yeah, seems to work for my case. I tested with Dutch. You can try debugging using this:

    @ plugins/context_condition_user.inc:38 @ class context_condition_user extends context_condition {
       function execute($account) {
         $all_roles = user_roles();
         $users_roles = $account->roles;
    +    print_r($all_roles);
    +    print_r($users_roles);
         foreach ($all_roles as $rid => $role) {
           foreach ($this->get_contexts($role) as $context) {
             $options = $this->fetch_from_context($context, 'options');
    
  • 🇨🇦Canada Ron Collins

    Context was failing for anonymous users on the French pages after updating 3.11 to 3.12.

    Patch #3 worked for me. Thanks.

    Seems like an easy one to get rolled in for next release.

  • Status changed to RTBC about 1 year ago
  • 🇭🇺Hungary danyg Budapest

    It's a simple and super solution for the issue, thanks. I can confirm the patch works when you translated the authenticated and/or anonymous role's name. Changed to RTBC

  • Status changed to Needs review 4 months ago
  • 🇪🇸Spain santiwww

    Sometimes (depending on when and how drupal 7 was installed, p.e. after a migration from d6) the names in the roles table are already translated, and because of that the patch #3 does not work.

    That's the case in some of my sites sites which were built in spanish in d6 and migrated to d7.

    I have created a new patch to force the name in english for authenticated and anonymous roles.

    I changed the status to needs review.

Production build 0.71.5 2024