おお,ビンゴですね.良かった.
さて,問題のエラーですが,moodle/question/inport_fomat.phpのfunction validate_updloaded_file()の
$errors['newfile'] = get_string('importwrongfiletype', 'question', $a);
ここで発生していますね.条件は,(!$qformat->can_import_file($file)) で,これはmoodle/question/fomat.phpの
public function can_import_file($file) {
return ($file->get_mimetype() == $this->mime_type());
}
これです.function get_mimetype()は,うーん,追跡が困難ですが,多分,moodle/lib/filestorage/file_storage.phpの
public static function mimetype($pathname, $filename = null) {
if (empty($filename)) {
$filename = $pathname;
}
$type = mimeinfo('type', $filename);
if ($type === 'document/unknown' && class_exists('finfo') && file_exists($pathname)) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
$type = mimeinfo_from_type('type', $finfo->file($pathname));
}
return $type;
}
ですね.太字の部分,function mimeinfo()は,moodle/lib/filelib.phpの中にあります.うーん,拡張子で判断しているようですね.
var_dump($filename);
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if (empty($filetype)) {
$filetype = 'xxx'; // file without extension
}
var_dump($filetype);
とトラップを仕掛けると,インポートする際にここを二回通っていますね.一度目は$filenameが「ファイル名.gift」で$filetypeが「gift」,二度目が「.txt」と「txt」.その後に$mimeinfo[$filetype][$element]をチェックすると,一度目がNULLで二度目が「text/plain」.ファイル名だけではダメで,function mimetype()の中の
$finfo = new finfo(FILEINFO_MIME_TYPE);
$type = mimeinfo_from_type('type', $finfo->file($pathname));
で調べ直しているようですね.このコードが実行されるのは,class_exists('finfo')がtrueの時なので,dllが読み込まれていない場合はエラーを起こさずにdocument/unknownのまま抜けてしまいますね.したがってIISのエラーログにはdllが無効だという記録は残らないと思います.