[Koha-devel] A case against some uses of C4::Context->userenv

Marcel de Rooy M.de.Rooy at rijksmuseum.nl
Sat Sep 28 10:29:17 CEST 2019


Sounds good to me. But as you know, refactoring a large codebase is a tedious process.

________________________________

 
 

​Museumstraat 1
Postbus 74888
1070 DN Amsterdam
Rijksmuseum.nl
​
​Nu te zien:
​​12x Erwin Olaf
​Louise Bourgeois in de Rijksmuseumtuinen
​Operatie Nachtwacht
​
​T/m 18 jaar gratis
  
 Please think before you print
Van: Koha-devel <koha-devel-bounces at lists.koha-community.org> namens Renvoize, Martin <martin.renvoize at ptfs-europe.com>
Verzonden: vrijdag 27 september 2019 19:13
Aan: Tomas Cohen Arazi <tomascohen at gmail.com>
CC: koha-devel <koha-devel at lists.koha-community.org>
Onderwerp: Re: [Koha-devel] A case against some uses of C4::Context->userenv

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.



Martin Renvoize

[https://www.ptfs-europe.com/wp-content/uploads/2018/10/ptfs-logo-full-email-sig.png]<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ptfs-europe.com&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606694897&sdata=qo0dpMjlegzzDhLI4meNlpDyStDamMNZeqx2GeArI%2Fo%3D&reserved=0>

Development Team Manager





Phone: +44 (0) 1483 378728

Mobile: +44 (0) 7725 985 636

Email: martin.renvoize at ptfs-europe.com<mailto:martin.renvoize at ptfs-europe.com>

Fax: +44 (0) 800 756 6384


www.ptfs-europe.com<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ptfs-europe.com&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606694897&sdata=qo0dpMjlegzzDhLI4meNlpDyStDamMNZeqx2GeArI%2Fo%3D&reserved=0>







Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30


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 info at ptfs-europe.com<mailto:info at ptfs-europe.com>



On Fri, 27 Sep 2019 at 17:42, Tomas Cohen Arazi <tomascohen at gmail.com<mailto:tomascohen at gmail.com>> wrote:
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.

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]

It is done this way because:
- We come from the CGI era, in which it made perfect sense
- Cookie auth is well established on the UI
- When migrating from C4:* into Koha:* it is easier to just keep the current behavior and then evolve.

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).

Looking forward to hear your opinions

[1] https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14697<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.koha-community.org%2Fbugzilla3%2Fshow_bug.cgi%3Fid%3D14697&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606704891&sdata=pEj0U2nGAHpCTqEQNur9R8XCRcxdggKALtPmohPjd2c%3D&reserved=0>
[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.

--
Tomás Cohen Arazi
Theke Solutions (http://theke.io<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftheke.io%2F&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606704891&sdata=rJ7Wq1rK256YA6BTdSophwfAQOYL%2FEd2qrBSu4LdrjM%3D&reserved=0>)
✆ +54 9351 3513384
GPG: B2F3C15F
_______________________________________________
Koha-devel mailing list
Koha-devel at lists.koha-community.org<mailto:Koha-devel at lists.koha-community.org>
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.koha-community.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fkoha-devel&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606714888&sdata=MSCs0c6X61QWoRbeQQDmIgYfkt1wMhj2CVDIERhlJ%2BY%3D&reserved=0>
website : http://www.koha-community.org/<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.koha-community.org%2F&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606714888&sdata=Ysg8%2F7hSlFWQxBXKOEIaVPQehnFiW4tTzs%2FR2613YPY%3D&reserved=0>
git : http://git.koha-community.org/<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.koha-community.org%2F&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606724882&sdata=P%2Fr5B5nQI7tlAw2CyWeDR9Yq2KU%2Fmvd8UMmP7D5jbU4%3D&reserved=0>
bugs : http://bugs.koha-community.org/<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbugs.koha-community.org%2F&data=02%7C01%7Cm.de.rooy%40rijksmuseum.nl%7C048e6e0d082f4f8a8ae608d7436e21f6%7C635b05eb66c748e1a94fb4b05a1b058b%7C0%7C0%7C637052012606724882&sdata=hH4KAhh61qM6lGWmuqvQfhPhiAEoJIQBmVieS%2BrfSR8%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20190928/a185606e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image466886.png
Type: image/png
Size: 2974 bytes
Desc: image466886.png
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20190928/a185606e/attachment-0001.png>


More information about the Koha-devel mailing list