]> git.agnieray.net Git - galette.git/commitdiff
Rename old dynamic files on contributions; refs #1697
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 8 Oct 2023 14:47:11 +0000 (16:47 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 8 Oct 2023 14:47:11 +0000 (16:47 +0200)
galette/lib/Galette/Controllers/Crud/DynamicFieldsController.php

index 6d5ac798d9f35f40aa403af2fa5c9dc083b25876..9c4bb28144c51b639a326fd89bb0b0699662833c 100644 (file)
@@ -357,6 +357,29 @@ class DynamicFieldsController extends CrudController
             '%form_%oid_field_%fid_value_%pos'
         );
 
+        if ($form_name !== 'member' && !file_exists(GALETTE_FILES_PATH . $filename)) {
+            //handle old names for non adh dynamic files
+            $test_filename = str_replace(
+                [
+                    '%form',
+                    '%oid',
+                    '%fid',
+                    '%pos'
+                ],
+                [
+                    'member',
+                    $id,
+                    $fid,
+                    $pos
+                ],
+                '%form_%oid_field_%fid_value_%pos'
+            );
+            if (file_exists(GALETTE_FILES_PATH . $test_filename)) {
+                //rename old file to new name
+                rename(GALETTE_FILES_PATH . $test_filename, GALETTE_FILES_PATH . $filename);
+            }
+        }
+
         if (file_exists(GALETTE_FILES_PATH . $filename)) {
             $type = File::getMimeType(GALETTE_FILES_PATH . $filename);