Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orcidAuthorize employment information not available #305

Open
2 tasks
ewhanson opened this issue Dec 8, 2023 · 2 comments
Open
2 tasks

orcidAuthorize employment information not available #305

ewhanson opened this issue Dec 8, 2023 · 2 comments
Assignees

Comments

@ewhanson
Copy link

ewhanson commented Dec 8, 2023

Describe the bug
When the orcidAuthorize handler method is run, the public API is called to fetch information about the authenticated ORCID user, including any employment information.

The affiliation field on the OJS registration form is supposed to be filled with the following information from an associative array returned from the /employments ORCID endpoint $employmentJson['employment-summary'][0]['organization']['name'], but the key of employment-summary is not included.

See PHP generated warning:

PHP Warning: Undefined array key "employment-summary" in [path-to-ojs]/plugins/generic/orcidProfile/OrcidProfileHandler.php on line 166

To confirm:

  • Is this happening all the time or only when certain information is missing?
  • Did the response returned from the /employments endpoint change and does the corresponding OJS code need to be updated?

Additional context
Observed in OJS 3.4, but likely an issue in previous versions.

@ewhanson ewhanson self-assigned this Dec 8, 2023
@Nostrabramus
Copy link

Nostrabramus commented Jun 25, 2024

I had the same problem but I think I solved it.
I'm using the orcidProfile 3.3.0 with OJS 3.3.0.10.
I have already checked on the most updated github versions of the plugin and the bug persists.

I found two problems:

  1. the response variable is not re-assigned and therefore it keeps the Json array of the person and not that of the employment
  2. the decode of the Json array of the employment does not take into account the correct structure of the array,
    the current code expects:
    ['employment-summary'][0]['organization']['name']
    but the structure of the array that is returned is the following:
    ['affiliation-group'][0]['summaries'][0]['employment-summary']['organization']['name']

My solution (version 3.3.0)

problem 1
file:
/orcidProfile/pages/OrcidHandler.inc.php
line 117 is:
$httpClient->request(
but it must be:
$response = $httpClient->request(
(since the variable is not reassigned, it retains the previously loaded Json array)

problem 2
file /orcidProfile/pages/OrcidHandler.inc.php
line 140 is:
opener.document.getElementById("affiliation").value = ' . json_encode(@$employmentJson['employment-summary'][0]['organization']['name']) . ';
but it must be:
opener.document.getElementById("affiliation").value = ' . json_encode(@$employmentJson['affiliation-group'][0]['summaries'][0]['employment-summary']['organization']['name']) . ';
(to extract data from the working architecture)

I made these two corrections and it works for me, if needed I can do the pull-request.

I found the same problems on version 3.4.0 but the file involved is:
/orcidProfile/OrcidProfileHandler.php
line 148 and line 173

I hope I was helpful.

Abramo

@ewhanson
Copy link
Author

ewhanson commented Jul 9, 2024

Thanks @Nostrabramus for confirming this! I've confirmed and addressed this in the big refactor the ORCID plugin just went through (on the main branch), but will get this changed ported back to OJS 3.3 and 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants