ChangeSet state preventing data from being published?

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

Silverstripe Version: 4.7.3

Question:

I am not sure if this behaviour is expected or not or if I am missing something.

When an extension adds an extra field to a Page dataobject, and the data for the field is gotten programmatically (i.e. not manually entered by the user), the data is not saved to the Live table only the Staged table. Unless some other piece of data for the Page (e.g. Title) is manually modified then the extended field gets published as expected.

I have added a simple page extension to test this behaviour. On publish the field Test does not get updated in the Live table, but the Staged table gets updated.

Can anyone explain the process to me or shed some light on what I am doing wrong?

UPDATE: I notice this is only happening on extensions applied to a Page object. On a versioned dataobject the programmatically updated field gets published.

use SilverStripe\ORM\DataExtension;

class PageExtension extends DataExtension {
    private static $db = [
        'Test' => 'Varchar'
    ];


    public function onBeforeWrite()
    {
	$this->owner->Test = time();
        parent::onBeforeWrite();
			
    }
	
}

Looks like an issue in SiteTree onBeforeWrite() to do with checking for changes.

I have opened an issue: Programmatically added data is not published unless manual edit is made · Issue #2646 · silverstripe/silverstripe-cms · GitHub

1 Like