Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Controller/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private function deleteBackupAction(): void
if ($db_file) {
$db_file_path = $this->getBackupFilePath($db_file, ['sql']);
if (empty($db_file_path) || false === file_exists($db_file_path)) {
Tools::log()->error('file-not-found');
Tools::log()->error('file-not-found', ['%fileName%' => $db_file]);
return;
}

Expand All @@ -290,7 +290,7 @@ private function deleteBackupAction(): void
if ($zip_file) {
$zip_file_path = $this->getBackupFilePath($zip_file, ['zip']);
if (empty($zip_file_path) || false === file_exists($zip_file_path)) {
Tools::log()->error('file-not-found');
Tools::log()->error('file-not-found', ['%fileName%' => $zip_file]);
return;
}

Expand All @@ -317,7 +317,7 @@ private function downloadSqlAction(): void

$file_path = $this->getBackupFilePath($file_name, ['sql']);
if (empty($file_path) || false === file_exists($file_path)) {
Tools::log()->error('file-not-found');
Tools::log()->error('file-not-found', ['%fileName%' => $file_name]);
return;
}

Expand All @@ -342,7 +342,7 @@ private function downloadZipAction(): void

$file_path = $this->getBackupFilePath($file_name, ['zip']);
if (empty($file_path) || false === file_exists($file_path)) {
Tools::log()->error('file-not-found');
Tools::log()->error('file-not-found', ['%fileName%' => $file_name]);
return;
}

Expand Down Expand Up @@ -399,7 +399,7 @@ protected function loadBackupFiles(): void
// buscamos todos los archivos de la carpeta MyFiles/Backups
$folder = Tools::folder('MyFiles', 'Backups');
if (false === Tools::folderCheckOrCreate($folder)) {
Tools::log()->error('folder-create-error');
Tools::log()->error('backup-folder-create-error');
return;
}

Expand Down Expand Up @@ -697,16 +697,16 @@ private function restoreFilesAction(): void
return;
}

if ($this->restoreFilesFromZip($zipFile->getPathname())) {
if ($this->restoreFilesFromZip($zipFile->getPathname(), $zipFile->getClientOriginalName())) {
Tools::log()->notice('record-updated-correctly');
}
}

private function restoreFilesFromZip(string $zipPath): bool
private function restoreFilesFromZip(string $zipPath, string $zipName): bool
{
$zip = new ZipArchive();
if (true !== $zip->open($zipPath)) {
Tools::log()->error('zip error');
Tools::log()->error('backup-zip-open-error', ['%zipFile%' => $zipName]);
return false;
}

Expand All @@ -720,7 +720,7 @@ private function restoreFilesFromZip(string $zipPath): bool

// eliminamos lo que se haya podido extraer antes del error
Tools::folderDelete($tmpFolder);
Tools::log()->error('zip extract error');
Tools::log()->error('backup-zip-extract-error', ['%zipFile%' => $zipName]);
return false;
}
$zip->close();
Expand Down
4 changes: 2 additions & 2 deletions Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ protected function applyBackupLimit(): void
protected function createBackup(): void
{
if (false === BackupSQL::generate(self::JOB_NAME)) {
Tools::log(self::JOB_NAME)->error('sql-file-error');
Tools::log(self::JOB_NAME)->error('backup-sql-error');
return;
}

if (false === BackupFile::generate(self::JOB_NAME)) {
Tools::log(self::JOB_NAME)->error('zip-file-error');
Tools::log(self::JOB_NAME)->error('backup-zip-error');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Lib/BackupFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function generate(string $channel = ''): bool
{
$folder = Tools::folder('MyFiles', 'Backups');
if (false === Tools::folderCheckOrCreate($folder)) {
Tools::log($channel)->error('folder-create-error');
Tools::log($channel)->error('backup-folder-create-error');
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Lib/BackupSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function generate(string $channel = ''): bool
{
$folder = Tools::folder('MyFiles', 'Backups');
if (false === Tools::folderCheckOrCreate($folder)) {
Tools::log($channel)->error('folder-create-error');
Tools::log($channel)->error('backup-folder-create-error');
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Test/main/BackupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ private function restoreFilesFromZip(string $zipPath): bool
$method = $reflection->getMethod('restoreFilesFromZip');
$method->setAccessible(true);

return $method->invoke($controller, $zipPath);
return $method->invoke($controller, $zipPath, basename($zipPath));
}
}
2 changes: 1 addition & 1 deletion Test/main/BackupFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private function restoreFilesFromZip(string $zipPath): void
$method = $reflection->getMethod('restoreFilesFromZip');
$method->setAccessible(true);

$this->assertTrue($method->invoke($controller, $zipPath), 'No se pudieron restaurar los archivos del ZIP');
$this->assertTrue($method->invoke($controller, $zipPath, basename($zipPath)), 'No se pudieron restaurar los archivos del ZIP');
}

protected function tearDown(): void
Expand Down
17 changes: 15 additions & 2 deletions Translation/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
"backup": "Backup",
"backup-charset-error": "The backup encoding is %db-charset%, while in config.php it is %config-charset%. Press the change encoding button before restoring.",
"backup-charset-mixed-warning": "Warning: The backup contains tables with multiple encodings (%charsets%). Your current configuration is %config-charset%.",
"backup-created": "Backup created successfully.",
"backup-deleted": "Backup deleted due to the limit: %file%",
"backup-empty-warning": "The backup was generated empty. Check it before using it.",
"backup-file-too-big": "The backup file is too large to upload to the server. The maximum size is %size% MB",
"backup-files-error": "Error al comprimir los archivos de la copia de seguridad: %error%",
"backup-files-error": "Error compressing the backup files: %error%",
"backup-folder-create-error": "The backup folder (MyFiles\/Backups) could not be created. Check the write permissions.",
"backup-memory-warning": "Warning: the backup takes %size% MB, but you only have %memory% MB of memory available. Insufficient to perform the backup.",
"backup-port-warning": "The MySQL port should be 3306, but you are using %port%",
"backup-restore-error": "Error restoring the backup: %error%",
"backup-restore-strict-mode": "The MySQL server has innodb_strict_mode enabled and some table exceeds the maximum row size. Ask your provider to disable innodb_strict_mode in the MySQL configuration, or to grant the SESSION_VARIABLES_ADMIN privilege to the database user.",
"backup-sql-error": "Error generating the database backup.",
"backup-use-fixer-plugin": "It is recommended to use the Fixer plugin to correct table encodings before creating backups.",
"config-mysql-charset-error": "Encoding constants are missing in the config.php file ('%config-charset%', '%config-collate%')",
"backup-zip-error": "Error generating the files backup.",
"backup-zip-extract-error": "The zip file '%zipFile%' could not be extracted. Check that there is disk space and write permissions in MyFiles.",
"backup-zip-open-error": "The zip file '%zipFile%' could not be opened. Check that it is a valid files backup.",
"config-file-error": "The config.php file could not be read.",
"config-mysql-charset-error": "The encoding '%selected-charset%' is not valid. The current configuration is '%config-charset%', '%config-collate%'.",
"download-backup": "Download backup",
"download-backup-p": "Download a backup copy of your database and another of your files. Keep these files in a safe place. If at any time you want to restore FacturaScripts data, you will need these files.",
"file-ready-to-download": "File ready for download",
Expand All @@ -20,6 +31,8 @@
"new-admin-password": "New administrator password",
"new-admin-password-confirm": "Confirm password",
"new-admin-password-p": "Optional. Set a new password for the administrator user after the restoration. Leave empty to keep the backup password.",
"no-file-received": "No file has been received.",
"not-allowed-import": "You do not have permission to import",
"restore-admin-access": "Administrator access",
"restore-admin-access-p": "Optional. You can change the existing admin password or create a new administrator user to ensure access after the restoration.",
"restore-admin-create-user": "Create new administrator user",
Expand Down
15 changes: 14 additions & 1 deletion Translation/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
"backup": "Copia de seguridad",
"backup-charset-error": "La codificación de la copia de seguridad es %db-charset%, mientras que en el config.php es %config-charset%. Pulsa el botón cambiar codificación antes de restaurar.",
"backup-charset-mixed-warning": "Advertencia: La copia de seguridad contiene tablas con múltiples codificaciones (%charsets%). Tu configuración actual es %config-charset%.",
"backup-created": "Copia de seguridad creada correctamente.",
"backup-deleted": "Copia de seguridad eliminada por límite: %file%",
"backup-empty-warning": "La copia de seguridad se ha generado vacía. Revísala antes de usarla.",
"backup-file-too-big": "El archivo de copia de seguridad es demasiado grande para subirlo al servidor. El tamaño máximo es %size% MB",
"backup-files-error": "Error al comprimir los archivos de la copia de seguridad: %error%",
"backup-folder-create-error": "No se ha podido crear la carpeta de copias de seguridad (MyFiles\/Backups). Comprueba los permisos de escritura.",
"backup-memory-warning": "Advertencia: la copia de seguridad ocupa %size% MB, pero solamente tienes %memory% MB de memoria RAM disponible. Insuficiente para realizar la copia de seguridad. Como alternativa puedes comprimir la carpeta de FacturaScripts, que es equivalente a una copia de los archivos.",
"backup-port-warning": "El puerto de MySQL debe ser el 3306, pero estás usando el %port%",
"backup-restore-error": "Error al restaurar la copia de seguridad: %error%",
"backup-restore-strict-mode": "El servidor MySQL tiene activado innodb_strict_mode y alguna tabla supera el tamaño máximo de fila. Pide a tu proveedor que desactive innodb_strict_mode en la configuración de MySQL, o que conceda al usuario de la base de datos el privilegio SESSION_VARIABLES_ADMIN.",
"backup-sql-error": "Error al generar la copia de seguridad de la base de datos.",
"backup-use-fixer-plugin": "Se recomienda usar el plugin Fixer para corregir las codificaciones de las tablas antes de realizar copias de seguridad.",
"config-mysql-charset-error": "Faltan las constantes de codificación en el archivo config.php ('%config-charset%', '%config-collate%')",
"backup-zip-error": "Error al generar la copia de seguridad de los archivos.",
"backup-zip-extract-error": "No se ha podido extraer el archivo zip '%zipFile%'. Comprueba que hay espacio en disco y permisos de escritura en MyFiles.",
"backup-zip-open-error": "No se ha podido abrir el archivo zip '%zipFile%'. Comprueba que es una copia de archivos válida.",
"config-file-error": "No se ha podido leer el archivo config.php.",
"config-mysql-charset-error": "La codificación '%selected-charset%' no es válida. La configuración actual es '%config-charset%', '%config-collate%'.",
"download-backup": "Descargar copia de seguridad",
"download-backup-p": "Descarga una copia de seguridad de tu base de datos y otra de tus archivos. Guarda estos ficheros en un lugar seguro. Si en algún momento quieres restaurar los datos de FacturaScripts, necesitarás estos ficheros.",
"file-ready-to-download": "Archivo listo para descargar",
Expand All @@ -20,6 +31,8 @@
"new-admin-password": "Nueva contraseña del administrador",
"new-admin-password-confirm": "Confirmar contraseña",
"new-admin-password-p": "Opcional. Establece una nueva contraseña para el usuario administrador tras la restauración. Déjalo vacío para conservar la contraseña del backup.",
"no-file-received": "No se ha recibido ningún archivo.",
"not-allowed-import": "No tiene permiso para importar",
"restore-admin-access": "Acceso del administrador",
"restore-admin-access-p": "Opcional. Puedes cambiar la contraseña del admin existente o crear un nuevo usuario administrador para garantizar el acceso tras la restauración.",
"restore-admin-create-user": "Crear nuevo usuario administrador",
Expand Down
Loading