I’ve got a website that I do the coding and testing for locally, and when ready I upload the files via FTP to a remote server which can be a little slow at times.
If a user tries to access a page containing a require_once of a page that’s currently being uploaded, they will get errors as at that specific moment in time the file appears not to exist or is only partially uploaded. Even if a user tries to access a page directly e.g. example.php they could experience the same problem.
I overcame the require_once issue by creating a custom include function that checks the last line of the file for a marker but this doesn’t help for non include pages and is really messy.
Is there a better way to update the site without pissing off the users with errors?
Have you looked into deployment options other than FTP? Many deployment tools like Capistrano, which works via SSH, copy new files into a new folder, then symlink the
currentdirectory to the new folder if and when the whole upload and update process is finished. This ensures atomic (all or nothing) updates.