Patch for "1.8_STABLE" branch: https://reviews.mahara.org/3651

-- 
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.7 series:
  New
Status in Mahara 1.8 series:
  New
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

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to