diff options
| author | 2014-08-11 19:18:12 +0200 | |
|---|---|---|
| committer | 2014-08-11 19:18:12 +0200 | |
| commit | 8ffd59f34ac458827f2a0217e4630caf69705853 (patch) | |
| tree | 2e05b9f8df5a51ba8d89974e5523e962542fc2a5 /app | |
| parent | 94570aaf5a23dfc02bf1120d168ec30c2ab3f044 (diff) | |
Improve import system
Catch errors of zip_open and log it. A notification is shown to indicate
something went wrong.
See https://github.com/marienfressinaud/FreshRSS/issues/494
Diffstat (limited to 'app')
| -rw-r--r-- | app/Controllers/importExportController.php | 14 | ||||
| -rw-r--r-- | app/i18n/en.php | 1 | ||||
| -rw-r--r-- | app/i18n/fr.php | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index dd6c23322..15871ed80 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -42,6 +42,20 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { if ($type_file === 'zip' && extension_loaded('zip')) { $zip = zip_open($file['tmp_name']); + if (!is_resource($zip)) { + Minz_Log::error( + 'Zip file cannot be imported. Error code: ' . $zip + ); + + // zip_open cannot open file: something is wrong + Minz_Session::_param('notification', array( + 'type' => 'bad', + 'content' => _t('zip_error') + )); + + Minz_Request::forward(array('c' => 'importExport'), true); + } + while (($zipfile = zip_read($zip)) !== false) { $type_zipfile = $this->guessFileType( zip_entry_name($zipfile) diff --git a/app/i18n/en.php b/app/i18n/en.php index 0c87f52be..416ca851f 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'File to import<br />(OPML, Json or Zip)', 'file_to_import_no_zip' => 'File to import<br />(OPML or Json)', 'import' => 'Import', + 'zip_error' => 'An error occured during Zip import.', 'no_zip_extension' => 'Zip extension is not present on your server.', 'export' => 'Export', 'export_opml' => 'Export list of feeds (OPML)', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 57ddebc20..d68006a87 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'Fichier à importer<br />(OPML, Json ou Zip)', 'file_to_import_no_zip' => 'Fichier à importer<br />(OPML ou Json)', 'import' => 'Importer', + 'zip_error' => 'Une erreur est survenue durant l’import du fichier Zip.', 'no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur.', 'export' => 'Exporter', 'export_opml' => 'Exporter la liste des flux (OPML)', |
