 jsonapi.services.yml                               |  4 +-
 src/Controller/EntityResource.php                  | 40 +++++++++++++-
 tests/src/Functional/BlockContentTest.php          |  2 +-
 tests/src/Functional/NodeTest.php                  |  5 ++
 tests/src/Functional/ResourceTestBase.php          | 62 +++++++++++++++++-----
 tests/src/Kernel/Controller/EntityResourceTest.php |  4 +-
 6 files changed, 100 insertions(+), 17 deletions(-)

diff --git a/jsonapi.services.yml b/jsonapi.services.yml
index 09b77d6..61953e3 100644
--- a/jsonapi.services.yml
+++ b/jsonapi.services.yml
@@ -145,7 +145,7 @@ services:
 
   # Controller.
   jsonapi.entity_resource:
-    class: \Drupal\jsonapi\Controller\EntityResource
+    class: Drupal\jsonapi\Controller\EntityResource
     arguments:
       - '@entity_type.manager'
       - '@entity_field.manager'
@@ -156,6 +156,8 @@ services:
       - '@jsonapi.entity_access_checker'
       - '@jsonapi.field_resolver'
       - '@jsonapi.serializer'
+      - '@datetime.time'
+      - '@current_user'
   jsonapi.file_upload:
     class: Drupal\jsonapi\Controller\FileUpload
     arguments:
diff --git a/src/Controller/EntityResource.php b/src/Controller/EntityResource.php
index b61a8f9..478e29d 100644
--- a/src/Controller/EntityResource.php
+++ b/src/Controller/EntityResource.php
@@ -3,6 +3,7 @@
 namespace Drupal\jsonapi\Controller;
 
 use Drupal\Component\Assertion\Inspector;
+use Drupal\Component\Datetime\TimeInterface;
 use Drupal\Component\Serialization\Json;
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Config\Entity\ConfigEntityInterface;
@@ -14,12 +15,15 @@ use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Entity\Query\QueryInterface;
+use Drupal\Core\Entity\RevisionableEntityBundleInterface;
 use Drupal\Core\Entity\RevisionableInterface;
 use Drupal\Core\Entity\RevisionableStorageInterface;
+use Drupal\Core\Entity\RevisionLogInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Render\RenderContext;
 use Drupal\Core\Render\RendererInterface;
+use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Url;
 use Drupal\jsonapi\Access\EntityAccessChecker;
 use Drupal\jsonapi\Context\FieldResolver;
@@ -129,6 +133,20 @@ class EntityResource {
    */
   protected $serializer;
 
+  /**
+   * The time service.
+   *
+   * @var \Drupal\Component\Datetime\TimeInterface
+   */
+  protected $time;
+
+  /**
+   * The current user account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $user;
+
   /**
    * Instantiates a EntityResource object.
    *
@@ -150,8 +168,12 @@ class EntityResource {
    *   The JSON:API field resolver.
    * @param \Symfony\Component\Serializer\SerializerInterface|\Symfony\Component\Serializer\Normalizer\DenormalizerInterface $serializer
    *   The JSON:API serializer.
+   * @param \Drupal\Component\Datetime\TimeInterface $time
+   *   The time service.
+   * @param \Drupal\Core\Session\AccountInterface $user
+   *   The current user account.
    */
-  public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $field_manager, ResourceTypeRepositoryInterface $resource_type_repository, RendererInterface $renderer, EntityRepositoryInterface $entity_repository, IncludeResolver $include_resolver, EntityAccessChecker $entity_access_checker, FieldResolver $field_resolver, SerializerInterface $serializer) {
+  public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $field_manager, ResourceTypeRepositoryInterface $resource_type_repository, RendererInterface $renderer, EntityRepositoryInterface $entity_repository, IncludeResolver $include_resolver, EntityAccessChecker $entity_access_checker, FieldResolver $field_resolver, SerializerInterface $serializer, TimeInterface $time, AccountInterface $user) {
     $this->entityTypeManager = $entity_type_manager;
     $this->fieldManager = $field_manager;
     $this->resourceTypeRepository = $resource_type_repository;
@@ -161,6 +183,8 @@ class EntityResource {
     $this->entityAccessChecker = $entity_access_checker;
     $this->fieldResolver = $field_resolver;
     $this->serializer = $serializer;
+    $this->time = $time;
+    $this->user = $user;
   }
 
   /**
@@ -299,6 +323,20 @@ class EntityResource {
     }, $entity);
 
     static::validate($entity, $field_names);
+
+    // Set revision data details for revisionable entities.
+    if ($entity->getEntityType()->isRevisionable()) {
+      $bundle_storage = $this->entityTypeManager->getStorage($entity->getEntityType()->getBundleEntityType());
+      $bundle_entity = $bundle_storage->load($entity->bundle());
+      if ($bundle_entity instanceof RevisionableEntityBundleInterface) {
+        $entity->setNewRevision($bundle_entity->shouldCreateNewRevision());
+      }
+      if ($entity instanceof RevisionLogInterface) {
+        $entity->setRevisionUserId($this->user->id());
+        $entity->setRevisionCreationTime($this->time->getRequestTime());
+      }
+    }
+
     $entity->save();
     $primary_data = new ResourceObjectData([ResourceObject::createFromEntity($resource_type, $entity)], 1);
     return $this->buildWrappedResponse($primary_data, $request, $this->getIncludes($request, $primary_data));
diff --git a/tests/src/Functional/BlockContentTest.php b/tests/src/Functional/BlockContentTest.php
index 9cd9ff0..c70c4be 100644
--- a/tests/src/Functional/BlockContentTest.php
+++ b/tests/src/Functional/BlockContentTest.php
@@ -61,7 +61,7 @@ class BlockContentTest extends ResourceTestBase {
       $block_content_type = BlockContentType::create([
         'id' => 'basic',
         'label' => 'basic',
-        'revision' => TRUE,
+        'revision' => FALSE,
       ]);
       $block_content_type->save();
       block_content_add_body_field($block_content_type->id());
diff --git a/tests/src/Functional/NodeTest.php b/tests/src/Functional/NodeTest.php
index 7f8b572..7c61934 100644
--- a/tests/src/Functional/NodeTest.php
+++ b/tests/src/Functional/NodeTest.php
@@ -42,6 +42,11 @@ class NodeTest extends ResourceTestBase {
    */
   protected static $resourceTypeIsVersionable = TRUE;
 
+  /**
+   * {@inheritdoc}
+   */
+  protected static $newRevisionsShouldBeAutomatic = TRUE;
+
   /**
    * {@inheritdoc}
    *
diff --git a/tests/src/Functional/ResourceTestBase.php b/tests/src/Functional/ResourceTestBase.php
index 8003c2e..4293111 100644
--- a/tests/src/Functional/ResourceTestBase.php
+++ b/tests/src/Functional/ResourceTestBase.php
@@ -17,6 +17,7 @@ use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityPublishedInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Entity\RevisionableInterface;
+use Drupal\Core\Entity\RevisionLogInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Field\Plugin\Field\FieldType\BooleanItem;
@@ -146,6 +147,13 @@ abstract class ResourceTestBase extends BrowserTestBase {
    */
   protected static $labelFieldName = NULL;
 
+  /**
+   * Whether new revisions of updated entities should be created by default.
+   *
+   * @var bool
+   */
+  protected static $newRevisionsShouldBeAutomatic = FALSE;
+
   /**
    * Whether anonymous users can view labels of this resource type.
    *
@@ -326,7 +334,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
     \Drupal::service('router.builder')->rebuildIfNeeded();
 
     // Reload entity so that it has the new field.
-    $reloaded_entity = $this->entityStorage->loadUnchanged($entity->id());
+    $reloaded_entity = $this->entityLoadUnchanged($entity->id());
     // Some entity types are not stored, hence they cannot be reloaded.
     if ($reloaded_entity !== NULL) {
       $entity = $reloaded_entity;
@@ -1964,7 +1972,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
     $this->assertFalse($response->hasHeader('X-Drupal-Cache'));
     // If the entity is stored, perform extra checks.
     if (get_class($this->entityStorage) !== ContentEntityNullStorage::class) {
-      $created_entity = $this->entityStorage->loadUnchanged(static::$firstCreatedEntityId);
+      $created_entity = $this->entityLoadUnchanged(static::$firstCreatedEntityId);
       $uuid = $created_entity->uuid();
       // @todo Remove line below in favor of commented line in https://www.drupal.org/project/jsonapi/issues/2878463.
       $location = Url::fromRoute(sprintf('jsonapi.%s.individual', static::$resourceTypeName), ['entity' => $uuid]);
@@ -2068,7 +2076,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
       return;
     }
 
-    $original_revision_id = (int) $this->entity->getRevisionId();
+    $prior_revision_id = (int) $this->entityLoadUnchanged($this->entity->id())->getRevisionId();
 
     // Patch testing requires that another entity of the same type exists.
     $this->anotherEntity = $this->createAnotherEntity('dupe');
@@ -2193,6 +2201,9 @@ abstract class ResourceTestBase extends BrowserTestBase {
     $request_options[RequestOptions::BODY] = Json::encode($valid_request_body);
     $response = $this->request('PATCH', $url, $request_options);
     $this->assertResourceResponse(200, FALSE, $response);
+    $updated_entity = $this->entityLoadUnchanged($this->entity->id());
+    $this->assertSame(static::$newRevisionsShouldBeAutomatic, $prior_revision_id < (int) $updated_entity->getRevisionId());
+    $prior_revision_id = (int) $updated_entity->getRevisionId();
 
     $request_options[RequestOptions::BODY] = $parseable_valid_request_body;
     $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/xml';
@@ -2209,10 +2220,19 @@ abstract class ResourceTestBase extends BrowserTestBase {
     $this->assertFalse($response->hasHeader('X-Drupal-Cache'));
     // Assert that the entity was indeed updated, and that the response body
     // contains the serialized updated entity.
-    $updated_entity = $this->entityStorage->loadUnchanged($this->entity->id());
-    $this->assertSame($original_revision_id, (int) $updated_entity->getRevisionId());
+    $updated_entity = $this->entityLoadUnchanged($this->entity->id());
+    $this->assertSame(static::$newRevisionsShouldBeAutomatic, $prior_revision_id < (int) $updated_entity->getRevisionId());
+    if ($this->entity instanceof RevisionLogInterface) {
+      if (static::$newRevisionsShouldBeAutomatic) {
+        $this->assertNotSame((int) $this->entity->getRevisionCreationTime(), (int) $updated_entity->getRevisionCreationTime());
+      }
+      else {
+        $this->assertSame((int) $this->entity->getRevisionCreationTime(), (int) $updated_entity->getRevisionCreationTime());
+      }
+    }
     $updated_entity_document = $this->normalize($updated_entity, $url);
     $this->assertSame($updated_entity_document, Json::decode((string) $response->getBody()));
+    $prior_revision_id = (int) $updated_entity->getRevisionId();
     // Assert that the entity was indeed created using the PATCHed values.
     foreach ($this->getPatchDocument()['data']['attributes'] as $field_name => $field_normalization) {
       // If the value is an array of properties, only verify that the sent
@@ -2247,9 +2267,10 @@ abstract class ResourceTestBase extends BrowserTestBase {
     $request_options[RequestOptions::BODY] = Json::encode($doc_remove_item, 'api_json');
     $response = $this->request('PATCH', $url, $request_options);
     $this->assertResourceResponse(200, FALSE, $response);
-    $updated_entity = $this->entityStorage->loadUnchanged($this->entity->id());
+    $updated_entity = $this->entityLoadUnchanged($this->entity->id());
     $this->assertSame([0 => ['value' => 'Two']], $updated_entity->get('field_rest_test_multivalue')->getValue());
-    $this->assertSame($original_revision_id, (int) $updated_entity->getRevisionId());
+    $this->assertSame(static::$newRevisionsShouldBeAutomatic, $prior_revision_id < (int) $updated_entity->getRevisionId());
+    $prior_revision_id = (int) $updated_entity->getRevisionId();
 
     // Multi-value field: add one item before the existing one, and one after.
     $doc_add_items = $doc_multi_value_tests;
@@ -2262,9 +2283,10 @@ abstract class ResourceTestBase extends BrowserTestBase {
       1 => ['value' => 'Two'],
       2 => ['value' => 'Three'],
     ];
-    $updated_entity = $this->entityStorage->loadUnchanged($this->entity->id());
+    $updated_entity = $this->entityLoadUnchanged($this->entity->id());
     $this->assertSame($expected_document, $updated_entity->get('field_rest_test_multivalue')->getValue());
-    $this->assertSame($original_revision_id, (int) $updated_entity->getRevisionId());
+    $this->assertSame(static::$newRevisionsShouldBeAutomatic, $prior_revision_id < (int) $updated_entity->getRevisionId());
+    $prior_revision_id = (int) $updated_entity->getRevisionId();
 
     // Finally, assert that when Content Moderation is installed, a new revision
     // is automatically created when PATCHing for entity types that have a
@@ -2291,13 +2313,13 @@ abstract class ResourceTestBase extends BrowserTestBase {
       1 => ['value' => 'Two'],
       2 => ['value' => '3'],
     ];
-    $updated_entity = $this->entityStorage->loadUnchanged($this->entity->id());
+    $updated_entity = $this->entityLoadUnchanged($this->entity->id());
     $this->assertSame($expected_document, $updated_entity->get('field_rest_test_multivalue')->getValue());
     if ($this->entity->getEntityType()->hasHandlerClass('moderation')) {
-      $this->assertNotSame($original_revision_id, (int) $updated_entity->getRevisionId());
+      $this->assertLessThan((int) $updated_entity->getRevisionId(), $prior_revision_id);
     }
     else {
-      $this->assertSame($original_revision_id, (int) $updated_entity->getRevisionId());
+      $this->assertSame(static::$newRevisionsShouldBeAutomatic, $prior_revision_id < (int) $updated_entity->getRevisionId());
     }
 
     // Ensure that PATCHing an entity that is not the latest revision is
@@ -2667,7 +2689,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
     ])->setLabel('Revisionable text field')->setTranslatable(FALSE)->save();
 
     // Reload entity so that it has the new field.
-    $entity = $this->entityStorage->loadUnchanged($this->entity->id());
+    $entity = $this->entityLoadUnchanged($this->entity->id());
 
     // Set up test data.
     /* @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
@@ -3344,4 +3366,18 @@ abstract class ResourceTestBase extends BrowserTestBase {
     $this->grantPermissionsToTestedRole($flattened_permissions);
   }
 
+  /**
+   * Loads an entity in the test container, ignoring the static cache.
+   *
+   * @param int $id
+   *   The entity ID.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface|null
+   *   The loaded entity.
+   */
+  protected function entityLoadUnchanged($id) {
+    $this->entityStorage->resetCache();
+    return $this->entityStorage->loadUnchanged($id);
+  }
+
 }
diff --git a/tests/src/Kernel/Controller/EntityResourceTest.php b/tests/src/Kernel/Controller/EntityResourceTest.php
index c07d007..7270b63 100644
--- a/tests/src/Kernel/Controller/EntityResourceTest.php
+++ b/tests/src/Kernel/Controller/EntityResourceTest.php
@@ -196,7 +196,9 @@ class EntityResourceTest extends JsonapiKernelTestBase {
       $this->container->get('jsonapi.include_resolver'),
       $this->container->get('jsonapi.entity_access_checker'),
       $this->container->get('jsonapi.field_resolver'),
-      $this->container->get('jsonapi.serializer')
+      $this->container->get('jsonapi.serializer'),
+      $this->container->get('datetime.time'),
+      $this->container->get('current_user')
     );
   }
 
