If you look through C4::Templates and C4::Languages, you'll see CGI objects being passed around a lot. In the end, all that C4::Templates::gettemplate() and C4::Languages::getlanguage need are the "language" param and the "KohaOpacLanguage" cookie. We should be fetching these appropriately from the CGI or PSGI or whatever context at a higher level and passing back the data rather than the objects.
We could also remove the following warnings since they're not actually useful: [2020/12/22 07:00:36] [WARN] no query in gettemplate at /kohadevbox/koha/C4/Templates.pm line 206. [2020/12/22 07:00:36] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266.