$emailSubject = $translator->trans('Request for account deletion');
$emailContent = sprintf($translator->trans('User %s asked for the deletion of his/her account, explaining that : ').$explanation, $user->getFullName());
$emailContent = \sprintf($translator->trans('User %s asked for the deletion of his/her account, explaining that : ').$explanation, $user->getFullName());
$emailSubject = $translator->trans('Request for consent withdrawal on legal terms');
$emailContent = sprintf($translator->trans('User %s asked for the removal of his/her consent to our legal terms, explaining that: ').$explanation, $user->getFullName());
$emailContent = \sprintf($translator->trans('User %s asked for the removal of his/her consent to our legal terms, explaining that: ').$explanation, $user->getFullName());
@ -47,7 +47,7 @@ final class ResourceToIdentifierTransformer implements DataTransformerInterface
$this->identifier => $value,
]);
if (null === $resource) {
throw new TransformationFailedException(sprintf('Object "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
throw new TransformationFailedException(\sprintf('Object "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
final class Version20240811221400 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migration to update foreign key constraints, drop and create indexes, and alter table structures to ensure data consistency and prevent errors during execution.';
@ -16,7 +16,6 @@ final class Version20240811221400 extends AbstractMigrationChamilo
public function up(Schema $schema): void
{
$this->addSql('SET FOREIGN_KEY_CHECKS = 0;');
// resource_node
@ -599,6 +598,5 @@ final class Version20240811221400 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE notification_event CHANGE title title VARCHAR(255) NOT NULL, CHANGE content content LONGTEXT DEFAULT NULL, CHANGE link link LONGTEXT DEFAULT NULL, CHANGE event_type event_type VARCHAR(255) NOT NULL;');
}
@ -48,49 +48,49 @@ final class Version20240811221950 extends AbstractMigrationChamilo
private function dropColumnIfExists(Schema $schema, string $tableName, string $columnName): void
{
if ($this->columnExists($schema, $tableName, $columnName)) {
$this->addSql(sprintf('ALTER TABLE %s DROP COLUMN %s;', $tableName, $columnName));
$this->addSql(\sprintf('ALTER TABLE %s DROP COLUMN %s;', $tableName, $columnName));
}
}
private function dropIndexIfExists(Schema $schema, string $tableName, string $indexName): void
{
if ($this->indexExists($schema, $tableName, $indexName)) {
$this->addSql(sprintf('DROP INDEX %s ON %s;', $indexName, $tableName));
$this->addSql(\sprintf('DROP INDEX %s ON %s;', $indexName, $tableName));
}
}
private function dropForeignKeyIfExists(Schema $schema, string $tableName, string $foreignKeyName): void
{
if ($this->foreignKeyExists($schema, $tableName, $foreignKeyName)) {
$this->addSql(sprintf('ALTER TABLE %s DROP FOREIGN KEY %s;', $tableName, $foreignKeyName));
$this->addSql(\sprintf('ALTER TABLE %s DROP FOREIGN KEY %s;', $tableName, $foreignKeyName));
}
}
private function columnExists(Schema $schema, string $tableName, string $columnName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name='%s' AND column_name='%s';",
$tableName,
$columnName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name='%s' AND column_name='%s';",
$tableName,
$columnName
)) > 0;
}
private function indexExists(Schema $schema, string $tableName, string $indexName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema = DATABASE() AND table_name='%s' AND index_name='%s';",
$tableName,
$indexName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema = DATABASE() AND table_name='%s' AND index_name='%s';",
$tableName,
$indexName
)) > 0;
}
private function foreignKeyExists(Schema $schema, string $tableName, string $foreignKeyName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_schema = DATABASE() AND table_name='%s' AND constraint_name='%s';",
$tableName,
$foreignKeyName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_schema = DATABASE() AND table_name='%s' AND constraint_name='%s';",