Migrations: Fix add file

pull/3984/head
Julio 4 years ago
parent 11cb54f913
commit 99e60b47d4
  1. 17
      src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php

@ -133,10 +133,15 @@ final class Version20201215160445 extends AbstractMigrationChamilo
$parent
);
$em->persist($resource);
$em->flush();
$forumImage = $itemData['forum_image'];
if (!empty($forumImage)) {
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/forum/images/'.$forumImage;
$this->addLegacyFileToResource($filePath, $forumRepo, $resource, $id, $forumImage);
if ($this->fileExists($filePath)) {
$this->addLegacyFileToResource($filePath, $forumRepo, $resource, $id, $forumImage);
}
}
if (false === $result) {
@ -255,7 +260,7 @@ final class Version20201215160445 extends AbstractMigrationChamilo
$forumPostRepo = $container->get(CForumPostRepository::class);
foreach ($items as $itemData) {
$id = $itemData['iid'];
$postId = $itemData['post_id'];
$postId = (int) $itemData['post_id'];
$path = $itemData['path'];
$fileName = $itemData['filename'];
@ -267,9 +272,11 @@ final class Version20201215160445 extends AbstractMigrationChamilo
if (!empty($fileName) && !empty($path)) {
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/forum/'.$path;
$this->addLegacyFileToResource($filePath, $forumPostRepo, $post, $id, $fileName);
$em->persist($post);
$em->flush();
if ($this->fileExists($filePath)) {
$this->addLegacyFileToResource($filePath, $forumPostRepo, $post, $id, $fileName);
$em->persist($post);
$em->flush();
}
}
}
$em->flush();

Loading…
Cancel
Save