检测到Moodle编码错误


Moodle coding error detected

我的moodle给了我这个错误:检测到编码错误,必须由程序员修复:传递给moodle_page::set_state的无效状态。我们处于状态0,请求状态3。

我在谷歌上搜索了一下,但找不到这个错误的确切解决方案。我自己以前从未遇到过。如果您需要任何关于代码或文件的额外信息,请务必告诉我。

如果调用了$OUTPUT->footer(),但未调用$OUTPUT->header(),则可能发生这种情况。页面应处于以下状态之一:

/** The state of the page before it has printed the header **/
const STATE_BEFORE_HEADER = 0;
/** The state the page is in temporarily while the header is being printed **/
const STATE_PRINTING_HEADER = 1;
/** The state the page is in while content is presumably being printed **/
const STATE_IN_BODY = 2;
/**
 * The state the page is when the footer has been printed and its function is
 * complete.
 */
const STATE_DONE = 3;

可能是一些自定义代码。将调试切换到开发人员级别以查找位置。在config.php中添加

$CFG->debug = E_ALL | E_STRICT;
$CFG->debugdisplay = true;