[Bug 23723] New: using exit to stop sending output to browser doesn't work under plack
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Bug ID: 23723 Summary: using exit to stop sending output to browser doesn't work under plack Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: critical Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: dpavlin@rot13.org QA Contact: testopia@bugs.koha-community.org When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. It seems that using just exit isn't enough to stop plack from generating headers and html page. This was noticed back in 2011 with Bug 5630 which added safe_exit in C4::Auth. It seems that we need to use something similar throughout all code which gets invoked with plack to fix this. I'm opening this bug as placeholder until I do more testing and figure out which parts need change and we have a lot of exit; in code: git grep 'exit;' | wc -l 352 -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=23589 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=5630 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #1 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Problem occurs only if we use exit inside eval block like: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval". Bacause of interaction of CGI::Compile which wraps system exit under plack we get both lines. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|using exit to stop sending |using exit inside eval to |output to browser doesn't |stop sending output to |work under plack |browser doesn't work under | |plack -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Theodoros Theodoropoulos <theod@lib.auth.gr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |theod@lib.auth.gr -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #2 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Created attachment 93527 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93527&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |dpavlin@rot13.org |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #3 from Dobrica Pavlinusic <dpavlin@rot13.org> --- I did check all places in code where we use eval and it seems that only place where we have also exit is this one, so situation is not as bad as I though initially. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Brendan Gallagher <brendan@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Brendan Gallagher <brendan@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #93527|0 |1 is obsolete| | --- Comment #4 from Brendan Gallagher <brendan@bywatersolutions.com> --- Created attachment 93541 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93541&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #5 from Theodoros Theodoropoulos <theod@lib.auth.gr> --- Dobrica, in the patch you submitted, you tackle the issue only in opac-discharge.pl The same code exists also in discharge.pl (where it was originally discovered). Please include the fix for that as well in your patch in order to sign it off. Thanks in advance! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Theodoros Theodoropoulos <theod@lib.auth.gr> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #93541|0 |1 is obsolete| | --- Comment #6 from Theodoros Theodoropoulos <theod@lib.auth.gr> --- Created attachment 93551 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93551&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack Also fixes ./src/members/discharge.pl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Theodoros Theodoropoulos <theod@lib.auth.gr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff --- Comment #7 from Theodoros Theodoropoulos <theod@lib.auth.gr> --- Extending the patch was trivial, so I gave it a go myself. Please check if it works for you too (it worked for me). Brendan, I'm changing status to "Needs Sign Off" (the original patch indeed tackled the problem, but not in all places). [I'm not a senior koha dev (like most of you), so please forgive me if I did something wrong. Full credits for identifying the real cause and fixing the problem go to Dobrica!] -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #93551|0 |1 is obsolete| | --- Comment #8 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Created attachment 93552 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93552&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. Current status: Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #9 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Patch should include also commit message, so I replaced it with full version which you can now sign-off :-) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 ByWater Sandboxes <bws.sandboxes@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #93552|0 |1 is obsolete| | --- Comment #10 from ByWater Sandboxes <bws.sandboxes@gmail.com> --- Created attachment 93556 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93556&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. Signed-off-by: Theodoros Theodoropoulos <theod@lib.auth.gr> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Theodoros Theodoropoulos <theod@lib.auth.gr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #11 from Theodoros Theodoropoulos <theod@lib.auth.gr> --- I used ByWater Solutions' sandboxes because they seem to use Plack (required for the bug to appear). Seems to work OK, but QA may complain that there is no test plan for the patch. Because the bug relates only to code found in discharges, I would propose something like: 1/ make sure Plack is used in the system 2/ go to System Preferences and set useDischarge: Allow 3/ create a patron (or select a patron) and go to discharges -> generate discharge 4/ the produced file is not a proper PDF as is contains headers and html code in the end 5/ Apply patch (restart starman/apache ?) 6/ go to discharges-> generate discharge 7/ the bug is fixed and produced file is proper PDF (Something similar could be described for opac-discharge) ByWater Solutions' sandbox sign-off procedure did not change the status to Signed off... Doing it manually. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de --- Comment #12 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Thx Dobrica (missing you here in Marseille) and Theodoros! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|using exit inside eval to |Using exit inside eval to |stop sending output to |stop sending output to the |browser doesn't work under |browser doesn't work under |plack |Plack -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I must be missing something - because my PDF look great without the patch :( -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #93556|0 |1 is obsolete| | --- Comment #14 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 93580 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=93580&action=edit Bug 23723: using exit inside eval to stop sending output to browser doesn't work under plack When fixing Bug 23589 Theodoros Theodoropoulos noticed that we are sending headers and html after pdf output to browser. Using exit inside eval block doesn't stop plack from generating headers and html page after exit since CGI::Compile will catch exit but doesn't stop emiting output. Example is: eval { warn "in eval"; exit; }; warn "after eval"; Under CGI, this would print just "in eval", but under plack we get both lines and thus generate additional header and html after we already sent pdf data. Signed-off-by: Theodoros Theodoropoulos <theod@lib.auth.gr> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #15 from Theodoros Theodoropoulos <theod@lib.auth.gr> --- Katrin, try to open it in Notepad++ or vi (or another editor). You will see the headers and html at the end of the file. With the patch, the resulting file has no such garbage and it has 1/3 of the size In 18.11 (and earlier versions) the resulting file was not even readable by a PDF reader. For some reason in master the added garbage do not invalidate the produced PDF. Maybe has to do with some perl module update? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |19.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 --- Comment #16 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work! Pushed to master for 19.11.00 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23723 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m Version(s)|19.11.00 |19.11.00,19.05.05 released in| | Status|Pushed to master |Pushed to stable --- Comment #17 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Pushed to 19.05.x for 19.05.05 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org