This change fixes an issue where old/existing formatted images are used
when a filename is reused (by overwrite or by coincidence), regardless
of if the file contents have changed. To users this mainly manifests
as a file overwrite appearing not to work; the thumbnails in the CMS
show the original image until regeneration is forced.
Calling Image::deleteFormattedImages() after image upload ensures that
no stagnant formatted images will be used.
Adding warning, took me a couple hours to figure this out...
The file does not get moved because of this line:
https://github.com/silverstripe/silverstripe-framework/blob/3.1/filesystem/File.php#L515
Maybe add to the method doc, telling people to set ParentId and Name instead if they want to change the location of a file (if that's the correct method).
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".