phpmysqldatabaseelgg

Missing files - Elgg and Databases


I'm trying to help a friend fix an application he had developed with Elgg. I'm familiar with PHP but completely new to Elgg.

Long story short there are two main problems that happen seemingly at random:

  1. Users will sometimes (about 1 out of 100) upload files and then the files disappear.
  2. At about the same rate (1 of 100) even when a file successfully shows up on the database it will, sometimes even weeks later, still disappear.

I thought about going through the logs to try to find the source of the problem but there are dozens of people that can be using it at any given time and hundreds of files (audio, image, pdf, video, etc) that can be uploaded on any given day and wouldn't even know what to look for.

What is the smarter way to pinpoint what is going wrong with these seemingly random errors on this Elgg project OR does anyone have any insight as to what may be the problem?

Thanks so much for your help!


Solution

  • The first thing to do is to look for errors and warnings in the server error log, e.g.:

    cat path-to-your-error-log | grep Error
    

    Such errors should be rare, so it ought to be easy enough to narrow it down.

    Assuming that the page that links to the file is intact (and therefore the entity is correctly stored in the database) it may be that the files are too large but that the application is not correctly registering the error - check the max_file_size in php.ini and look for correlations between the problem and the file size. Such errors should show up in the server error log.

    We have also had problems in the past with filesytem errors or altered file permissions that have prevented access to files even after they are originally uploaded successfully. Make sure that the files themselves actually exist and that permissions are fine in the Elgg data directory. If they are not, fix the disk. Such errors may only show up as warnings so can be harder to find.

    Another problem that can occur with most versions of Elgg is if the server timezone changes, because files are stored in directories that are named based on their owner's first login date. If the timezone of the server changes, Elgg is not smart enough to know that the directory structure has to change too. You can explicitly set the timezone in engine/settings.php using date_default_timezone_set().