Problem/Motivation

Some of the results from "json_decode" are treated as objects, but as the second parametre is set to TRUE, they're actually an array. This provokes a chain of errors of undefined properties when trying to do some operations, like syncing roles.

We can see that change comparing to legacy code here: https://git.drupalcode.org/project/discourse_sso/-/compare/8.x-1.0-beta2... (then see all "json_decode" calls.

Steps to reproduce

Install and configure the module.
Edit a user's roles

See attached images:
* https://www.drupal.org/files/issues/2021-06-18/Screenshot%202021-06-18%2...
* https://www.drupal.org/files/issues/2021-06-18/Screenshot%202021-06-18%2...

Proposed resolution

Adapt code reading the results to either object (casting the result array) or array format.

Remaining tasks

Provide patch.

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

fjgarlin created an issue. See original summary.

fjgarlin’s picture

Status: Active » Needs review
StatusFileSize
new1.8 KB

Patch supplied.

jurgenhaas’s picture

@fjgarlin would you mind turning this into an issue fork and merge request? We could then hopefully find somebody who eventually does the review so that we can merge this in.

fjgarlin’s picture

  • jurgenhaas committed 154ad65 on 2.0.x authored by fjgarlin
    Issue #3219570 by fjgarlin: Mix up between objects and arrays due to...
jurgenhaas’s picture

Status: Needs review » Fixed

This is great, thanks a lot @fjgarlin

I looked through the MR an it looks great so that I merged it right away. I don't have any discourse instance running any longer, so I'm probably not the ideal maintainer, as I can't test things. But committing and merging is no problem.

Status: Fixed » Closed (fixed)

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