NEW Fix folder permissions (#8950)

* Add `FixFilePermissionsHelper` subtask
* Changed name to folder permissions, added more loggin
This commit is contained in:
Andre Kiste 2019-05-02 16:28:57 +12:00 committed by Ingo Schommer
parent 0696045e59
commit 48db515fbd
2 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,8 @@ This task will perform a number of subtasks:
- `generate-cms-thumbnails`: The new CMS UI needs different thumbnail sizes, which can be pregenerated.
This can be a CPU and memory intensive task for large asset stores.
See [Migrating substantial number of files](#performance)
- `fix-folder-permissions`: Fixes folder permissions which might have been broken by
previously using the [silverstripe/secureassets](https://github.com/silverstripe/silverstripe-secureassets)
One or more subtasks can be run individually through the `only` argument.
Example: `only=move-files,move-thumbnails`

View File

@ -26,7 +26,8 @@ class MigrateFileTask extends BuildTask
protected $defaultSubtasks = [
'move-files',
'move-thumbnails',
'generate-cms-thumbnails'
'generate-cms-thumbnails',
'fix-folder-permissions'
];
private static $dependencies = [
@ -92,6 +93,23 @@ class MigrateFileTask extends BuildTask
ImageThumbnailHelper::singleton()->run();
}
if (in_array('fix-folder-permissions', $subtasks)) {
if (!class_exists(FixFolderPermissionsHelper::class)) {
$this->logger->error("FixFolderPermissionsHelper not found");
return;
}
$this->logger->info('### Fixing folder permissions (fix-folder-permissions)');
$updated = FixFolderPermissionsHelper::singleton()->run();
if ($updated > 0) {
$this->logger->info("Repaired {$updated} folders with broken CanViewType settings");
} else {
$this->logger->info("No folders required fixes");
}
}
}
public function getDescription()
@ -99,7 +117,9 @@ class MigrateFileTask extends BuildTask
return <<<TXT
Imports all files referenced by File dataobjects into the new Asset Persistence Layer introduced in 4.0.
Moves existing thumbnails, and generates new thumbnail sizes for the CMS UI.
Fixes file permissions.
If the task fails or times out, run it again and it will start where it left off.
You need to flush your cache after running this task via CLI.
See https://docs.silverstripe.org/en/4/developer_guides/files/file_migration/.
TXT;
}