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
$query
->addWhere(array(
"\"{$myclass}\".\"Embargo\" IS NULL OR \"{$myclass}\".\"Embargo\" < NOW()",
"\"{$myclass}\".\"Expiry\" IS NULL OR \"{$myclass}\".\"Expiry\" > NOW()",
));
}
}
}