concrete5/concrete5 — pull request #1513 by geekcubed (2013-11-16 08:34:44+00:00)
Title: Allow for File Versions to be created by anonymous users.

Adding a new File object (and associated initial FileVersion) to the system supports doing so by an "anonymous" user (with the arbitrary uID of 0). However, when updating an existing File to add a new version, FileVersion::duplicate() is called, and this doesn't support the User being anonymous.

Calling Duplicate without an active, authorised, session results in an SQL Exception as the insert statement attempts to set the fvAuthorUID field for the new version to null.

This is particularly relevant when calling FileImporter::import(), which encapsulates the whole process and provides no way to override the author column. This has occurred in a couple of places in recent projects for me

* When trying to add or update a File where the current session is for an anonymous user.
* When trying to use the FileImporter to add/update a file as part of a Concrete5 background Job being ran via cron.

This fix adds a similar level of logic checking to the duplicate method as already present in File::add() and FileVersion::add()