mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #16521
[Bug 1270110] Re: Unable to add new user from uploaded Leap2A file
Hi David,
Inspecting the file extension is actually step #2 on my list of steps to
take to fix that bug. :) That's what Moodle does, it has an array of
file extensions which it maps to mime types.
The only thing better than that approach, is to use the Magic database (
http://www.magicdb.org/ ), which can actually inspect the file's
contents and make a more informed decision about its format. That's what
the PHP fileinfo extension does, but there's currently some issues that
are preventing that from working properly.
Ultimately what I want to do is have a series of fallbacks, where we try
fileinfo first, then if that doesn't work we try the Moodle mimetype
array, and then if that doesn't work, we call it a generic "application
/octet-stream".
--
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/1270110
Title:
Unable to add new user from uploaded Leap2A file
Status in Mahara ePortfolio:
Confirmed
Bug description:
I am experiencing same problems as reported in (now closed) bug
#746079
* I have exported all my portfolio at mahara.org and have the ZIP file
* When trying to create new user at my local mahara installation (mahara 1.8.2testing, commit hash 67d9f6), the import fails with the following error
=========================
[WAR] c2 (import/leap/lib.php:126) simplexml_load_file(): /path/to/maharadata/mahara18/temp/import/username-1389955022/extract/mahara_org_username.leap.zip:1: parser error : Start tag expected, '<' not found
Call stack (most recent first):
log_message("simplexml_load_file(): /path/to/maharadata/m...", 8, true, true, "/path/to/the/mahara18/htdocs/import/...", 126) at /path/to/the/mahara18/htdocs/lib/errors.php:430
error(2, "simplexml_load_file(): /path/to/maharadata/m...", "/path/to/the/mahara18/htdocs/import/...", 126, array(size 2)) at Unknown:0
simplexml_load_file("/path/to/maharadata/mahara18/temp/import/mud...", "SimpleXMLElement", 67584) at /path/to/the/mahara18/htdocs/import/leap/lib.php:126
PluginImportLeap->read_leap2a_xml_file() at /path/to/the/mahara18/htdocs/import/leap/lib.php:147
PluginImportLeap->build_default_load_mapping() at /path/to/the/mahara18/htdocs/import/leap/lib.php:158
PluginImportLeap->process() at /path/to/the/mahara18/htdocs/admin/users/add.php:329
adduser_submit(object(Pieform), array(size 21)) at Unknown:0
call_user_func_array("adduser_submit", array(size 2)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:528
Pieform->__construct(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:170
Pieform::process(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 7)) at /path/to/the/mahara18/htdocs/admin/users/add.php:148
[WAR] c2 (import/leap/lib.php:126) simplexml_load_file(): PK
Call stack (most recent first):
log_message("simplexml_load_file(): PK", 8, true, true, "/path/to/the/mahara18/htdocs/import/...", 126) at /path/to/the/mahara18/htdocs/lib/errors.php:430
error(2, "simplexml_load_file(): PK", "/path/to/the/mahara18/htdocs/import/...", 126, array(size 2)) at Unknown:0
simplexml_load_file("/path/to/maharadata/mahara18/temp/import/mud...", "SimpleXMLElement", 67584) at /path/to/the/mahara18/htdocs/import/leap/lib.php:126
PluginImportLeap->read_leap2a_xml_file() at /path/to/the/mahara18/htdocs/import/leap/lib.php:147
PluginImportLeap->build_default_load_mapping() at /path/to/the/mahara18/htdocs/import/leap/lib.php:158
PluginImportLeap->process() at /path/to/the/mahara18/htdocs/admin/users/add.php:329
adduser_submit(object(Pieform), array(size 21)) at Unknown:0
call_user_func_array("adduser_submit", array(size 2)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:528
Pieform->__construct(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:170
Pieform::process(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 7)) at /path/to/the/mahara18/htdocs/admin/users/add.php:148
[WAR] c2 (import/leap/lib.php:126) simplexml_load_file(): ^
Call stack (most recent first):
log_message("simplexml_load_file(): ^", 8, true, true, "/path/to/the/mahara18/htdocs/import/...", 126) at /path/to/the/mahara18/htdocs/lib/errors.php:430
error(2, "simplexml_load_file(): ^", "/path/to/the/mahara18/htdocs/import/...", 126, array(size 2)) at Unknown:0
simplexml_load_file("/path/to/maharadata/mahara18/temp/import/mud...", "SimpleXMLElement", 67584) at /path/to/the/mahara18/htdocs/import/leap/lib.php:126
PluginImportLeap->read_leap2a_xml_file() at /path/to/the/mahara18/htdocs/import/leap/lib.php:147
PluginImportLeap->build_default_load_mapping() at /path/to/the/mahara18/htdocs/import/leap/lib.php:158
PluginImportLeap->process() at /path/to/the/mahara18/htdocs/admin/users/add.php:329
adduser_submit(object(Pieform), array(size 21)) at Unknown:0
call_user_func_array("adduser_submit", array(size 2)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:528
Pieform->__construct(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:170
Pieform::process(array(size 7)) at /path/to/the/mahara18/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 7)) at /path/to/the/mahara18/htdocs/admin/users/add.php:148
[INF] c2 (admin/users/add.php:333) Leap2A import failed: FATAL: XML
file is not well formed! Please consult Mahara's error log for more
information
Sorry - Importing the Leap2A file failed.
This could be because you did not select a valid Leap2A file to upload
or because the version of your Leap2A file is not supported by this
Mahara version. Alternatively, there may be a bug in Mahara causing
your file to fail, even though it is valid.
Please go back and try again, and if the problem persists, you may want to post to the Mahara Forums to ask for help. Be prepared to be asked for a copy of your file.
=========================
It seems that Mahara did not extract the ZIP file and fails because it
expects XML then. Creating a new user works if I upload plain
leap2a.xml, but without the files of course.
I did some research and the problem seems to be in import/lib.php
file, ImporterTransport::extract_file(). At one moment, the code is
checking for the uploaded file's mimetype and decides if it is ZIP or
not. For me, the reported mimetype is "application/x-forcedownload".
So it does not match any of "application/zip", "application/x-zip",
"application/zip-compressed" and "application/x-zip-compressed" and
the file is not considered a valid ZIP file. The code simple moves it
into the /extract folder which explains the rest of the issue.
Experienced at Gentoo Linux, PHP 5.5.4-pl0-gentoo
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1270110/+subscriptions
References