pkp / orcidProfile

A plugin to pull ORCID information into a PKP user profile
GNU General Public License v3.0
16 stars 50 forks source link

Adds verification to context variable if its an instance of Journal c… #315

Open netmas opened 4 months ago

netmas commented 4 months ago

This modification verifies that the $context is of type Journal.

This fixes this error:

[17-Apr-2024 14:09:43 America/Argentina/Cordoba] Slim Application Error: Type: TypeError Message: APP\plugins\generic\orcidProfile\mailables\OrcidCollectAuthorId::construct(): Argument #1 ($context) must be of type APP\journal\Journal, APP\server\Server given, called in /home/paideias/preprints.latarxiv.org/plugins/generic/orcidProfile/OrcidProfilePlugin.php on line 898 File: /home/paideias/preprints.latarxiv.org/plugins/generic/orcidProfile/mailables/OrcidCollectAuthorId.php Line: 38 Trace: #0 /home/paideias/preprints.latarxiv.org/plugins/generic/orcidProfile/OrcidProfilePlugin.php(898): APP\plugins\generic\orcidProfile\mailables\OrcidCollectAuthorId->construct()

1 /home/paideias/preprints.latarxiv.org/plugins/generic/orcidProfile/OrcidProfilePlugin.php(862): APP\plugins\generic\orcidProfile\OrcidProfilePlugin->sendAuthorMail()

2 [internal function]: APP\plugins\generic\orcidProfile\OrcidProfilePlugin->handleAuthorFormExecute()

asmecher commented 4 months ago

@ewhanson, can you tackle this one? I suppose the issue was probably encountered on stable-3_4_0, as stable-3_3_0 doesn't have typehints.

ewhanson commented 4 months ago

Hey @netmas, thanks for finding this and submitting a PR!

I think in this case, rather than an instanceof check, it would be better to make the expected type for the mailables the parent Context class rather than a journal. This should be updated both here: https://github.com/pkp/orcidProfile/blob/61066d8fa0c66536dcb5b9db1a67c42df8f62963/mailables/OrcidCollectAuthorId.php#L38 and here: https://github.com/pkp/orcidProfile/blob/61066d8fa0c66536dcb5b9db1a67c42df8f62963/mailables/OrcidRequestAuthorAuthorization.php#L39