PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | database/Migrations/TaxClassesMigrator.php +20 -4 1.4.0 → 1.6.5 View file →
@@ -150,10 +150,26 @@
150 150 }
151 151
152 152 public static function seedDefaultTaxClass()
153 153 {
154 - TaxClass::query()->firstOrCreate(
155 - ['slug' => 'standard'],
156 - ['title' => 'Standard']
157 - );
154 + global $wpdb;
155 +
156 + if (TaxClass::query()->where('slug', 'standard')->exists()) {
157 + return;
158 + }
159 +
160 + $table = static::getTableName();
161 +
162 + // INSERT IGNORE so a concurrent migration run that inserted the row
163 + // between our exists() check and this insert can't raise a
164 + // duplicate-entry error on the unique slug index.
165 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
166 + $wpdb->query($wpdb->prepare(
167 + "INSERT IGNORE INTO %i (`slug`, `title`, `created_at`, `updated_at`) VALUES (%s, %s, %s, %s)",
168 + $table,
169 + 'standard',
170 + 'Standard',
171 + current_time('mysql', true),
172 + current_time('mysql', true)
173 + ));
158 174 }
159 175 }