PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.02
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmMigrate.php +11 -171 6.25.15.2.02 View file →
@@ -35,29 +35,22 @@
35 35 if ( $needs_upgrade ) {
36 36 // update rewrite rules for views and other custom post types
37 37 flush_rewrite_rules();
38 38
39 - require_once ABSPATH . 'wp-admin/includes/upgrade.php';
39 + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
40 40
41 41 $old_db_version = get_option( 'frm_db_version' );
42 42
43 43 $this->create_tables();
44 44 $this->migrate_data( $old_db_version );
45 - $this->check_that_tables_exist();
46 45
47 - // SAVE DB VERSION.
46 + /***** SAVE DB VERSION *****/
48 47 update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version );
49 48
50 49 if ( ! $old_db_version ) {
51 50 $this->maybe_create_contact_form();
52 -
53 - if ( false === get_option( 'frm_first_activation' ) ) {
54 - update_option( 'frm_first_activation', time(), false );
55 - }
56 -
57 - $this->update_settings_for_new_install();
58 51 }
59 - }//end if
52 + }
60 53
61 54 do_action( 'frm_after_install' );
62 55
63 56 $frm_vars['doing_upgrade'] = false;
@@ -70,55 +63,8 @@
70 63 $frm_style->update( 'default' );
71 64 }
72 65 }
73 66
74 - /**
75 - * Updates some settings for new installs.
76 - *
77 - * @since 6.23
78 - */
79 - private function update_settings_for_new_install() {
80 - $settings = FrmAppHelper::get_settings();
81 -
82 - $settings->denylist_check = 1;
83 - $settings->installed_after_welcome_tour_update = 1;
84 - $settings->store();
85 - }
86 -
87 - /**
88 - * If we fail to create the database tables, add an inbox notice.
89 - * This informs the user that they need to correct the issue and try again.
90 - *
91 - * @since 6.19
92 - *
93 - * @return void
94 - */
95 - private function check_that_tables_exist() {
96 - // Check the DB that the table $this->forms exists.
97 - global $wpdb;
98 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $this->forms ) );
99 -
100 - if ( $exists ) {
101 - $inbox = new FrmInbox();
102 - $inbox->dismiss( 'failed-to-create-tables' );
103 - return;
104 - }
105 -
106 - $message = array(
107 - 'key' => 'failed-to-create-tables',
108 - 'subject' => 'Something went wrong setting up the database',
109 - 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">documentation</a>. If you need assistance, we recommend that you reach out to your hosting provider. Then <a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_add_tables=1' ) ) . '">click here</a> to try again.',
110 - 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>',
111 - 'type' => 'error',
112 - );
113 -
114 - $inbox = new FrmInbox();
115 - $inbox->add_message( $message );
116 - }
117 -
118 - /**
119 - * @return string
120 - */
121 67 public function collation() {
122 68 global $wpdb;
123 69 if ( ! $wpdb->has_cap( 'collation' ) ) {
124 70 return '';
@@ -211,77 +157,10 @@
211 157 $wpdb->query( $q . $charset_collate ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
212 158 }
213 159 unset( $q );
214 160 }
215 -
216 - $this->add_composite_indexes_for_entries();
217 161 }
218 162
219 - /**
220 - * These indexes help optimize database queries for entries.
221 - *
222 - * @since 6.6
223 - * @since 6.16.3 idx_form_id_is_draft was also added to frm_items.
224 - * @since 6.17 idx_form_id_type was also added to frm_fields.
225 - *
226 - * @return void
227 - */
228 - private function add_composite_indexes_for_entries() {
229 - global $wpdb;
230 -
231 - $table_name = "{$wpdb->prefix}frm_items";
232 - $index_name = 'idx_is_draft_created_at';
233 -
234 - if ( ! self::index_exists( $table_name, $index_name ) ) {
235 - $wpdb->query( "CREATE INDEX idx_is_draft_created_at ON `{$wpdb->prefix}frm_items` (is_draft, created_at)" );
236 - }
237 -
238 - $table_name = "{$wpdb->prefix}frm_item_metas";
239 - $index_name = 'idx_field_id_item_id';
240 -
241 - if ( ! self::index_exists( $table_name, $index_name ) ) {
242 - $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
243 - }
244 -
245 - $table_name = "{$wpdb->prefix}frm_items";
246 - $index_name = 'idx_form_id_is_draft';
247 -
248 - if ( ! self::index_exists( $table_name, $index_name ) ) {
249 - $wpdb->query( "CREATE INDEX idx_form_id_is_draft ON `{$wpdb->prefix}frm_items` (form_id, is_draft)" );
250 - }
251 -
252 - $table_name = "{$wpdb->prefix}frm_fields";
253 - $index_name = 'idx_form_id_type';
254 -
255 - if ( ! self::index_exists( $table_name, $index_name ) ) {
256 - $wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" );
257 - }
258 - }
259 -
260 - /**
261 - * Check that an index exists in a database table before trying to add it (which results in an error).
262 - *
263 - * @since 6.6
264 - *
265 - * @param string $table_name
266 - * @param string $index_name
267 - * @return bool
268 - */
269 - private static function index_exists( $table_name, $index_name ) {
270 - global $wpdb;
271 - $row = $wpdb->get_row(
272 - $wpdb->prepare(
273 - 'SELECT 1 FROM information_schema.statistics
274 - WHERE table_schema = database()
275 - AND table_name = %s
276 - AND index_name = %s
277 - LIMIT 1',
278 - array( $table_name, $index_name )
279 - )
280 - );
281 - return (bool) $row;
282 - }
283 -
284 163 private function maybe_create_contact_form() {
285 164 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
286 165 if ( ! $form_exists ) {
287 166 $this->add_default_template();
@@ -325,9 +204,9 @@
325 204 // bail if we don't know the previous version
326 205 return;
327 206 }
328 207
329 - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 );
208 + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98 );
330 209 foreach ( $migrations as $migration ) {
331 210 if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) {
332 211 $function_name = 'migrate_to_' . $migration;
333 212 $this->$function_name();
@@ -354,10 +233,9 @@
354 233 delete_option( 'frm_lite_settings_upgrade' );
355 234 delete_option( 'frm-usage-uuid' );
356 235 delete_option( 'frm_inbox' );
357 236 delete_option( 'frmpro_css' );
358 - delete_option( FrmOnboardingWizardController::REDIRECT_STATUS_OPTION );
359 - delete_option( FrmEmailSummaryHelper::$option_name );
237 + delete_option( 'frm_welcome_redirect' );
360 238
361 239 // Delete roles.
362 240 $frm_roles = FrmAppHelper::frm_capabilities();
363 241 $roles = get_editable_roles();
@@ -386,9 +264,9 @@
386 264 // delete transients
387 265 delete_transient( 'frmpro_css' );
388 266 delete_transient( 'frm_options' );
389 267 delete_transient( 'frmpro_options' );
390 - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );
268 + delete_transient( 'frm_activation_redirect' );
391 269
392 270 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
393 271
394 272 do_action( 'frm_after_uninstall' );
@@ -396,46 +274,8 @@
396 274 return true;
397 275 }
398 276
399 277 /**
400 - * In older versions of Lite, it's possible we've saved the wrong location ID.
401 - * So force it to get valid values again.
402 - *
403 - * @since 6.25
404 - *
405 - * @return void
406 - */
407 - private function migrate_to_104() {
408 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) {
409 - FrmSquareLiteConnectHelper::get_location_id( true, 'test' );
410 - }
411 -
412 - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) {
413 - FrmSquareLiteConnectHelper::get_location_id( true, 'live' );
414 - }
415 - }
416 -
417 - /**
418 - * Disables summary email for multisite (not the main site) if recipient setting isn't changed.
419 - *
420 - * @since 6.8
421 - */
422 - private function migrate_to_101() {
423 - if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) {
424 - return;
425 - }
426 -
427 - $frm_settings = FrmAppHelper::get_settings();
428 - if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) {
429 - // User changed it.
430 - return;
431 - }
432 -
433 - $frm_settings->summary_emails = 0;
434 - $frm_settings->store();
435 - }
436 -
437 - /**
438 278 * Clear frmpro_css transient.
439 279 *
440 280 * @since 4.10.02
441 281 */
@@ -478,9 +318,9 @@
478 318 }
479 319 }
480 320
481 321 /**
482 - * Delete unneeded default templates
322 + * Delete uneeded default templates
483 323 *
484 324 * @since 3.06
485 325 */
486 326 private function migrate_to_90() {
@@ -500,9 +340,9 @@
500 340 $fields = $this->get_fields_with_size();
501 341
502 342 foreach ( (array) $fields as $f ) {
503 343 FrmAppHelper::unserialize_or_decode( $f->field_options );
504 - $size = $f->field_options['size'];
344 + $size = $f->field_options['size'];
505 345 $this->maybe_convert_migrated_size( $size );
506 346
507 347 if ( $size === $f->field_options['size'] ) {
508 348 continue;
@@ -604,9 +444,9 @@
604 444 return;
605 445 }
606 446
607 447 foreach ( $styles as $style ) {
608 - if ( $style->post_content['field_width'] === '400px' ) {
448 + if ( $style->post_content['field_width'] == '400px' ) {
609 449 $style->post_content['field_width'] = '100%';
610 450 $frm_style->save( (array) $style );
611 451
612 452 return;
@@ -670,9 +510,9 @@
670 510
671 511 private function convert_character_to_px( &$size ) {
672 512 $pixel_conversion = 9;
673 513
674 - $size = round( $pixel_conversion * (int) $size );
514 + $size = round( $pixel_conversion * (int) $size );
675 515 $size .= 'px';
676 516 }
677 517
678 518 /**
@@ -744,9 +584,9 @@
744 584 $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
745 585 $draft_link = FrmFormsHelper::get_draft_link();
746 586 foreach ( $forms as $form ) {
747 587 FrmAppHelper::unserialize_or_decode( $form->options );
748 - if ( empty( $form->options['submit_html'] ) ) {
588 + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
749 589 continue;
750 590 }
751 591
752 592 if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {