PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/desktop-files/store.php +12 -5 1.1.41.1.10 View file →
@@ -118,11 +118,20 @@
118 118 // `<div class="wpdberror">…</div>` to the REST response body and
119 119 // break `await response.json()` on the client. `$wpdb->last_error`
120 120 // still holds the message, so genuine DB failures surface via the
121 121 // `WP_Error` we return when no existing row is found.
122 - $prev_suppress = $wpdb->suppress_errors( true );
123 - $ok = $wpdb->insert( $tables['placements'], $row, array( '%d', '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s' ) );
124 - $wpdb->suppress_errors( $prev_suppress );
122 + $insert = static function () use ( $tables, $row ) {
123 + global $wpdb;
124 + $prev_suppress = $wpdb->suppress_errors( true );
125 + $ok = $wpdb->insert( $tables['placements'], $row, array( '%d', '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s' ) );
126 + $wpdb->suppress_errors( $prev_suppress );
127 + return array( $ok, (int) $wpdb->insert_id );
128 + };
129 + $result = 'upload' === $type ? openstation_stored_files_place_insert( $ref, $insert ) : $insert();
130 + if ( is_wp_error( $result ) ) {
131 + return $result;
132 + }
133 + list( $ok, $id ) = $result;
125 134 if ( false === $ok ) {
126 135 // Disambiguate the two cases hidden behind a generic `false`:
127 136 // (a) The `placement_unique` index collided
128 137 // with an existing row for this (user, parent, type,
@@ -187,10 +196,8 @@
187 196 }
188 197
189 198 return $existing_id;
190 199 }
191 - $id = (int) $wpdb->insert_id;
192 -
193 200 $row['id'] = $id;
194 201
195 202 /**
196 203 * Fires after a placement is created.