/** * Return an array of conditions depending of options set in $opts * * @param FormOptions $opts * @return array */ public function buildMainQueryConds(FormOptions $opts) { $dbr = $this->getDB(); $conds = parent::buildMainQueryConds($opts); // Calculate cutoff if ($opts['days'] > 0) { $conds[] = 'rc_timestamp > ' . $dbr->addQuotes($dbr->timestamp(time() - intval($opts['days'] * 86400))); } return $conds; }
/** * Return an array of conditions depending of options set in $opts * * @param FormOptions $opts * @return array */ public function buildMainQueryConds(FormOptions $opts) { $dbr = $this->getDB(); $conds = parent::buildMainQueryConds($opts); // Calculate cutoff $cutoff_unixtime = time() - $opts['days'] * 86400; $cutoff_unixtime = $cutoff_unixtime - $cutoff_unixtime % 86400; $cutoff = $dbr->timestamp($cutoff_unixtime); $fromValid = preg_match('/^[0-9]{14}$/', $opts['from']); if ($fromValid && $opts['from'] > wfTimestamp(TS_MW, $cutoff)) { $cutoff = $dbr->timestamp($opts['from']); } else { $opts->reset('from'); } $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes($cutoff); return $conds; }