Your cron job probably defaults to running in the draft stage. Maybe try making this call at the start of your cron job Versioned::set_reading_mode('Stage.Live');
Interesting. Does it mean that I need to set the Stage in my sub class of BuildTask? Saying that, I check the ‘BuildTask’ class source code and i don’t see codes that set the Stage to ‘Stage’.
Is it because it’s set somewhere else? It’s not logical that BuildTask set the stage to ‘Stage’. What’re the benefits?
I think it’s more that Stage is always the default, but ContentController switches it to Live.
Well the ‘Stage’ stage gives you the most up to date version of your dataobjects. That’s usually what I want to work with when I’m doing things programatically.
SS_ENVIRONMENT_TYPE is unrelated to versioning. Basically, the environment type control things like whether the errors are outputted to the browser or not.
SS_ENVIRONMENT_TYPE except its value to be live, test or dev.