NOTE: This change should be reviewed to make sure it does not cause any side effects.
Example use case:
An admin porting user images from an old website.
The script would put the images in the assets folder,
and then insert them into the database using Image::write()
and data from the old database.
public function insertImage($data) {
$image = new Image();
$image->ParentID = $data->parentId;
$image->Title = $data->title;
$image->FileName = $data->filename;
$image->OwnerID = $data->ownerId;
$image->write();
// In the current version, this results in all images
// being owned by Member::currentUser() instead of
// the expected $data->ownerId;
}
I've changed the variables to use the absolute path as the path is unhelpful for debugging and this is more consistent with the other lines of code below
Filesystem::sync() tries to run through all pages, without caring
which subsite the page came from. The problem with this is
code in SiteTree::validURLSegment() will return invalid information,
as it will check if the page exists, thinking it does, return false,
then the page will get a new URLSegment written, e.g. "home-2".
Instead of disabling the subsite filter in Filesystem::sync(), this
fix will just loop through each subsite and sync each subsite's pages
individually before doing the main site.
Fixes http://open.silverstripe.org/ticket/6210.
Replaces the hardcoded file patterns from Folder::syncChildren() with a new static Filesystem::$sync_blacklisted_patterns to describe files and folder names to skip when running Folder::sync().
Added unit test for Folder::sync()
Extended Folder::sync() to report on the number of file / folders skipped.
Does not actually change behaviour, but ensures that the hyphen
is not interpreted as a range identifier should it be placed
between two characters which PCRE regards as "rangeable".
Upload::load() assumes that a parent Folder always exists for a file
upload, but that's not always the case, and a non-object error is
given if no parent folder.
Check the folder exists first before getting the ID.
When a user renames a file to "__test.txt" (two underscores or more),
then FileNameFilter will only remove the very first underscore from the
filename. This is not sufficient, as any number of underscores in the
filename will be problematic when Filesystem::sync() is called, it will
remove that File record thinking it's an internal file. This fixes it
so any number of underscores are stripped out at the start of the filename.
This is a measure to support form fields and controllers
interacting with files in different contexts,
for example an UploadField used in a ModelAdmin,
or a website frontend. The check for 'CMS_ACCESS_AssetAdmin'
was too restricting. This wasn't a problem in 2.x simply because
the old FileField/Upload classes didn't respect File->can*()
permissions.