Performance

When migrating content, suspend cache invalidation and flush the cache afterwards.

With that in mind, the following optimisation reduces the number of database queries to 1:

-		$post_data = [
-			'ID' => $post_id,
-			'post_content' => $content,
-		];
-
-		$updated = wp_update_post( $post_data, true );
+		$updated = $wpdb->update(
+			$wpdb->posts,
+			[
+				'post_content' => $content,
+			],
+			[
+				'ID' => $post_id,
+			]
+		);

Revision #4
Created 21 September 2023 09:07:01 by Sander
Updated 21 September 2023 10:32:31 by Sander