Merge pull request #5064 from christianbeeznest/migration-quota

Migration: Change default disk quota to MB and migration
pull/5070/head
christianbeeznest 11 months ago committed by GitHub
commit e812514a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/CoreBundle/Migrations/Schema/V200/Version20240112103400.php
  2. 4
      src/CoreBundle/Settings/DocumentSettingsSchema.php

@ -8,6 +8,7 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\Repository\SettingsCurrentRepository;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
@ -28,18 +29,33 @@ final class Version20240112103400 extends AbstractMigrationChamilo
$kernel = $container->get('kernel');
$rootPath = $kernel->getProjectDir();
$settingRepo = $container->get(SettingsCurrentRepository::class);
$q = $em->createQuery('SELECT c FROM Chamilo\CoreBundle\Entity\Course c');
/** @var Course $course */
foreach ($q->toIterable() as $course) {
$diskQuotaInBytes = $course->getDiskQuota();
if (null !== $diskQuotaInBytes) {
if ($diskQuotaInBytes !== null) {
$diskQuotaInMegabytes = $diskQuotaInBytes / (1024 * 1024);
$course->setDiskQuota($diskQuotaInMegabytes);
$em->persist($course);
}
}
$em->flush();
$em->flush();
$setting = $settingRepo->findOneBy(['variable' => 'default_document_quotum']);
if ($setting) {
$selectedValueInBytes = (int) $setting->getSelectedValue() / (1024 * 1024);
$setting->setSelectedValue((string) $selectedValueInBytes);
}
$setting = $settingRepo->findOneBy(['variable' => 'default_group_quotum']);
if ($setting) {
$selectedValueInBytes = (int) $setting->getSelectedValue() / (1024 * 1024);
$setting->setSelectedValue((string) $selectedValueInBytes);
}
$em->flush();
}
}

@ -20,8 +20,8 @@ class DocumentSettingsSchema extends AbstractSettingsSchema
$builder
->setDefaults(
[
'default_document_quotum' => '1048576000',
'default_group_quotum' => '262144000',
'default_document_quotum' => '1000',
'default_group_quotum' => '250',
'permanently_remove_deleted_files' => 'false',
'upload_extensions_list_type' => 'blacklist',
'upload_extensions_blacklist' => '',

Loading…
Cancel
Save