From 87c224c106a85d85319851919a113d69f4bcd5ae Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Mon, 16 Nov 2026 09:46:08 +0100 Subject: [PATCH 1/4] fix: indicar el archivo en los avisos de copia no encontrada --- Controller/Backup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/Backup.php b/Controller/Backup.php index ef5abd9..1161363 100644 --- a/Controller/Backup.php +++ b/Controller/Backup.php @@ -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; } @@ -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; } @@ -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; } @@ -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; } From 21091acee1f225d728963ad4465fe918e51cc3f1 Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Mon, 16 Nov 2026 10:05:21 +0100 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20indicar=20el=20zip=20en=20los?= =?UTF-8?q?=20errores=20de=20restauraci=C3=B3n=20de=20archivos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/Backup.php | 8 ++++---- Test/main/BackupControllerTest.php | 2 +- Test/main/BackupFileTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/Backup.php b/Controller/Backup.php index 1161363..b3379db 100644 --- a/Controller/Backup.php +++ b/Controller/Backup.php @@ -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; } @@ -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(); diff --git a/Test/main/BackupControllerTest.php b/Test/main/BackupControllerTest.php index 15ef831..ea608b9 100644 --- a/Test/main/BackupControllerTest.php +++ b/Test/main/BackupControllerTest.php @@ -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)); } } diff --git a/Test/main/BackupFileTest.php b/Test/main/BackupFileTest.php index 5fd2de6..216c48f 100644 --- a/Test/main/BackupFileTest.php +++ b/Test/main/BackupFileTest.php @@ -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 From 0fd592dec39e1365ae5bd1a094c73ac209ae4994 Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Mon, 16 Nov 2026 10:17:35 +0100 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20usar=20el=20prefijo=20backup-?= =?UTF-8?q?=20en=20las=20claves=20de=20traducci=C3=B3n=20del=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/Backup.php | 2 +- Cron.php | 4 ++-- Lib/BackupFile.php | 2 +- Lib/BackupSQL.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Controller/Backup.php b/Controller/Backup.php index b3379db..678e0cc 100644 --- a/Controller/Backup.php +++ b/Controller/Backup.php @@ -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; } diff --git a/Cron.php b/Cron.php index f6b005d..9b501b3 100644 --- a/Cron.php +++ b/Cron.php @@ -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; } diff --git a/Lib/BackupFile.php b/Lib/BackupFile.php index 48ad4a3..10ab526 100644 --- a/Lib/BackupFile.php +++ b/Lib/BackupFile.php @@ -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; } diff --git a/Lib/BackupSQL.php b/Lib/BackupSQL.php index d749e60..d8c603e 100644 --- a/Lib/BackupSQL.php +++ b/Lib/BackupSQL.php @@ -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; } From 8ee26b9f65f4361690c56fe0590a3c5d2886ae19 Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Mon, 16 Nov 2026 10:18:08 +0100 Subject: [PATCH 4/4] chore: actualizar traducciones --- Translation/en_EN.json | 17 +++++++++++++++-- Translation/es_ES.json | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Translation/en_EN.json b/Translation/en_EN.json index 5fdee38..aa82d44 100644 --- a/Translation/en_EN.json +++ b/Translation/en_EN.json @@ -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", @@ -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", diff --git a/Translation/es_ES.json b/Translation/es_ES.json index 453a539..d0064d7 100644 --- a/Translation/es_ES.json +++ b/Translation/es_ES.json @@ -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", @@ -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",