Do not save entity in generateSampleValue

Created on 17 October 2023, 9 months ago

Problem/Motivation

Working on a page where content is generated programatically, I'm generate dummy paragraph entities. Unfortunately, entities are created for real (e.g. saved in database) every time I load the page.

This is caused by the call to $entity->save() in \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::generateSampleValue.

Steps to reproduce

$storage = \Drupal::entityTypeManager()->getStorage('paragraph');
$entity = $storage->createWithSampleValues('my_paragraph_type', ['parent_type' => 'node']);
// OMG the $entity is already saved! I didn't want it too be :(

Proposed resolution

Do not save the entity in generate sample value.

Remaining tasks

Review and accept the PR.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024