?stage=Stage injected into page link

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe Version: : 4


I wonder when Silverstripe will inject stage=Stage at the page URL.

I have a script to send out email with ss template which contains


I then have a cron job to run this via cli-php to send out the email.

But when user receive the email, the links become

The website is in ‘live’ mode.

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');

The cron job looks like this

/usr/bin/php /home/username/public_html/vendor/silverstripe/framework/cli-script.php /dev/tasks/sendEmail

SendEmail is a sub class of SilverStripe\Dev\BuildTask

I wonder why i need to set Stage to live in a sub class of BuildTask ?

BuildTask defaults to the “Stage” stage. So any DataObject you query there will be returned in the Draft stage.

I think only children of ContentController will default to the Live stage.

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 see. it will be nice for BuildTask to respect the

and automatically switch to live stage

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.