Issue fork rules-3457135

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

TR created an issue. See original summary.

sarwan_verma’s picture

Assigned: Unassigned » sarwan_verma
sarwan_verma’s picture

Assigned: sarwan_verma » Unassigned
Status: Active » Needs review
StatusFileSize
new741 bytes

Hi @TR,

I've created the patch for this , please verify the attached patch.

tr’s picture

Status: Needs review » Needs work
     // Use parameter FALSE to include 'Anonymous'.
-    $roles = user_role_names(FALSE);
+    $roles = Role::loadMultiple(FALSE);

This doesn't work.

loadMultiple() doesn't take a boolean argument.
You have to make sure that the value of $roles doesn't change. I suggest reading the change record that I linked.

sarwan_verma’s picture

Status: Needs work » Needs review
StatusFileSize
new736 bytes

I have added the new updated patch ,kindly review and verify. Thanks.

tr’s picture

Status: Needs review » Needs work

Read what I said in #4.

ankitv18 made their first commit to this issue’s fork.

ankitv18 changed the visibility of the branch 3457135-10.2-userroles-and to hidden.

ankitv18’s picture

Status: Needs work » Needs review

MR!38 is ready for review

tr’s picture

Status: Needs review » Needs work
StatusFileSize
new244 bytes

Again, user_role_names() and Role::loadMultiple() DO NOT GENERATE THE SAME OUTPUT. You can't simply substitute one for the other. More work needs to be done.

The contents of $roles needs to be EXACTLY THE SAME after the change as it was before the change.

Here is a little drush script that demonstrates this is wrong. This prints the value of $roles with the old code then prints the value of $roles with the new code. Run this as drush php-script 3457135-roles.txt

bharath-kondeti’s picture

Assigned: Unassigned » bharath-kondeti
bharath-kondeti’s picture

Assigned: bharath-kondeti » Unassigned
Status: Needs work » Needs review
tr’s picture

I don't think Html::escape() is correct here, so I removed it. The original function user_role_names() does not use it. Also, this was discussed in the core issue linked in the change notice. Although the core patch did use it in some places, there was a follow-up issue to remove it.

Regardless, in Rules, this code appears in an OptionsProvider, and sanitation should not take place this early - that should be left to the rendering stage. We have no knowledge in the OptionsProvider about how the data will eventually be used, so IMO it is premature to modify it with escape().

bharath-kondeti’s picture

Okay. Thanks for the review. @TR do we have to address the build issues on PR in this issue itself ?

  • TR committed 13d625d2 on 4.0.x authored by ankitv18
    Issue #3457135 by TR, bharath-kondeti: [10.2] user_roles() and...
tr’s picture

Status: Needs review » Fixed

Only need to address things caused by this MR, but there are none. I still trying to get all the tests back and running - they're failing due to changed in D10.3 and due to the change from DrupalCI to GitLabCI. I'm working on it, and it's almost all fixed now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.