There is no such concept as "Web Request" and "Session" or even "User is Logged In" concepts when In-Portal is executed from CLI (command-line). Yet the corresponding access methods for objects representing these concepts (GetVar, SetVar, RecallVar, StoreVar) still work and are used in In-Portal.
Solution
I propose, that we:
- sub-class the kApplication class and use that sub-class instead of kApplication class from CLI
- find usages of above mentioned methods, that at least make some sense in CLI
- extract those particular usages into methods on kApplication class
- change extracted methods in the CLI kApplication class version to return sane values
Concept | In Web Request | In CLI |
---|---|---|
logged-in user id | $this->Application->RecallVar('user_id') |
|
is ajax request | $this->Application->GetVar('ajax') == 'yes' |
|
current language id | $this->Application->GetVar('m_lang') |
|
current theme id | $this->Application->GetVar('m_theme') |
|
automatic object loading by ID in url | code inside "kDBEventHandler::StoreSelectedIDs" method |
|
getting current site domain field | $this->Application->siteDomainField('FieldName') |
|
current session id | $this->Application->GetSID() |
|
main popup window identifier | $this->Application->GetTopmostWid() |
|
popup window identifier | $this->Application->GetVar('m_wid') |
|
is current user logged-in | $this->Application->LoggedIn() |
|
website visitor IP address | $this->Application->getClientIP() |
|
attempt to read/write web request data |
| |
attempt to read/write session data |
|
|
attempt to read/write session data | other methods |
|
Even though most of methods mentioned makes no sense in CLI they still return value that makes sense to avoid changing every call site.