pkp-lib icon indicating copy to clipboard operation
pkp-lib copied to clipboard

Site level mailables can't be accessed with ContextId = null

Open defstat opened this issue 1 year ago • 1 comments

Describe the bug A recent change related to the DB foreign keys changed the code that was using 0 as the "placeholder" for the site-related contextId. Now this is set to null.

This affected the Mailables retrieval. All the related functions getByKey, getCollector, etc of the emailTemplate Repository are using int $contextId as a mandatory, not nullable parameter. In case that we may need the site level mailable (like the registration or login processes) the code returns a fatal error, because it tries to pass null in the parameter that this is not allowed.

To Reproduce Steps to reproduce the behavior:

  1. Try to register a new user with the [email] => require_validation = On switch in the configuration file

What application are you using? OJS, OMP or OPS main branch


PRs

PKP-LIB: #10358

defstat avatar Sep 02 '24 16:09 defstat

@Vitaliy-1, I have made a PR for that. This one allows a null contextId in the existing emailTemplates repository.

I'm not sure if we want to go in that direction or use a different logic for site-level mailables to avoid mixing them with the existing context-related templates.

However, this seems to work nonetheless.

defstat avatar Sep 02 '24 16:09 defstat

Merged the PR, thanks!

asmecher avatar Nov 26 '24 21:11 asmecher