Moodle

Uploading a file fails with JSON error

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Files API
  • Labels:
    None
  • Environment:
    windows xp moodle 2.0 php 5.2.8
  • Database:
    MySQL
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

I cannot upload any files using the new file manager in Moodle 2.0. I get the error JSON |upload| (can't remember it exactly, but that is the basics.) Does anyone know how to fix this? local install

Activity

Hide
Martin Dougiamas added a comment -

Elaine, what version are you using? Dongsheng can you check this?

Show
Martin Dougiamas added a comment - Elaine, what version are you using? Dongsheng can you check this?
Hide
Dongsheng Cai added a comment -

Hi, Elaine, can you copy the JSON error message, this will help me debug it.

Probably, you was uploading a large file, and File API reject this file

Show
Dongsheng Cai added a comment - Hi, Elaine, can you copy the JSON error message, this will help me debug it. Probably, you was uploading a large file, and File API reject this file
Hide
Dongsheng Cai added a comment -

Elaine, I committed a few code to improve uploading process, can you try again use the latest 2.0 code?

Show
Dongsheng Cai added a comment - Elaine, I committed a few code to improve uploading process, can you try again use the latest 2.0 code?
Hide
Elaine Blakeman added a comment -

I tried to download the new code but got this error:

In C:\xampp\htdocs\moodle_20\moodle: "C:\Program Files\CVSNT\cvs.exe" -q -d
:pserver:anonymous@us.cvs.moodle.org:/cvsroot/moodle checkout -P moodle
CVSROOT=:pserver:anonymous@us.cvs.moodle.org:/cvsroot/moodle

Empty password used - try 'cvs login' with a real password
(and then nothing happens.)
________________________________________________________________________________________
This is the exact error I am getting in Moodle 2.0:
Invalid JSON string - |upload| -

In teacher role I cannot upload at all (get above error)
(It also says I do not have permissions but when I check permissions they are all set to allow.)

As an Admin I can upload only through the Admin Panel > Files. If I try using the drop-down menus to add a file, I get the error: Invalid JSON string - |upload| -

Thank you I look forward to your reply.

Show
Elaine Blakeman added a comment - I tried to download the new code but got this error: In C:\xampp\htdocs\moodle_20\moodle: "C:\Program Files\CVSNT\cvs.exe" -q -d :pserver:anonymous@us.cvs.moodle.org:/cvsroot/moodle checkout -P moodle CVSROOT=:pserver:anonymous@us.cvs.moodle.org:/cvsroot/moodle Empty password used - try 'cvs login' with a real password (and then nothing happens.) ________________________________________________________________________________________ This is the exact error I am getting in Moodle 2.0: Invalid JSON string - |upload| - In teacher role I cannot upload at all (get above error) (It also says I do not have permissions but when I check permissions they are all set to allow.) As an Admin I can upload only through the Admin Panel > Files. If I try using the drop-down menus to add a file, I get the error: Invalid JSON string - |upload| - Thank you I look forward to your reply.
Hide
Elaine Blakeman added a comment -

I was able to download afterall:

Success, CVS operation completed

but still get the JSON error as noted above. Do I need to restart after downloading new code?

Show
Elaine Blakeman added a comment - I was able to download afterall: Success, CVS operation completed but still get the JSON error as noted above. Do I need to restart after downloading new code?
Hide
Elaine Blakeman added a comment -

I turned on debugging and when I try to upload a file in teacher role, (from the Admin Panel > files) I get the error message:

Error writing to database and then this:

Debug info: Duplicate entry '61dcfb04ea33e07f165472527b45623883bdeb45' for key 'mdl_file_pat_uix'<br /><br />INSERT INTO mdl_files (contextid,filearea,itemid,filepath,filename,timecreated,timemodified,mimetype,userid,filesize,contenthash,pathnamehash) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)<br />[array ( 0 => '11', 1 => 'course_content', 2 => '0', 3 => '/', 4 => 'Winter.jpg', 5 => 1258134058, 6 => 1258134058, 7 => 'image/jpeg', 8 => '3', 9 => 105542, 10 => 'ca6ec835bffff37e28896df424db5559012d48b6', 11 => '61dcfb04ea33e07f165472527b45623883bdeb45', )]
Stack trace:

  • line 365 of \lib\dml\moodle_database.php: dml_write_exception thrown
  • line 738 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 781 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 638 of \lib\file\file_storage.php: call to mysqli_native_moodle_database->insert_record()
  • line 331 of \lib\file\file_info_stored.php: call to file_storage->create_file_from_pathname()
  • line 96 of \files\index.php: call to file_info_stored->create_file_from_pathname()
Show
Elaine Blakeman added a comment - I turned on debugging and when I try to upload a file in teacher role, (from the Admin Panel > files) I get the error message: Error writing to database and then this: Debug info: Duplicate entry '61dcfb04ea33e07f165472527b45623883bdeb45' for key 'mdl_file_pat_uix'<br /><br />INSERT INTO mdl_files (contextid,filearea,itemid,filepath,filename,timecreated,timemodified,mimetype,userid,filesize,contenthash,pathnamehash) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)<br />[array ( 0 => '11', 1 => 'course_content', 2 => '0', 3 => '/', 4 => 'Winter.jpg', 5 => 1258134058, 6 => 1258134058, 7 => 'image/jpeg', 8 => '3', 9 => 105542, 10 => 'ca6ec835bffff37e28896df424db5559012d48b6', 11 => '61dcfb04ea33e07f165472527b45623883bdeb45', )] Stack trace:
  • line 365 of \lib\dml\moodle_database.php: dml_write_exception thrown
  • line 738 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 781 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 638 of \lib\file\file_storage.php: call to mysqli_native_moodle_database->insert_record()
  • line 331 of \lib\file\file_info_stored.php: call to file_storage->create_file_from_pathname()
  • line 96 of \files\index.php: call to file_info_stored->create_file_from_pathname()
Hide
Elaine Blakeman added a comment -

When I try to upload from drop-down menu I get this error (in both admin and teacher roles)

Invalid JSON string - |upload| -

Just to clarify I have two issues with file uploading.

Show
Elaine Blakeman added a comment - When I try to upload from drop-down menu I get this error (in both admin and teacher roles) Invalid JSON string - |upload| - Just to clarify I have two issues with file uploading.
Hide
Elaine Blakeman added a comment -

When I try to upload a file using html editor (teacher role) I get the following:

Invalid JSON string - |upload| -
Fatal error: Call to undefined method repository::store_to_filepool() in C:\xampp\htdocs\moodle_20\moodle\repository\upload\repository.class.php on line 26

Show
Elaine Blakeman added a comment - When I try to upload a file using html editor (teacher role) I get the following: Invalid JSON string - |upload| - Fatal error: Call to undefined method repository::store_to_filepool() in C:\xampp\htdocs\moodle_20\moodle\repository\upload\repository.class.php on line 26
Hide
Elaine Blakeman added a comment -

Everything is working now. I did a completely new installation with your code update and I tested file upload and it works!

Thanks for helping me on this.

Show
Elaine Blakeman added a comment - Everything is working now. I did a completely new installation with your code update and I tested file upload and it works! Thanks for helping me on this.
Hide
Dongsheng Cai added a comment -

Thanks, Elaine feel free to reopen it if you find another bug

Show
Dongsheng Cai added a comment - Thanks, Elaine feel free to reopen it if you find another bug

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: