HTML file from Moodle is not transferred correctly

Bug #774684 reported by Kristina Hoeppner
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Low
Hugh Davenport

Bug Description

This was trialed on the iMoot2011 site at http://2011.imoot.org/ It is connected to a Mahara 1.2 installation. When a text assignment and forum post (both simple text) were saved as HTML file to be transferred to Mahara, the HTML files could not be chosen in the "Some HTML" block. When the files were saved on the desktop from Moodle and uploaded into Mahara manually, they were recognized correctly and displayed.

Would that be a Moodle or Mahara bug?

I attach one of the files, but as the problem is in the transfer, I am not sure how useful this is.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

I have not yet had the opportunity to check if this problem also exists when connecting Mahara 1.3/1.4 to Moodle 2. If somebody has this setup, it would be great if you tested it.

Revision history for this message
François Marier (fmarier) wrote :

Kristina, I have downloaded your file:

  wget https://bugs.launchpad.net/mahara/+bug/774684/+attachment/2102246/+files/assignment_downloaded.html

and uploaded into my local Mahara (master). From there, I was able to add it to a view (through the Some HTML block) without any problems.

Have you got any ideas on how we could reproduce this bug?

Changed in mahara:
status: New → Incomplete
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Hello Francois,

The test you did also worked for me. The problem occurred when we wanted to transfer the file from Moodle 2.0. So what would be needed is a Moodle 2.0 hooked up to Mahara via Mahoodle with the Portfolio API set up to allow Mahara to be a portfolio. Then a forum post or a simple text assignment could be created and saved to the Mahara portfolio as HTML file. The file gets transferred, but it could not be chosen in the HTML block. That's what needs to be tested.

It seems like I won't get my new computer until well into the month and my local install won't allow me to do Mahoodle. Inaki could not find the mistake. It's probably my VM that can't allocate enough RAM. Therefore, I can't test it myself there. I remember that we do have a test environment. I can try to use that and set up Mahoodle with master.dev. I'll report back.

Revision history for this message
François Marier (fmarier) wrote :

It sounds like the mimetype is not copied across with the file.

The question is: who's responsibility is it to set the right mimetype? The sender (Moodle) or the received (Mahara)?

Changed in mahara:
milestone: none → 1.4.0
importance: Undecided → Low
status: Incomplete → Triaged
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

This one *should* be fixed by the fix for bug #735884. But I think Mahara won't guess a mimetype if the sender adds one, so it's possible it still won't work if Moodle puts the wrong mimetype in the leap2a.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

OK. I linked one of our Moodle installs to master.dev (Richard and Francois: Let me know if I shall tell you which one). The Mahoodle guide worked perfectly (thank Inaki :-) ).

When I exported a forum post as HTML, it was not recognized by the HTML block. So I guess, Francois' suggestion with the mimetype is the likely one. When I used the Leap2A export, the forum post was exported as blog post and showed up in Mahara.

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

Right have set up a mahoodle with moodle 2.0.3 and mahara master (1.4.0alpha2dev)

Can confirm that if you export with html it won't set mimetype properly

if i export with leap, then get the following trace with no import

[Wed May 11 16:03:34 2011] [error] [client ::1] [WAR] 89 (import/leap/lib.php:1075) Undefined offset: 0
[Wed May 11 16:03:34 2011] [error] [client ::1] Call stack (most recent first):
[Wed May 11 16:03:34 2011] [error] [client ::1] * log_message("Undefined offset: 0", 8, true, true, "/home/hugh/src/mahara/mahara/htdocs/import/leap/li...", 1075) at /home/hugh/src/mahara/mahara/htdocs/lib/errors.php:446
[Wed May 11 16:03:34 2011] [error] [client ::1] * error(8, "Undefined offset: 0", "/home/hugh/src/mahara/mahara/htdocs/import/leap/li...", 1075, array(size 3)) at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:1075
[Wed May 11 16:03:34 2011] [error] [client ::1] * PluginImportLeap->get_entry_by_id("http://localhost/moodle2/user/view.php?id=3") at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:239
[Wed May 11 16:03:34 2011] [error] [client ::1] * PluginImportLeap->create_strategy_listing() at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:135
[Wed May 11 16:03:34 2011] [error] [client ::1] * PluginImportLeap->process() at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/lib.php:473
[Wed May 11 16:03:34 2011] [error] [client ::1] * send_content_ready("449b0d88a091d1c21e029db802ced9e51d4a4592", "test2", "leap2a", array(size 4), 1) at Unknown:0
[Wed May 11 16:03:34 2011] [error] [client ::1] * call_user_func_array("send_content_ready", array(size 5)) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/lib.php:122
[Wed May 11 16:03:34 2011] [error] [client ::1] * api_dummy_method("portfolio/mahara/lib.php/send_content_ready", array(size 5), "send_content_ready") at Unknown:0
[Wed May 11 16:03:34 2011] [error] [client ::1] * xmlrpc_server_call_method(resource(#45), "<?xml version="1.0" encoding="utf-8"?>
[Wed May 11 16:03:34 2011] [error] [client ::1] <methodCall...", "send_content_ready", array(size 1)) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/dispatcher.php:191
[Wed May 11 16:03:34 2011] [error] [client ::1] * Dispatcher->__construct("<?xml version="1.0" encoding="utf-8"?>
[Wed May 11 16:03:34 2011] [error] [client ::1] <methodCall...", true, true) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/server.php:142

Changed in mahara:
status: Triaged → Confirmed
Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

neater trace :P

 [WAR] 89 (import/leap/lib.php:1075) Undefined offset: 0
 Call stack (most recent first):
   * log_message("Undefined offset: 0", 8, true, true, "/home/hugh/src/mahara/mahara/htdocs/import/leap/li...", 1075) at /home/hugh/src/mahara/mahara/htdocs/lib/errors.php:446
   * error(8, "Undefined offset: 0", "/home/hugh/src/mahara/mahara/htdocs/import/leap/li...", 1075, array(size 3)) at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:1075
   * PluginImportLeap->get_entry_by_id("http://localhost/moodle2/user/view.php?id=3") at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:239
   * PluginImportLeap->create_strategy_listing() at /home/hugh/src/mahara/mahara/htdocs/import/leap/lib.php:135
   * PluginImportLeap->process() at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/lib.php:473
   * send_content_ready("449b0d88a091d1c21e029db802ced9e51d4a4592", "test2", "leap2a", array(size 4), 1) at Unknown:0
   * call_user_func_array("send_content_ready", array(size 5)) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/lib.php:122
   * api_dummy_method("portfolio/mahara/lib.php/send_content_ready", array(size 5), "send_content_ready") at Unknown:0
   * xmlrpc_server_call_method(resource(#45), "<?xml version="1.0" encoding="utf-8"?>
 <methodCall...", "send_content_ready", array(size 1)) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/dispatcher.php:191
   * Dispatcher->__construct("<?xml version="1.0" encoding="utf-8"?>
 <methodCall...", true, true) at /home/hugh/src/mahara/mahara/htdocs/api/xmlrpc/server.php:142

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

it seems the leap was still imported, just came up with that error the first time, then tried again.

some other underlying thing making that trace...

Changed in mahara:
assignee: nobody → Hugh Davenport (hugh-catalyst)
Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

This one is a tricky little bug.

We are reading the mimetype when we import it.

To do this we use the finfo class. By default it loads the following magic database (according to manual):
If not specified, the MAGIC environment variable is used. If this variable is not set either, /usr/share/misc/magic is used by default. A .mime and/or .mgc suffix is added if needed.

From what I see, the MAGIC env isn't set, and there is a *directory* at /usr/share/misc/magic, and a *file* at /usr/share/misc/magic.mgc

This seems like a upstream bug in php, for now I will add in a check if /usr/share/misc/magic is a dir, and if it is then will try .mgc (which detects as html as expected)

Cheers,

Hugh

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

filed php bug
http://bugs.php.net/bug.php?id=54714

sent in workaround for review
https://reviews.mahara.org/149

Cheers,

Hugh

Changed in mahara:
status: Confirmed → In Progress
Changed in mahara:
status: In Progress → Fix Committed
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.