PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +52 -0 6.36.7 View file →
@@ -157,10 +157,61 @@
157 157 $wpdb->query( $q . $charset_collate ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
158 158 }
159 159 unset( $q );
160 160 }
161 +
162 + $this->add_composite_indexes_for_entries();
161 163 }
162 164
165 + /**
166 + * These indexes help optimize database queries for entries.
167 + *
168 + * @since 6.6
169 + *
170 + * @return void
171 + */
172 + private function add_composite_indexes_for_entries() {
173 + global $wpdb;
174 +
175 + $table_name = "{$wpdb->prefix}frm_items";
176 + $index_name = 'idx_is_draft_created_at';
177 +
178 + if ( ! self::index_exists( $table_name, $index_name ) ) {
179 + $wpdb->query( "CREATE INDEX idx_is_draft_created_at ON `{$wpdb->prefix}frm_items` (is_draft, created_at)" );
180 + }
181 +
182 + $table_name = "{$wpdb->prefix}frm_item_metas";
183 + $index_name = 'idx_field_id_item_id';
184 +
185 + if ( ! self::index_exists( $table_name, $index_name ) ) {
186 + $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
187 + }
188 + }
189 +
190 + /**
191 + * Check that an index exists in a database table before trying to add it (which results in an error).
192 + *
193 + * @since 6.6
194 + *
195 + * @param string $table_name
196 + * @param string $index_name
197 + * @return bool
198 + */
199 + private static function index_exists( $table_name, $index_name ) {
200 + global $wpdb;
201 + $row = $wpdb->get_row(
202 + $wpdb->prepare(
203 + 'SELECT 1 FROM information_schema.statistics
204 + WHERE table_schema = database()
205 + AND table_name = %s
206 + AND index_name = %s
207 + LIMIT 1',
208 + array( $table_name, $index_name )
209 + )
210 + );
211 + return (bool) $row;
212 + }
213 +
163 214 private function maybe_create_contact_form() {
164 215 $form_exists = FrmForm::get_id_by_key( 'contact-form' );
165 216 if ( ! $form_exists ) {
166 217 $this->add_default_template();
@@ -234,8 +285,9 @@
234 285 delete_option( 'frm-usage-uuid' );
235 286 delete_option( 'frm_inbox' );
236 287 delete_option( 'frmpro_css' );
237 288 delete_option( 'frm_welcome_redirect' );
289 + delete_option( FrmEmailSummaryHelper::$option_name );
238 290
239 291 // Delete roles.
240 292 $frm_roles = FrmAppHelper::frm_capabilities();
241 293 $roles = get_editable_roles();