mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #20101
[Bug 1318995] Re: File import of zipped PDF does not detect filetype correctly
Hello Robert,
Can you please backport this to 1.9?
Thank you
Kristina
** Also affects: mahara/1.9
Importance: Undecided
Status: New
** Changed in: mahara/1.9
Importance: Undecided => Medium
** Changed in: mahara/1.9
Status: New => Confirmed
** Changed in: mahara/1.9
Assignee: (unassigned) => Robert Lyon (robertl-9)
** Changed in: mahara/1.9
Milestone: None => 1.9.3
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1318995
Title:
File import of zipped PDF does not detect filetype correctly
Status in Mahara ePortfolio:
Fix Committed
Status in Mahara 1.9 series:
Confirmed
Bug description:
In Mahara 1.9.0
After building a portfolio export button for the Moodle certificate
module using MNet, I found that the PDF file was getting saved with
the mimetype set to application/x-director. This turned out to be
because the import process does not correctly pass through the file
extension.
In import/file/lib.php, around line 108 in the add_artefacts()
function is a call to ArtefactTypeFile::save_file(). The $data does
not include and $oldextension attribute, but this is expected later on
around line 947 of artefact/file/lib.php in the new_file() function.
The following line throws an error:
$data->guess = file_mime_type($path, "foo.{$data->oldextension}");
And then file_mime_type() fails because it doesn't know what the
extension is.
To fix it, the following chunk of code works nicely:
if (isset($data->oldextension)) {
$originalfilename = "foo.{$data->oldextension}";
} else {
$originalfilename = false;
}
$data->guess = file_mime_type($path, $originalfilename);
This causes the original filename to be read from the file object.
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1318995/+subscriptions
References