How to configure MigrateFileTask for migrating assets from SS3 to SS4

Silverstripe Version:

4.5.1

Question:

Is it necessary to configure paths before running MigrateFileTask when upgrading from a site from SS3 to SS 4.5?

Details of your query go here
I am on the very last step indicated in the SilverStripe 4 migration guide. I am migrating an existing SS 3.6.5 site to SS 4.5.1. Simply put, I’m at the file migration task step. The rest was long but it went smoothly thanks to the upgrader.

I am running php ./vendor/silverstripe/framework/cli-script.php dev/tasks/MigrateFileTask on Windows 8.1 box running PHP 7.2.

The lowest-ID database record in table file is named assets/Uploads/thumbnail-BlueXML1.png.

When the task runs, I get this error message:

ERROR [Emergency]: Uncaught InvalidArgumentException: H:\Code<project root>\public\assets\assets/Uploads/thumbnail-BlueXML1.png does not exist

The error message is right: the actual path contains “assets” only once. The path in the error message has it twice.

Given that I have followed the migration guide to the letter, and I’m using the latest version (4.5.1) of recipe-cms in my composer.json file, I am wondering whether there is an additional configuration that I have made the mistake of not noticing in the migration guide.

Under SS 3.6.5, the path to the “assets” folder was: H:\Code\<project root>\assets.

Under 4.5.1, as I understood in the migration guide, the “assets” folder should now be at H:\Code\<project root>\public\assets.

I’m using the default paths, as I have never had a need that would have justified/would justify diverting from the defaults.

If someone has an idea for solving this duplication of “assets” in the paths, I would be grateful if they could share it.
Thank you.

1 Like

Hi there,

So, I found a solution for the MigrateFileTask double “assets” in path:
In …\vendor\silverstripe\assets\src\Dev\Tasks\FileMigrationHelper.php I changed line 306 to
$base . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $fsFilename,…
(deleted the ASSETS_DIR . from it)

4 Likes

@Kimk Thanks for the answer, a year and a half later this has helped another person. Worked for me on ver 4.10, same file but now line 298.

Nice to know, thanks. I’ll try it.

@Kimk After applying your solution, the task reached its end normally and I can see every file as expected in the CMS.
Thank you!