<div dir="ltr">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.<div><br></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><table cellspacing="0" cellpadding="0" width="410" style="font-family:"Times New Roman""><tbody><tr><td colspan="2"><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"></p></td></tr></tbody></table><table cellspacing="0" cellpadding="0" width="450" style="font-family:"Times New Roman""><colgroup><col width="99"><col><col></colgroup><tbody><tr><td width="300"><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Martin Renvoize</strong></p></td><td rowspan="2"><p style="line-height:20px;margin:0px"><a href="https://www.ptfs-europe.com" border="0" target="_blank"><img src="https://www.ptfs-europe.com/wp-content/uploads/2018/10/ptfs-logo-full-email-sig.png" width="" height="" border="0"></a></p></td></tr><tr><td colspan="2"><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)">Development Team Manager</p></td></tr><tr><td colspan="2"><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td colspan="2"><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Phone:</strong> +44 (0) 1483 378728</p></td><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Mobile:</strong> +44 (0) 7725 985 636</p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Email:</strong> <a href="mailto:martin.renvoize@ptfs-europe.com" style="color:rgb(45,92,136)" target="_blank">martin.renvoize@ptfs-europe.com</a><br></p></td><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Fax:</strong> +44 (0) 800 756 6384</p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><br></p></td><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><a href="https://www.ptfs-europe.com" style="color:rgb(45,92,136)" target="_blank">www.ptfs-europe.com</a></p></td></tr><tr><td><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td><p style="font-family:Arial;margin:0px"> </p></td></tr></tbody></table><table cellspacing="0" cellpadding="0" style="font-family:"Times New Roman";border-top:1px solid rgb(194,194,194);padding:20px 0px 0px;margin:0px"><tbody><tr><td><p style="font-family:Arial;font-size:12px;color:rgb(45,92,136);margin:0px">Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30</p><br><p style="font-family:Arial;font-size:12px;color:rgb(45,92,136);margin:0px">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></p></td></tr></tbody></table><span style="font-size:12.8px"><br></span></div></div><div dir="ltr"></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 27 Sep 2019 at 17:42, Tomas Cohen Arazi <<a href="mailto:tomascohen@gmail.com">tomascohen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">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.<div><br></div><div>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]</div><div><br></div><div>It is done this way because:</div><div>- We come from the CGI era, in which it made perfect sense</div><div>- Cookie auth is well established on the UI</div><div>- When migrating from C4:* into Koha:* it is easier to just keep the current behavior and then evolve.</div><div><br></div><div>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).</div><div><br></div><div>Looking forward to hear your opinions <br><div><br></div><div>[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></div><div>[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"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div style="font-size:12.8px">Tomás Cohen Arazi</div><div style="font-size:12.8px">Theke Solutions (<a href="http://theke.io/" target="_blank">http://theke.io</a>)<br>✆ +54 9351 3513384<br>GPG: B2F3C15F</div></div></div></div></div></div></div></div>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.org/</a><br>
</blockquote></div>