| @@ -17,41 +17,13 @@ | ||
| 17 | 17 | } |
| 18 | 18 | self::migratePaypal(); |
| 19 | 19 | $config = (object) []; |
| 20 | 20 | $config->delete_table = true; |
| 21 | - $this->duplicateV1StyleFiles(); | |
| 22 | 21 | update_option('bitform_app_config', $config); |
| 22 | + set_transient('bitforms_v1_form_contents', $newFormContents); | |
| 23 | 23 | return $newFormContents; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function rollbackToV1() | |
| 27 | - { | |
| 28 | - $this->dropTableAndRename('form', 'form_v1'); | |
| 29 | - $this->dropTableAndRename('workflows', 'workflows_v1'); | |
| 30 | - $this->dropTableAndRename('success_messages', 'success_messages_v1'); | |
| 31 | - $source = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles'; | |
| 32 | - MigrationHelper::recursiveDeleteFiles($source); | |
| 33 | - $destination = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1'; | |
| 34 | - MigrationHelper::recursiveCopyFiles($destination, $source); | |
| 35 | - MigrationHelper::recursiveDeleteFiles($destination); | |
| 36 | - if (file_exists($destination)) { | |
| 37 | - rmdir($destination); | |
| 38 | - } | |
| 39 | - delete_option('bitforms_migrating_to_v2'); | |
| 40 | - delete_option('bitforms_migrated_to_v2'); | |
| 41 | - } | |
| 42 | - | |
| 43 | - private function duplicateV1StyleFiles() | |
| 44 | - { | |
| 45 | - $source = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles'; | |
| 46 | - $destination = BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1'; | |
| 47 | - if (!file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1')) { | |
| 48 | - wp_mkdir_p(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles-v1'); | |
| 49 | - } | |
| 50 | - MigrationHelper::recursiveCopyFiles($source, $destination); | |
| 51 | - MigrationHelper::recursiveDeleteFiles($source); | |
| 52 | - } | |
| 53 | - | |
| 54 | 26 | private static function migratePaypal() |
| 55 | 27 | { |
| 56 | 28 | $integrationHandler = new IntegrationHandler(0); |
| 57 | 29 | $formIntegrations = $integrationHandler->getAllIntegration('app', 'payments'); |
| @@ -79,18 +51,9 @@ | ||
| 79 | 51 | { |
| 80 | 52 | global $wpdb; |
| 81 | 53 | $deleteTable = "{$wpdb->prefix}bitforms_{$deletedTableName}"; |
| 82 | 54 | $renameTable = "{$wpdb->prefix}bitforms_{$renamedTableName}"; |
| 83 | - // $wpdb->query("DROP TABLE IF EXISTS $deleteTable"); | |
| 84 | - // $wpdb->query("RENAME TABLE $renameTable TO $deleteTable"); | |
| 85 | - $wpdb->query( | |
| 86 | - $wpdb->prepare( | |
| 87 | - "DROP TABLE IF EXISTS $deleteTable" | |
| 88 | - ) | |
| 89 | - ); | |
| 90 | - $wpdb->query( | |
| 91 | - $wpdb->prepare( | |
| 92 | - "RENAME TABLE $renameTable TO $deleteTable" | |
| 93 | - ) | |
| 94 | - ); | |
| 55 | + // Schema migration: table name interpolation only. $wpdb->prepare() cannot parameterize DDL statements. | |
| 56 | + $wpdb->query("DROP TABLE IF EXISTS `{$deleteTable}`"); | |
| 57 | + $wpdb->query("RENAME TABLE `{$renameTable}` TO `{$deleteTable}`"); | |
| 95 | 58 | } |
| 96 | 59 | } |