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

Fatal error when setting the body of a mailable with null #9444

Closed
jonasraoni opened this issue Oct 20, 2023 · 3 comments · Fixed by #9445 or #9446
Closed

Fatal error when setting the body of a mailable with null #9444

jonasraoni opened this issue Oct 20, 2023 · 3 comments · Fixed by #9445 or #9446
Assignees
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.

Comments

@jonasraoni
Copy link
Contributor

Describe the bug
When trying to create a submission in OMP, I've got the Exception below, due to the absence of a body at the email template SUBMISSION_NEEDS_EDITOR.
Perhaps the template body shouldn't be null, but the Mailable class should deal with it.

Slim Application Error:
Type: TypeError
Message: PKP\mail\Mailable::body(): Argument #1 ($view) must be of type string, null given, called in /var/www/html/lib/pkp/classes/observers/listeners/AssignEditors.php on line 115
File: /var/www/html/lib/pkp/classes/mail/Mailable.php
Line: 257
Trace: #0 /var/www/html/lib/pkp/classes/observers/listeners/AssignEditors.php(115): PKP\mail\Mailable->body(NULL)
#1 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(441): PKP\observers\listeners\AssignEditors->handle(Object(PKP\observers\events\SubmissionSubmitted))
#2 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}('PKP\\observers\\e...', Array)
#3 /var/www/html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(451): Illuminate\Events\Dispatcher->dispatch('PKP\\observers\\e...')
#4 /var/www/html/lib/pkp/classes/submission/Repository.php(595): event(Object(PKP\observers\events\SubmissionSubmitted))
#5 /var/www/html/lib/pkp/api/v1/submissions/PKPSubmissionHandler.php(717): PKP\submission\Repository->submit(Object(APP\submission\Submission), Object(APP\press\Press))
#6 [internal function]: PKP\API\v1\submissions\PKPSubmissionHandler->submit(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Array)
#7 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func(Array, Object(Slim\Http\Request), Object(PKP\core\APIResponse), Array)
#8 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/Route.php(281): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\Request), Object(PKP\core\APIResponse), Array)
#9 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#10 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#11 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/App.php(503): Slim\Route->run(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#12 /var/www/html/lib/pkp/classes/security/authorization/internal/ApiAuthorizationMiddleware.php(90): Slim\App->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#13 [internal function]: PKP\security\authorization\internal\ApiAuthorizationMiddleware->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Slim\App))
#14 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(PKP\security\authorization\internal\ApiAuthorizationMiddleware), Array)
#15 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Slim\App))
#16 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Slim\App))
#17 /var/www/html/lib/pkp/classes/security/authorization/internal/ApiCsrfMiddleware.php(56): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#18 [internal function]: PKP\security\authorization\internal\ApiCsrfMiddleware->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#19 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(PKP\security\authorization\internal\ApiCsrfMiddleware), Array)
#20 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#21 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#22 /var/www/html/lib/pkp/classes/security/authorization/internal/ApiTokenDecodingMiddleware.php(140): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#23 [internal function]: PKP\security\authorization\internal\ApiTokenDecodingMiddleware->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#24 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(PKP\security\authorization\internal\ApiTokenDecodingMiddleware), Array)
#25 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#26 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#27 /var/www/html/lib/pkp/classes/handler/APIHandler.php(83): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#28 [internal function]: PKP\handler\APIHandler->PKP\handler\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#29 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#30 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#31 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#32 /var/www/html/lib/pkp/classes/handler/APIHandler.php(100): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#33 [internal function]: PKP\handler\APIHandler->PKP\handler\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#34 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#35 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#36 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#37 /var/www/html/lib/pkp/classes/handler/APIHandler.php(105): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#38 [internal function]: PKP\handler\APIHandler->PKP\handler\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#39 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#40 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#41 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#42 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#43 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#44 /var/www/html/lib/pkp/classes/handler/APIHandler.php(98): Slim\App->process(Object(Slim\Http\Request), Object(PKP\core\APIResponse))
#45 [internal function]: PKP\handler\APIHandler->PKP\handler\{closure}(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Object(Closure))
#46 /var/www/html/lib/pkp/lib/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#47 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http

What application are you using?
OMP 3.4

jonasraoni added a commit to jonasraoni/pkp-lib that referenced this issue Oct 20, 2023
@jonasraoni jonasraoni self-assigned this Oct 20, 2023
@jonasraoni jonasraoni added the Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. label Oct 20, 2023
jonasraoni added a commit to jonasraoni/pkp-lib that referenced this issue Oct 20, 2023
@jonasraoni
Copy link
Contributor Author

jonasraoni commented Oct 20, 2023

@asmecher / @Vitaliy-1 I was going to merge right away, but as I've created PRs, here they are:

I've got this exception in our test drive, AFAICR it was missing some template data for the en locale.
I didn't see how the email migration is working, but perhaps there's something missing to create/recreate non-existent templates.

jonasraoni added a commit that referenced this issue Oct 24, 2023
…ax-mailable-body

#9444 Allowed passing null to the Mailable::body() method
jonasraoni added a commit that referenced this issue Oct 24, 2023
…ble-body

#9444 Allowed passing null to the Mailable::body() method
@jonasraoni
Copy link
Contributor Author

I've merged the PRs as there's nothing special on them.

I just wanted to:

@Vitaliy-1
Copy link
Collaborator

Thanks, @jonasraoni!

This issue is related: #9202, I'm planning to migrate all of the missing template for 3.5 release

I'd add a warning if mailable is sent with an empty body, just for such cases - to know if the template is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.
Projects
None yet
2 participants