Problem/Motivation

entity_reference_create_field() is only used in tests, and #2429191-10: Deprecate entity_reference.module and move its functionality to core asked for it to be moved to a test trait.

Proposed resolution

Create a EntityReferenceTestTrait and move entity_reference_create_field() inside it.

Remaining tasks

None.

User interface changes

Nope.

API changes

entity_reference_create_field() is moved to a test trait.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Unfrozen changes Unfrozen because it only changes tests.

Comments

vasike’s picture

Status: Active » Needs review
StatusFileSize
new15.11 KB
amateescu’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Needs review » Needs work

Looks great! I just found two small problems:

  1. +++ b/core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php
    @@ -19,6 +19,7 @@
    +  use EntityReferenceTestTrait;
    

    The trait is added here but its "add field" method is not used in the test :)

  2. +++ b/core/modules/entity_reference/src/Tests/EntityReferenceTestTrait.php
    @@ -0,0 +1,70 @@
    +use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
    

    This use statement is not needed.

vasike’s picture

Status: Needs work » Needs review
StatusFileSize
new14.56 KB

indeed. there is a new one.
thank you

amateescu’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Related issues: +#2429191: Deprecate entity_reference.module and move its functionality to core

Awesome! I grepped the codebase and entity_reference_create_field() is not used anywhere else, so we should be good to go here. Let's hope the testbot agrees.

Also updated the issue summary and added a beta evaluation.

The last submitted patch, 1: EntityReferenceTestTrait-implementation-2452619-1.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: EntityReferenceTestTrait-implementation-2452619-3.patch, failed testing.

Status: Needs work » Needs review
amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Testbot was acting up, back to rtbc.

joshtaylor’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new14.72 KB

Straight reroll due to latest core breakage.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

The reroll looks good.

tim.plunkett’s picture

+++ b/core/modules/entity_reference/src/Tests/EntityReferenceTestTrait.php
@@ -0,0 +1,69 @@
+  public function createEntityReferenceField($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array(), $cardinality = 1) {

Doesn't actually matter, but why is this public? Seems to be always called on $this->

amateescu’s picture

StatusFileSize
new14.72 KB
new1.05 KB

For no good reason :P

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Since entity_reference_create_field was only introduced in Drupal 8 I think it is okay to remove it. Also if contrib is using it already it really should not be - since fields should be created using CMI or using the Field and FieldStorage config entities directly.

Committed 60531a7 and pushed to 8.0.x. Thanks!

  • alexpott committed 60531a7 on 8.0.x
    Issue #2452619 by vasike, amateescu, joshtaylor: Move...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.