Index: src/wp-includes/theme.php
===================================================================
--- src/wp-includes/theme.php	(revision 39474)
+++ src/wp-includes/theme.php	(working copy)
@@ -1786,9 +1786,13 @@
 		$r = wp_update_post( wp_slash( $post_data ), true );
 	} else {
 		$r = wp_insert_post( wp_slash( $post_data ), true );
+		// Trigger creation of a revision. See #30854
+		if ( ! is_wp_error( $r ) && 0 === count( wp_get_post_revisions( $r ) ) ) {
+			wp_save_post_revision( $r );
+		}
 	}
 
-	if ( $r instanceof WP_Error ) {
+	if ( is_wp_error( $r ) ) {
 		return $r;
 	}
 	return get_post( $r );
Index: tests/phpunit/tests/customize/custom-css-setting.php
===================================================================
--- tests/phpunit/tests/customize/custom-css-setting.php	(revision 39474)
+++ tests/phpunit/tests/customize/custom-css-setting.php	(working copy)
@@ -193,6 +193,25 @@
 	}
 
 	/**
+	 * Test revision saving on initial save of Custom CSS.
+	 *
+	 * @ticket 39032
+	 */
+	function test_custom_css_revision_saved() {
+		$r = wp_update_custom_css_post( 'body { background: black; }', array(
+			'stylesheet' => 'testtheme',
+		) );
+
+		$this->assertCount( 1, wp_get_post_revisions( $r ) );
+
+		wp_update_custom_css_post( 'body { background: red; }', array(
+			'stylesheet' => 'testtheme',
+		) );
+
+		$this->assertCount( 2, wp_get_post_revisions( $r ) );
+	}
+
+	/**
 	 * Test crud methods on WP_Customize_Custom_CSS_Setting.
 	 *
 	 * @covers WP_Customize_Custom_CSS_Setting::value()
