<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Segoe UI Symbol";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Totally agree too. Also makes unit testing a million times easier. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>David Cook<o:p></o:p></p><p class=MsoNormal>Systems Librarian<o:p></o:p></p><p class=MsoNormal>Prosentient Systems<o:p></o:p></p><p class=MsoNormal>72/330 Wattle St<o:p></o:p></p><p class=MsoNormal>Ultimo, NSW 2007<o:p></o:p></p><p class=MsoNormal>Australia<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Office: 02 9212 0899<o:p></o:p></p><p class=MsoNormal>Direct: 02 8005 0595<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> Koha-devel <koha-devel-bounces@lists.koha-community.org> <b>On Behalf Of </b>Renvoize, Martin<br><b>Sent:</b> Saturday, 28 September 2019 3:14 AM<br><b>To:</b> Tomas Cohen Arazi <tomascohen@gmail.com><br><b>Cc:</b> koha-devel <koha-devel@lists.koha-community.org><br><b>Subject:</b> Re: [Koha-devel] A case against some uses of C4::Context->userenv<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I generally agree here,  I'd rather explicitly pass things like this into objects on instantiation and die if they're not present.. that way we catch cases of missing environments early and as you state, userenv harks back the CGI days and we should generally be moving forward and away from those patterns in my opinion.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><br clear=all><o:p></o:p></p><div><div><div><div><div><div><div><div><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=410 style='width:307.5pt'><tr><td style='padding:0cm 0cm 0cm 0cm'></td></tr></table><p class=MsoNormal><span style='display:none'><o:p> </o:p></span></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=450 style='width:337.5pt'><tr><td width=300 style='width:225.0pt;padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Martin Renvoize</span></strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'><o:p></o:p></span></p></td><td style='border:none;border-bottom:none black 1.0pt;padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><a href="https://www.ptfs-europe.com/" target="_blank"><span style='font-family:"Times New Roman",serif;text-decoration:none'><img border=0 width=175 height=26 style='width:1.8229in;height:.2708in' id="_x0000_i1025" src="https://www.ptfs-europe.com/wp-content/uploads/2018/10/ptfs-logo-full-email-sig.png"></span></a><span style='font-family:"Times New Roman",serif'><o:p></o:p></span></p></td></tr><tr><td colspan=2 style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Development Team Manager<o:p></o:p></span></p></td></tr><tr><td colspan=2 style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-family:"Arial",sans-serif'> <o:p></o:p></span></p></td></tr><tr><td colspan=2 style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-family:"Arial",sans-serif'> <o:p></o:p></span></p></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Phone:</span></strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'> +44 (0) 1483 378728<o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Mobile:</span></strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'> +44 (0) 7725 985 636<o:p></o:p></span></p></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Email:</span></strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'> <a href="mailto:martin.renvoize@ptfs-europe.com" target="_blank"><span style='color:#2D5C88'>martin.renvoize@ptfs-europe.com</span></a><o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Fax:</span></strong><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'> +44 (0) 800 756 6384<o:p></o:p></span></p></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'></td><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt;line-height:15.0pt'><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'><a href="https://www.ptfs-europe.com" target="_blank"><span style='color:#2D5C88'>www.ptfs-europe.com</span></a><o:p></o:p></span></p></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-family:"Arial",sans-serif'> <o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-family:"Arial",sans-serif'> <o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-family:"Arial",sans-serif'> <o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'></td></tr></table><p class=MsoNormal><span style='display:none'><o:p> </o:p></span></p><table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 style='border:none;border-top:solid #C2C2C2 1.0pt'><tr><td style='border:none;padding:15.0pt 0cm 0cm 0cm'><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Times New Roman",serif'><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#2D5C88'>The information contained in this email message may be privileged, confidential and protected from disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this email message in error, please email the sender at <a href="mailto:info@ptfs-europe.com" target="_blank">info@ptfs-europe.com</a><o:p></o:p></span></p></td></tr></table><p class=MsoNormal><o:p> </o:p></p></div></div></div></div></div></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Fri, 27 Sep 2019 at 17:42, Tomas Cohen Arazi <<a href="mailto:tomascohen@gmail.com">tomascohen@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><p class=MsoNormal>Hi all, I've been looking at the 'Claims returned' work (awesome!) [1] and I've noticed a pattern we should, in my opinion, start avoiding and reverting.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It is quite common to find uses of C4::Context->userenv in the Koha::* namespace, either as a plain requirement (if the borrowernumber is not set we bail out) or just as a fallback. I think it is wrong to expect such environment status in our logic. It complicates things in various ways. [2]<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It is done this way because:<o:p></o:p></p></div><div><p class=MsoNormal>- We come from the CGI era, in which it made perfect sense<o:p></o:p></p></div><div><p class=MsoNormal>- Cookie auth is well established on the UI<o:p></o:p></p></div><div><p class=MsoNormal>- When migrating from C4:* into Koha:* it is easier to just keep the current behavior and then evolve.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I propose we leave them out, and add as a parameter whatever we are expecting to find in the userenv hashref. That way we could use this new libs in the API (which is not cookie-only).<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Looking forward to hear your opinions <o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>[1] <a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14697" target="_blank">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14697</a><o:p></o:p></p></div><div><p class=MsoNormal>[2] CLI scripts are using Koha::* libraries, and we then need to 'emulate' that userenv or even add code to detect we don't have a userenv.<br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>-- <o:p></o:p></p><div><div><div><div><div><p class=MsoNormal><span style='font-size:9.5pt'>Tomás Cohen Arazi<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:9.5pt'>Theke Solutions (<a href="http://theke.io/" target="_blank">http://theke.io</a>)<br></span><span style='font-size:9.5pt;font-family:"Segoe UI Symbol",sans-serif'>✆</span><span style='font-size:9.5pt'> +54 9351 3513384<br>GPG: B2F3C15F<o:p></o:p></span></p></div></div></div></div></div></div></div></div><p class=MsoNormal>_______________________________________________<br>Koha-devel mailing list<br><a href="mailto:Koha-devel@lists.koha-community.org" target="_blank">Koha-devel@lists.koha-community.org</a><br><a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>website : <a href="http://www.koha-community.org/" target="_blank">http://www.koha-community.org/</a><br>git : <a href="http://git.koha-community.org/" target="_blank">http://git.koha-community.org/</a><br>bugs : <a href="http://bugs.koha-community.org/" target="_blank">http://bugs.koha-community.org/</a><o:p></o:p></p></blockquote></div></div></body></html>