pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
306 stars 445 forks source link

Error when requesting a single mailable #8471

Closed NateWr closed 1 year ago

NateWr commented 1 year ago

Describe the bug An error occurs when trying to load details about a single mailable through the API.

To Reproduce Steps to reproduce the behavior:

  1. Go to Settings > Workflow > Email > Add and Edit Templates
  2. Click on the Edit button next to Copyediting (Discussion)
  3. See that nothing happens.
  4. Look at server error log to find error.

What application are you using? main branch (3.4 pre-release)

Additional information The error message:

[07-Dec-2022 11:38:31 UTC] Slim Application Error:
Type: BadMethodCallException
Message: Method PKP\mail\Mailer::getMailables does not exist.
File: lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php
Line: 113
Trace: #0 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(505): Illuminate\Mail\Mailer->__call('getMailables', Array)
#1 lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): Illuminate\Mail\MailManager->__call('getMailables', Array)
#2 lib/pkp/classes/mail/Repository.php(66): Illuminate\Support\Facades\Facade::__callStatic('getMailables', Array)
#3 lib/pkp/api/v1/mailables/MailableHandler.php(91): PKP\mail\Repository->get('DISCUSSION_NOTI...', 1)
#4 [internal function]: PKP\API\v1\mailables\MailableHandler->get(Object(Slim\Http\Request), Object(PKP\core\APIResponse), Array)

This is related to #8424.

NateWr commented 1 year ago

This happened because Repo::mailable()->get(...) was still calling the Mailer::getMailables() function. To solve this, I moved a few things around. Repo::mailable()->get(...) and Repo::mailable()->getMany() now return just class names. These are compiled into descriptive arrays in the handlers that call the functions.

@Vitaliy-1 can you take a quick look to see if you spot any problems with this?

PR: https://github.com/pkp/pkp-lib/pull/8472

Tests: https://github.com/pkp/ojs/pull/3647

Vitaliy-1 commented 1 year ago

@NateWr, looks good, just a minor comment, thanks!

NateWr commented 1 year ago

Thanks! All merged.