Notice generation fails for Advanced Notices, Item Due, and Overdues when run in shell. This is due to the call to C4::Context->userenv->{'branch'} in Letters.pm (line 124) coming back as undefined. Since there is no "userenv" context in the shell, it fails everytime. Introduce a check for "userenv", so it doesn't try changing the branch (which is already coming in from elsewhere) to the userenv branch. With this check, notice generation works perfectly. Related to Bug 8198 and Bug 8197.
Created attachment 10805 [details] [review] Bug 8434: Notice generation fails for Advanced Notices, Item Due, and Overdues when run in shell (due to error in Letters.pm)
David How do you run the notice generation?
(In reply to comment #2) > David > > How do you run the notice generation? I'm not personally involved with it (besides testing 3.8), but we have a shell script set up to run the overdue_notices and advanced_notices scripts and then to process_message_queue. Personally, it seems a bit strange that we do it this way. How is it ordinarily accomplished?
Cron jobs normally.
(In reply to comment #4) > Cron jobs normally. This would still be a cron job, but perhaps its purpose is to group together the different nightly scripts. Even as a regular cron job, wouldn't the context for userenv still be missing?
Yep the reason it hasn't been spotted is it only happens with independent branches on. (You can set the userenv by calling C4::Context->set_userenv if you want) But the if statement is harmless in that case, and stops an error in other cases. Signing off
Created attachment 10806 [details] [review] Bug 8434 - Notice generation fails for Advanced Notices, Item Due, and Overdues when run in shell (due to error in Letters.pm) Patch introduces a check for C4::Context->userenv in Letters.pm, so that script doesn't fail when it calls to C4::Context->userenv->{branch}, when run from shell. Without the check, Advanced Notices, Item Due, and Overdues fail to generate. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Created attachment 10831 [details] [review] [SIGNED-OFF] Bug 8434 - Notice generation fails for Advanced Notices, Item Due, and Overdues when run in shell (due to error in Letters.pm) Patch introduces a check for C4::Context->userenv in Letters.pm, so that script doesn't fail when it calls to C4::Context->userenv->{branch}, when run from shell. Without the check, Advanced Notices, Item Due, and Overdues fail to generate. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 11078 [details] [review] [SIGNED-OFF] Bug 8434 - Notice generation fails for Advanced Notices, Item Due, and Overdues when run in shell (due to error in Letters.pm) QA Comments: The patch fixes the error if getletter is called by a command line script. (This one fixes a bad indentation) Marking as Passed QA
Patch pushed, severity updated to "normal" instead of ENH
Pushed to 3.8.x, will be in 3.8.4