【问题标题】:How to fix "Exception - Call to a member function customdata() on null" error?如何修复“异常 - 在 null 上调用成员函数 customdata()”错误?
【发布时间】:2019-06-08 13:10:45
【问题描述】:

我正在将 PDF 查看器导入 Moodle 以在线查看 PDF 文件而无需下载。当我尝试保存上传的文件时,会出现此错误代码Exception - Call to a member function customdata() on null

我该如何解决这个问题?

function pdfjsfolder_cm_info_dynamic(cm_info $cm) {
// The field 'customdata' is filled in only if folder is to be
// shown inline.
if ($cm_info->customdata()) {
    $cm->set_no_view_link();
   }
}

/*** Overwrites the content in the course-module object with the folder files list
 * if folder.display == FOLDER_DISPLAY_INLINE.
 *
 * @param cm_info $cm
 */
function pdfjsfolder_cm_info_view(cm_info $cm) {
global $PAGE, $DB;

if ($cm->uservisible &&
        $cm_info->customdata() &&
        has_capability('mod/pdfjsfolder:view', $cm->context)) {
    require_once(dirname(__FILE__) . '/locallib.php');

【问题讨论】:

    标签: plugins moodle pdf.js moodle-api


    【解决方案1】:

    $cm_info 对象在“pdfjsfolder_cm_info_view”函数的范围内不可用,根据您上面提供的代码。

    将 $cm_info 替换为 $cm。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 2020-01-19
      • 2017-09-14
      • 2017-06-18
      • 1970-01-01
      相关资源
      最近更新 更多