File not found in Moodle 2.0

File not found in Moodle 2.0

by Pavel Zika -
Number of replies: 13
Hello,

sorry if the question is answered somewhere else but I haven't found it.

I have SCORM package that worked in Moodle 1.9.x without any problem.
I've tried it in Moodle 2.0 on our server and on Moodle.org testing installation and both unzipped and showed course structure correctly but after launching the course I get an error "Sorry, the requested file could not be found".

Can anybody point me where might be a problem? If anybody wants to test it, small (about 1MB) scorm package with our course can be found at:
http://download.langmaster.cz/temp/moodle/english1.zip

Related line in apache log is:
212.24.151.34 - - [27/Sep/2010:11:37:00 +0000] "GET /pluginfile.php/20/mod_scorm/content/2/english1/l01/a/home.htm HTTP/1.1" 404 11351 "http://cloud3.panelnet.cz/mod/scorm/loadSCO.php?id=2&scoid=24" "Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0E)"

and as far as I was able to search the database table mdl_files, there is such a file.
english1.png
although there are missing slashes?

Thank you for your help.

Regards
Petr

Average of ratings: -
In reply to Pavel Zika

Re: File not found in Moodle 2.0

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Petr,
the physical path for english1/l01/a/home.htm, according with your table (see contenthash column), should be $CFG->dataroot/filedir/8b/f4/8bf495e89...88052.

I guess that the missing slash in the table is the root of the issue here since HTTP 404 can be triggered by a incorrect hash matching based on the (relative) file path:
function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
...
    $fs = get_file_storage();
    if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
        return false;
    }
...

Unfortunately I'm not able to say the reason why you're missing slashes there in the table: maybe something related with lib/moodlelib.php::clean_param() using PARAM_PATH/PARAM_FILE and/or your Apache/PHP configuration (e.g.: AcceptPathInfo).

HTH,
Matteo
In reply to Pavel Zika

Re: File not found in Moodle 2.0

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Petr,

that zip file appears to be very strange

the filename of the files in the zip have slashes in the file names and aren't in real directories..

when I extract the zip I get a filename called:
"english1\l01\a\home.htm"
instead of directory called "english1" with a subdirectory called "l01" with a subdirectory called "a"

it was probably just a fluke that the file was handled in Moodle 1.9 - you need to fix the zip file as using slashes in filenames is not valid.
In reply to Dan Marsden

Re: File not found in Moodle 2.0

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Ahhh ;) At the time of my reply the package was not available for download...

@Petr: http://www.pkware.com/documents/casestudies/APPNOTE.TXT:
...
      file name: (Variable)

          The name of the file, with optional relative path.
          The path stored should not contain a drive or
          device letter, or a leading slash.  All slashes
          should be forward slashes '/' as opposed to
          backwards slashes '\' for compatibility with Amiga
          and UNIX file systems etc. 
... 

Ciao,
Matteo
In reply to Dan Marsden

Re: File not found in Moodle 2.0

by Pavel Zika -
Hi Dan,

thats strange as on Windows OS is unpacking working as expected. It must be some incompatibility between Windows and Linus unzip. I'll try to pack it with some other zip program to check and let here know.

Thank you for your help
Petr
In reply to Pavel Zika

Re: File not found in Moodle 2.0

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
well - it "could" be classed as a bug in Windows... it's not extracting the files as originally named smile

but really it's a bug with whatever product you used to zip the file.

The "windows bug" could potentially help - after unzipping in Windows, use windows to zip the files again and see if that file works as expected.
In reply to Dan Marsden

Re: File not found in Moodle 2.0

by Pavel Zika -
Wow. I never thought it might happen, but it was true.
When I unzipped it on Windows and zipped it with different zip archiver, everything works fine.
The question is, whether the bug is in Windows or Linux zip archiver smile but I guess it's Windows one.

Thank you for your help!
In reply to Pavel Zika

Re: File not found in Moodle 2.0

by mounir me -

Hi,

I'm running moodIe 2.0 and i am getting almost  the same problem. When i try to upload a scorm package i get the message:" Incorrect file package - not an archive". I've read the responses but for me there is nothing wrong with my zip file because when i unzip it i get i folder. So there is no slashes prob as for pavel zika.

Notice that the same scorm package is working fine  on moodle 1.9.4.

 

Please help me fixing this problem

 

In reply to mounir me

Re: File not found in Moodle 2.0

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi,

that error is arised here, in mod/scorm/mod_form.php:

                $packer = get_file_packer('application/zip');

                $filelist = $packer->list_files($filename);
                if (!is_array($filelist)) {
                    $errors['packagefile'] = 'Incorrect file package - not an archive'; //TODO: localise
                } else {

lib/moodlelib.php::get_file_packer() loads the zip_packer class:

    require_once("$CFG->libdir/filestorage/$classname.php");
    $fp[$mimetype] = new $classname();

which is charged to implement the list_files() method, which can fail in opening the archive (using PHP ZipArchive).

Shortly: your ZIP archive seems not to be valid, take a look at your PHP error log.

Ciao,

Matteo

In reply to Matteo Scaramuccia

Re: File not found in Moodle 2.0

by Moodle Eastern -

We upgraded from 1.9 to Moodle 2.0 last Friday but are having issues viewing files that were uploaded before the upgrade.

Config: Windows 2003, PHP 5.2.8, MySQL 5.0.83, IIS 6

We also had a problem uploading files but creating a temp folder fixed the problem, however, we do not  know how to resolve issue with old files. On mouse over, the link points to: https://moodle/mod/resource/view.php?id=12624 but clicking on the link results to: https://moodle/pluginfile.php/17781/mod_resource/content/0/

All the files before the upgrade seem to result to this page: https://moodle/pluginfile.php/17781/mod_resource/content/0/ with the error "Sorry, the requested file could not be found."

Any help would be appreciated.

Thanks

In reply to Moodle Eastern

Re: File not found in Moodle 2.0

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

just guessing here, but it sounds like a slash arguments error - check this out:
http://docs.moodle.org/en/Installation_for_Windows_2003_with_IIS

look at the section titled "Slasharguments"

In reply to Dan Marsden

Re: File not found in Moodle 2.0

by Ian Wright -

I could use a bit of help here, for Moodle 2 (latest), IIS 6 and Windows Server 2003 Enterprise x64 running Virtuozzo.  I'm getting a null result from the lib.php lines mentioned above and repeated below (which I frankly don't understand, but I know this returns false resulting in a file-not-found display):

    if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
        return false;
    }

I'm using WinZip 15, and notice that all the folders in the WinZip GUI are shown as separated by backslashes, but I can't believe Moodle won't handle a WinZip 15 file (pse see the attached screen-clip).  If unzipped into a Windows directory,  there's no sign of any forward- or back-slashes - Windows just shows folders.

I've worked through the IIS "Slasharguments" stuff, but don't see this as the issue.  The actual URLs that Moodle is generating are, for example:

http://109.104.82.157/mod/scorm/loadSCO.php?id=4&scoid=4

followed after 2 seconds by:

http://109.104.82.157/pluginfile.php/27/mod_scorm/content/Lib/Shell/P209shell.html

These URLs are forward-slashed and look reasonable, but as I don't comprehend the 'filedir' structure (which for two SCORM lessons contain 229 files in 375 folders with hex names and scrambled data), I can't see why they result in 'file-not-found'.  Nor can I use Windows to unzip into the target directory... 

This is a show-stopper.  Any useful steer would be gratefully accepted.

Attachment WinZip15Clip.PNG
In reply to Ian Wright

Re: File not found in Moodle 2.0

by Nicolas Hartman -

Ian, have you had any luck with your problem as I have an identical one in Moodle which is also stopping production.

In reply to Nicolas Hartman

Re: File not found in Moodle 2.0

by Ian Wright -

Not yet, Nicolas - I've turned back to 1.9 for now.  At this time v2 SCORM doesn't always appear to "do what it says on the tin", but I don't know why - yet.  I have a better understanding of the file storage system since finding http://docs.moodle.org/en/Development:File_API and associated development docs linked at the foot of that page - but this doesn't solve the problem.