Upgrade from 3 to 4.1 - assets don't work

Silverstripe Version: 4.1 (coming from 3.1)

Question:

After going through the upgrading process as described in the docs, there seems to be an issue with assets.
Everything else seems to be fine, /dev/build has no errors, but in the Files area all files listed show ‘File cannot be found’.

I’ve copied all files from ‘assets’ to ‘public/assets’ and left the paths in the database as they were.

Strange thing is that there is something mentioned in the docs that just doesn’t seem right, see 4.0.0 – SilverStripe Documentation

“In order to retain existing file paths in line with framework version 3 you should set the \SilverStripe\Filesystem\Flysystem\FlysystemAssetStore.legacy_paths config to true.”

From what I can see, “SilverStripe\Filesystem\Flysystem\FlysystemAssetStore.legacy_paths” simply doesn’t exist (neither the class, nor the property).
Closest thing I could find is “SilverStripe\Assets\Flysystem\FlysystemAssetStore.legacy_filenames”, but setting this to true doesn’t fix the problem for me.

Any ideas?

We’ve fixed this now, will be released with 4.1.1 shortly

2 Likes

Hi schellmax,

you need to run MigrateFileTask to update the files in DB. Be aware that if you use Subsites module the subsites filter also kicks in and you need to migrate the files per subsite.

I ran

vendor/bin/sake dev/tasks/MigrateFileTask

in CLI, with subsites I also needed to run

vendor/bin/sake dev/tasks/MigrateFileTask SubsiteID=1
vendor/bin/sake dev/tasks/MigrateFileTask SubsiteID=2

Thanks, already tried this, but i get

No File DataObjects need upgrading

seems like MigrateFileTask is not working for SilverStripe 4.1 yet.
There is a check for each file which doesn’t take the new ‘public’ folder into account:

        // Make sure this legacy file actually exists
        $path = $base . '/' . $legacyFilename;

should be

        // Make sure this legacy file actually exists
        $path = $base . '/public/' . $legacyFilename;

after this change, the task succeeds for all files.
doesn’t really help though: all files in the filesystem are now 0 bytes!

1 Like

@schellmax please can you open an issue for this on GitHub?

1 Like

@dhensby ticket created MigrateFileTask not working in SilverStripe 4.1 · Issue #123 · silverstripe/silverstripe-assets · GitHub

  • Thumbnails won’t work without FileHash field

  • If u will set FileHash field u will need to move ur files into .protected folder: assets/.protected/10 symbols of hash/your-file.png

  • After that CMS thumbnails will need to be regenerated.

So here’s the fixture:
try this: SS3 > SS4.1 protected folder migration script · GitHub