Hi John,
Unless I'm missing some particular issue, it really seems strange that the cleanup process is not working. I just made two tests at my local installation (Win XP, Apache 2.2.20, MySQL 5.5.8, PHP 5.3.5, Moodle 2.2.1 build: 20120109), and everything ran as it should.
Before I describe the tests I did, maybe you would like to read the following post I made, just to get familiar with some aspects of the mdl_files table and the underlying file system:
http://moodle.org/mod/forum/discuss.php?d=203204#p889847
Well, to test the cron system and the code, I began by creating a new page with some text, saved it and then edited it to add a new image; however, once I uploaded the png file, I clicked Cancel on both the "Insert/edit image" window and the "Updating Page in Topic 1" page. This of course left me with an unused image file (or a draft file).
When I went to browse the mdl_files table, two new entries were there (I still don't understand the reason behind many of the intricacies and mechanisms of the mdl_files table and of the file system, being one of them why an empy file is created along with the corresponding table entry, but that's how it is):
id 157 158
contenthash ded4b5... da39a3...
pathnamehash 084da3... 3ce712...
contextid 5 5
component user user
filearea draft draft
itemid 517639160 517639160
filepath / /
filename imiamec.png .
filesize 5289 0
timecreated 1339475765 1339475765
As you can see, the first entry (id=157) corresponds with the file that was actually uploaded, as it has the original file name and a non-zero file size, while the second entry doesn't have a name and is an empty file. Evidently, the itemid field creates the relationship between both registers.
Based on the value of the contenthash field, I went and confirmed that the "ded4b5..." file was at moodledata/filedir/de/d4, and that the "da39a3..." (empty) file was at moodledata/filedir/da/39.
To be able to test the deletion of these draft files, I opened file_storage.php (at moodle/lib/filestorage), deleted the "- 60*60*24*4" part of the $old variable, and then manually ran the cron.php script, which ended normally:
Deleting old draft files... done.
Cleaning up files from deleted contexts... done.
Deleting trash files... done.
Cron script completed correctly
Finally I checked the mdl_files table and the two directories: both registers and both files were deleted.
For the second test, I created a new page, uploaded and saved the image and the page. This time, the mdl_files table had four new registers:
id 173 174 175 176
contenthash 580c7a... da39a3... 580c7a... da39a3...
pathnamehash 9cd34f... 9e7e6a... 81ddc2... 6a5bea...
contextid 5 5 35 35
component user user mod_page mod_page
filearea draft draft content content
itemid 285766602 285766602 0 0
filepath / / / /
filename viv.jpg . viv.jpg .
filesize 31745 0 31745 0
mimetype image/jpeg NULL image/jpeg NULL
timecreated 1339479656 1339479656 1339479656 1339479656
After I ran the cron.php script, only the last two (id=175, 176) remained; those whose filearea=draft, were deleted. Obviously, none of the files ("580c7a..." & "da39a3...") were deleted, as the DB says they are being used (component=mod_page).
I hope some of this will let you find what is going wrong with your installation. If not, maybe you should open a tracker (you need to create an account for this):
http://tracker.moodle.org/
Maybe the problem you're having is related to one of the WISP components (e.g. some particular setting).
---
Funny thing, one thing I just noticed while doing this test that uploaded images are not being shown once I save them!! Neither in IE nor in FF. The link looks Ok (moodle/pluginfile.php/35/mod_page/content/1/viv.jpg) and the file is in its corresponding folder, but the browser just shows the classic white square with a red X
If I try to open the image directly (via the image URL), FF says:
The image xxx cannot be displayed, because it contains errors. And the error console reports:
Error: Image corrupt or truncated:
moodle/pluginfile.php/35/mod_page/content/1/viv.jpg
I just checked the SHA1 of both the local and the "uploaded" files, and they are the same, and both browsers display Ok the local file... sigh! (sorry for this extra rant).