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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3219570-2-object_vs_array.patch | 1.8 KB | fjgarlin |
| Screenshot 2021-06-18 at 15.25.52.png | 127.5 KB | fjgarlin | |
| Screenshot 2021-06-18 at 15.25.29.png | 57.96 KB | fjgarlin |
Issue fork discourse_sso-3219570
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
Comment #2
fjgarlin commentedPatch supplied.
Comment #3
jurgenhaas@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.
Comment #5
fjgarlin commentedYou got it @jurgenhaas. Here it is: https://git.drupalcode.org/project/discourse_sso/-/merge_requests/1
Comment #7
jurgenhaasThis 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.