这个 $last cron 变量是否被正确评估?

Is this $lastcron variable being evaluated correcty?

请参考这段PHP代码: https://github.com/jleyva/moodle-block_configurablereports/blob/MOODLE_36_STABLE/block_configurable_reports.php#L182

第 182 行使用 $DB 对象从 sql 数据库中获取数据,然后将结果放入 $lastcron 变量中。

下一行像这样评估 $lastcron 变量:

    if (!$lastcron and ($lastcron + $this->cron < time()) )

请向我解释这段代码!

if() 语句是否应该在 if() 语句的开头使用 !$lastcron$lastcron?也就是说,应该是:

      if (!$lastcron and ($lastcron + $this->cron < time()) )

      if ($lastcron and ($lastcron + $this->cron < time()) )

你是对的,在我看来像是一个错误。

$DB->get_field() returns 如果记录不存在则为 false,如果存在则为值。

在这种情况下,integer 值为 lastcron

应该是or

if (!$lastcron || ($lastcron + $this->cron < time()) )