Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

augmentSQL seems to empty fields from object

Go to End



Community Member, 22 Posts

7 July 2014 at 8:51pm

I'm developing a simple module to provide 'soft' scheduling of pages (Embargo & Expire, I'm aware this is also provided by the workflow module). For this I wrote a SiteTreeExtension which adds Embargo & Expiry as Datetimefields.

I'm trying to implement augmentSQL on this in order to filter out pages that are under embargo/expiry. But any time I add an extra 'Where' clause to the augmentSQL method involving the Embargo or Expiry fields, the 'Embargo' and 'Expiry' fields of all resulting Pages appear unset. If I comment out the 'addWhere' lines, these fields load their data just fine.

Am I missing something?


class EmbargoExpirySchedulerExtension extends SiteTreeExtension {
	public static $db = array(
		'Embargo' => 'SS_Datetime', 
		'Expiry' => 'SS_Datetime'


	function augmentSQL(SQLQuery &$query) {
		$myclass = $this->owner->className;
		if (is_subclass_of(Controller::curr(), 'ContentController')) { // on frontend 
					"\"{$myclass}\".\"Embargo\" IS NULL OR \"{$myclass}\".\"Embargo\" < NOW()",
					"\"{$myclass}\".\"Expiry\" IS NULL OR \"{$myclass}\".\"Expiry\" > NOW()",