Closed golenkovm closed 2 years ago
It seems like I faced a problem and a bit stuck.
When we run CLI scripts they call config.php
first which calls setup.php
. However, when after_config
is called $USER
is still empty. It gets populated later on this call: https://github.com/moodle/moodle/blob/a23f0bff3e1f386ceeb686e1d7ce28d8735769e0/admin/cli/adhoc_task.php#L123
But since there is no require_login()
call in CLI scripts tool_abconfig_after_require_login()
is not executed.
This makes applying experiments on CLI calls based on user id a bit tricky.
This seems a bit odd to me. CLI scripts either don't have a concept of a user, or they run effectively like sudo as the primary admin user.
If you are manually running a cli script and you want to force the condition of any arbitrary experiment then a better way of passing this in in a very generic way which enabled you to specify which experiment on the cli is using an environment var:
EXPERIMENT_SHORTNAME=conditionset php admin/cli/mycli.php --foo=bar
So this is exactly equivalent to doing ?experimentshortname=conditionset in a web request
Pretty well exactly like how this does it https://tracker.moodle.org/browse/MDL-67081
Yeah, you're right. Closing this as Won't fix
@golenkovm I am very happy for this to land using the env var way of turning it on, you could re-push that to this PR or are you going to make a new pr?
This is to implement #50