这个$lastcron变量的计算是否正确



请参考以下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((语句是否应该使用$lastcron$lastcron在if((语句的开头?换句话说,它应该是:

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

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

你是对的,对我来说就像一个bug。

如果记录不存在,则$DB->get_field()返回false;如果记录确实存在,则返回值。

在这种情况下,lastcroninteger

可能应该是or

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

最新更新