I would suggest that you plan on updating sooner rather than later. You could spend ages looking for the problem, find it, solve it and then update. Waste of time, I think. Just update now, adding in a fresh codebase. If the problem persists then look to your PHP version, 5.x or 7.x? You might want to update that as well, prepare for the time that you will need to be using that version of PHP. If the problem continues to exist, then likely something has bitten your server and that's outside my knowledge. Don't update in too big a step, go to v2.8, then v3.0, two version steps is likely to work best.
BTW, there are likely to be others who would suggest don't update until you find the problem and fix it. They will offer good advice, and encouragement, and might even find a solution, but it is your decision.
Incentives to upgrade?
'spirit of sharing', Ken
Interesting list Ken, is it a replay of the Moodle Tracker?
@Colin ... are you informing me of Moodle Tracker, or what?
Fine ... for the OP.
https://tracker.moodle.org/browse/MDL-43655?jql=text%20~%20%22version%202.6%22
Same incentives, I would think.
As far as who post what where and when, I would hope 'responsible reporting' (got a 'finger wag' on that one recently) would mean Moodle Tracker first ... CVE second .... or automagically posted from Tracker to CVE.
Tracker does have more Moodle specific info ... and stuff like ... cannot replicate ... etc..
So it might be preferences of seeker?
'spirit of sharing', Ken
Thanks for the list. I realize that using an old version of Moodle is a security risk. We already have a plan for updating, but right now we have courses depending on the old version of Moodle that we cannot delay at all.
Consider that the issue might be on the workstation you are using to access.
Same issues on other workstations using same OS and browser?
Got a Mac or know someone who does? See what happens to them. Know this might be far fetched, but how about a Linux OS workstation?
Resisting 'finger wag' concerning version as you have already stated you do need to upgrade. ;)
Does Windows still use registry and Reg Edit?
'spirit of sharing', Ken
In the past, it was not un-common to have issues with workstation registry. Had to ask.
So if, one were to work right on the server, in the OS interface, NOT moodle, and find a file that was uploaded to moodle via whatever, does that file open correctly?
For that you'd need to make queries of your mdl_files table to find the humanly recognizable name and it's contenthash ....
contenthash shows path to the file in the sea of files in moodledata/filedir/
Example:
humanly recognizable name: mycool.doc or mycool.zip
contenthash has qfwqwehjgrwelqwedhfalslw
That file is located in moodledata/filedir/qf/wq/ and is named with the contenthash ... so the file doesn't have any extension on it.
Copy that file (qfwqwehjgrwelqwedhfalslw) out to desktop of the server, rename it for the humanly re-cognizable name (mycool.doc or mycool.zip)
and see if the server OS can open the file.
Don't run Windows anything anymore myself .... server/workstation ... so above is 'troubleshooting' and trying to find out where the issue might be.
'spirit of sharing', Ken
Also ... one other thought if using Apache ... what is apache setting for xsendfile and mime types?
Think you could see some of that info via phpinfo in admin -> Server -> PHP Info
'spirit of sharing', Ken
As I mentioned in the post, the original file does get uploaded. Like if I upload a PNG file say p.png with a content hash of abcdefghij, it does get stored in the moodledata/filedir/ab/cd/abcdefghij, which is exactly the same as the file I uploaded. But, the preview image in Moodle and its associated download button, gives me a different corrupted image. If I download the same image from the Moodle interface and call it say p2.png, it has a different hash, say efghijklmn. Looking at the moodledata dir again, there is another file in moodledata/filedir/ef/gh/efghijklmn. That's the issue here.
I don't know if it'll help, but the corrupted file and the original file always seems to have the same filesize. Looking at the one corrupted jpg file with a text editor, I notice the following:
Ǿˡƿ Ÿϊ۠ʶ̝Щ��j荺ݑ^?PٽȒޞliеı?ԳƷ}ۯ��ҋߜɠdɭ$??㡈ңԁ튉ܕ!θ{ثغbw{]?[��οR뵕荶ĝU 2}ͳXಹ_ڃޜL{1+ɣlև뫰~n#��Ѯ݊У,Ǻκjףa����5?5Փم(ǡUࠇ%ؙٖ6��ܴ#۽˭ߡȿ ҚΚʦʛѽ?��?䀲IεۣuSȳևࠪ(̥#fˤcʍ Ɣȹ5ɟ?��?м۩vޘ:cE؈ϢɉϘӚϟɺ vև㴨����¯Ƞh$Ә����Ƶ\ ㋝Ȯ�%EZw��Aɐhotoshop 3.0 8BIM Untitled-2a 8BIM% ԂrW.G΅Ჟ湂IMꠠ ��ml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.print.PageFormat.PMHorizontalRes</key>
<dict>
<key>com.apple.print.ticket.creator</key>
<string>com.apple.jobticket</string>
<key>com.apple.print.ticket.itemArray</key>
...
That plist shouldn't be here in a jpg file format. Don't know where or why Moodle put this in the file.
If files were uploaded by a mac user .plist might be there. Looks like photoshop header.
Got any apple products (applications) installed **on the server**? On the workstation?
mysql> select contenthash,filename,userid,mimetype from mdl_files where filename like '%.jpg';
Example of what is returned:
| 41cfeee5884a43a4650a851f4f85e7b28316fcc9 | background.jpg | 2 | image/jpeg |
So if I go to the moodledata/filedir/41/cf/ directory do I see a 41cfeee5884a43a4650a851f4f85e7b28316fcc9 file?
And if I copy that file to desktop *ON THE SERVER* and rename it to background.jpg can I open the file *ON THE SERVER*?
Find out who is user id is and if they are using photoshop.
What php extensions do you have installed? and version of PHP? User pics uploaded by users are converted to two images .... sized to fit and a smaller version for display in certain areas of Moodle. Do those user pics look ok for a user?
PHP info page will show php info.
Agree this is strange ... don't know that anyone has ever posted anything similar. :\
'spirit of sharing', Ken
Pretty sure there's no apple product installed on the server. As part of the course work, we do have students submitting images using Adobe Illustrator, but they submitted only the final images. And yes, when you upload a file, you do have the original file stored according to its checksum and when you rename it, it does open on the server and it displays the original image.
But the preview image looks broken. From the Moodle interface, you get a broken image and the download option points towards the broken file, which has a different checksum stored in a different folder in moodledata/filedir.
Really strange behaviour from Moodle. Haven't got the slightest clue why this is happening.
There is no column in mdl_files for 'checksum' ... there is a size column.
Did you do the example query on your DB? Here's another query:
mysql> select contenthash,filename,filearea,filepath,userid,mimetype,filesize from mdl_files where filename like '%.jpg';
Run it ... if you know the name of the .jpg file change the ending of the query to the actual humanly recognized filename.
Explain what you mean by 'preview' .... and if the downloaded file has a different contenthash have you tried the same test ON THE SERVER with the 'different' contenthashed file?
There is a preview image and a full image file? How are students uploading files? I take it this is in assignments? In site admin menu, do you have a tool to convert assignments?
Adobe illustrator ... that plist file didn't show that!
I take it that your cron job is running ok and frequently.
And I asked about PHP and extensions? Are you missing any?
'spirit of sharing', Ken
Are we still confusing 'checksum' with 'contenthash' .... they are not the same.
The contenthash value stored in the DB is NOT a checksum .... it's just an obscured path and file name in moodledata.
Think the issue with the .zip file is on the workstation end. Registry? Have never heard of Moodle converting an uploaded .zip to a .rar. That would mess up things like SCORM's in Moodle. You must have WinRAR or something else installed on the workstation that does that 'automagically'.
What happens when you access that course/file using a smartphone .... like an Android ... and you tap on the link to the .zip file? Does it download as a zip?
Ken
Running the SQL query you provived gives me the following output
SQL result
Host: 204.93.172.30:3306
Database: cmtphys_moodle
Generation Time: Jul 01, 2018 at 08:41 AM
Generated by: phpMyAdmin 3.3.1 / MySQL 5.1.66-community
SQL query: SELECT contenthash,filename,filearea,filepath,userid,mimetype,filesize from mdl_files where filename like 'smiley1.jpg'
LIMIT 0, 30 ;
Rows: 2
contenthash | filename | filearea | filepath | userid | mimetype | filesize |
---|---|---|---|---|---|---|
58b8d77aac35c792ea14f9b359be35eee3a54707 | smiley1.jpg | draft | / | 4 | image/jpeg | 7095 |
58b8d77aac35c792ea14f9b359be35eee3a54707 | smiley1.jpg | content | / | 4 | image/jpeg | 7095 |
See the filearea the DB returned .... 'draft'. Means it's not quite there all the way yet.
Rather than worry about the preview, go ahead and SAVE.
Make sure the cron job runs. You'll have to research how to do that one windows command line ... if on linux, one could cd admin/cli/ then issue: php cron.php
In the output of running cron, look for anything related to files. Since 2.6 is soooooo old there is much that has changed in the running of cron so I cannot provide an example of what it would look like to you as that version.
After cron job runs, that 'draft' should change to things like 'section' or 'content'. Moodle then has been given time to gen a preview if that version actually gen's a preview. That preview might be coming from .js code.
IF, after running cron do the DB query again to see if that 'draft' status has changed to something else ... 'section', 'content', whatever. There really should be only one reference to that file. Your query shows 2 .... one draft and one content!!!!
???? https://moodle.org/mod/forum/discuss.php?d=185839
Site might have hit something that can only be fixed by upgrading.
'spirit of sharing', Ken
Correction ...
The query will show two rows ... the contenthash is the same so that means there is only ONE file in the meta data.
At some point in the future, draft is no longer be true as you've not edited the file link created and that should/would disappear leaving on the row that has 'content'.
Add filesize to the query .... that value should be the same ... it's the same file. There is no 'preview' sized image in the DB. That only shows when in the process of editing or adding the resource.
What's important is not the preview that might have been trying to acquire via right click ... but the actual link to the resource in the course.
'spirit of sharing', Ken
I faced the same issue with Moodle 3.5 and filemanager field. Image preview has got corrupted for some reason only for some occasions. When I cleaned the preview file record in database, it regenerated without any issue. However I need to clean records in database using following sql,
// Get contenthash
select contenthash from mdl_files where itemid='688186689';
// Get preview - filename is the contenthash from previous sql
DELETE from mdl_files where filename='53002d018e1ac3a82326882386f9e5186a34f730' AND filearea='preview' AND filepath='/thumb/';