At the moment RDF module does not support automated deletion of stored mappings for Content Types and Fields. This would result in inconsistency once the users edit or delete Content Types and fields associated. Thus this functionality should be added to the rdf module.

How to create a content type + mapping using Drush

Having a way to quickly create content types with their RDF mappings is going to be quite useful to test this issue.
These instructions assume you are starting from a vanilla Drupal site with the standard profile installed. It already includes mappings for article, user and the tags taxonomy term bundle. It also assumes you've already deleted the article content type (for example to test this issue). Here is how to recreate the article content type (and if needed its RDF mappings too) using Drush:

- Export your configuration in the staging area: drush config-export staging -y
- It should be missing the article content type YAML file
- copy the original article content type definition YAML file located in the standard profile into your site staging area: cp core/profiles/standard/config/install/node.type.article.yml sites/default/files/config_2T8.../staging/
- optionally also copy the article RDF mapping (rdf.mapping.node.article.yml) if those were deleted (as they should be once the patch is working
- Import all of the config present in the staging area into your site: drush config-import staging -y
- Visit the content type listing page, the article content type should be back!

CommentFileSizeAuthor
#99 2303541-99.patch16.71 KBjofitz
#94 2303541-94-interdiff.txt1023 byteslokapujya
#94 2303541-94.patch13.71 KBlokapujya
#92 2303541-92.patch13.72 KBlokapujya
#92 2303541-92-interdiff.txt3.07 KBlokapujya
#90 2303541-85b-interdiff.txt2.06 KBlokapujya
#87 2303541-86-interdiff.txt2.92 KBlokapujya
#87 2303541-86.patch14.18 KBlokapujya
#85 2303541-85-interdiff.txt4.37 KBlokapujya
#85 2303541-85.patch11.09 KBlokapujya
#82 2303541-82-interdiff.txt3.03 KBlokapujya
#82 2303541-82.patch9.44 KBlokapujya
#79 2303541-77-interdiff.txt956 byteslokapujya
#77 2303541-77.patch8.73 KBlokapujya
#73 2303541-73-interdiff.txt1.14 KBlokapujya
#73 2303541-73.patch8.7 KBlokapujya
#70 interdiff-2303541-70.txt3.52 KBlokapujya
#70 2303541-70.patch8.81 KBlokapujya
#66 2303541-66.patch6.68 KBlokapujya
#66 2303541-66-interdiff.txt1.41 KBlokapujya
#64 2303541-64.patch5.5 KBlokapujya
#64 2303541-64-interdiff.txt1.2 KBlokapujya
#62 2303541-test-only.patch4.9 KBlokapujya
#60 2303541-60.patch7.65 KBlokapujya
#57 2303541-57.patch8.22 KBSachini
#54 interdiff-2303541-50-54.txt7.24 KBSachini
#54 2303541-54.patch11.22 KBSachini
#50 interdiff-2303541-50.txt1.21 KBlokapujya
#50 2303541-50.patch7.88 KBlokapujya
#47 interdiff-2303541-47.txt2.45 KBlokapujya
#47 2303541-47.patch7.98 KBlokapujya
#42 interdiff-2303541-42.txt1.05 KBsuntog
#42 2303541-42.patch6.82 KBsuntog
#41 2303541-41.patch6.82 KBsuntog
#34 interdiff-2303541-34.patch1.89 KBlokapujya
#34 2303541-34.patch6.82 KBlokapujya
#32 interdiff-2303541-32.txt1.97 KBlokapujya
#32 2303541-32.patch6.24 KBlokapujya
#30 interdiff-2303541-30.txt1.7 KBlokapujya
#30 2303541-30.patch5.21 KBlokapujya
#28 interdiff-2303541-28.txt2.55 KBlokapujya
#28 2303541-28.patch5.09 KBlokapujya
#26 2303541-26.patch5.23 KBlokapujya
#23 2303541-interdiff-23.txt1.21 KBlokapujya
#23 2303541-23.patch5.07 KBlokapujya
#21 interdiff-2303541-21.txt792 byteslokapujya
#21 2303541-21.patch5.14 KBlokapujya
#19 2303541-19.patch4.94 KBlokapujya
#15 2303541-15.patch1.47 KBlokapujya
#12 interdiff-2303541-9-12.txt1.75 KBlokapujya
#12 2303541-12.patch2.71 KBlokapujya
#9 2303541-9.patch1.53 KBchrisfromredfin
#4 2303541-4.patch784 byteschrisfromredfin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scor’s picture

Issue tags: +RDF code sprint
lokapujya’s picture

Title: Add functionality to remove Content and Field Mappings » Add functionality to automatically remove Content and Field Mappings
Issue summary: View changes
scor’s picture

Issue summary: View changes
chrisfromredfin’s picture

Status: Active » Needs review
FileSize
784 bytes

Kicking the testbot. This is only a partial implementation, but would like comments and implementation at least looked over if someone has the opportunity. Next stop - implement hook_field_delete_field.

Status: Needs review » Needs work

The last submitted patch, 4: 2303541-4.patch, failed testing.

scor’s picture

Like we discussed, I would rather try to use rdf_get_mapping() if possible, and then act on that config entity.

chrisfromredfin’s picture

What I didn't like about that was that entity_load, if there is no mapping, returns FALSE. rdf_get_mapping will return me an structured array that will sort of "start me a mapping" if one does not exist. So then I'm testing for some particular structured array rather than a simple "FALSE."

I'd be happy to use rdf_get_mapping, but I feel like we might want ot change the function signature to add a (..., $return_empty = TRUE) or something. Alternatively, we could write "rdf_mapping_exists" but all it would do is call the entity_load.

Other thoughts?

scor’s picture

I think you had mentioned during our last sprint: we could also inspect the new empty mapping that rdf_get_mapping() returns, and detect that the mapping doesn't exist. I *think* I've seen the same logic of instantiating a new object in other APIs in core, but I don't remember which one it was (maybe config?).

chrisfromredfin’s picture

Status: Needs work » Needs review
FileSize
1.53 KB

1. I talked to Crell, who broke the tie. He agrees with you that if you can detect the empty case, better off calling the higher-level API over the lower one. I used the ->id property to detect if there was no mapping. So adjusted that code.

2. With help from chx, I was able to get pointed in the write hook direction for when a field instance is removed from an entity. In this case, there doesn't appear to really be a way to DELETE a field's mapping, only to set the mapping to empty. I don't love how this turns out in the yml when I config-export. It's still there, but set to an empty array. Not sure if we need a new function / API change.

chrisfromredfin’s picture

Mostly writing a note to myself here with a status update from the last sprint...

This patch passes tests primarily because it doesn't test its own case, btw. The two functions, combined, break on the first $mapping->save call when deleting an entire bundle (deleting the bundle must also invoke the hook to delete the individual fields, which makes sense).

For some reason that mapping->save() call dies "accessing a non-object" -- will need to fire up the debugger and figure out the timings. Alternatively, the right approach here is probably to use a ->deleteMapping() call (new) rather than mapping->save()ing an empty array into the mapping. That alone might solve the issue.

chrisfromredfin’s picture

Status: Needs review » Needs work

And back to NW.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
2.71 KB
1.75 KB

Added a deleteFieldMapping(). You still have to call save().

Started adding a test for "delete" to the crudTest.php, but maybe testing the automatic deletion of a mapping needs to be a web test (in order to trigger hook_ENTITY_TYPE_delete.)

scor’s picture

Added a deleteFieldMapping(). You still have to call save().

This looks great, Jamie!

Started adding a test for "delete" to the crudTest.php, but maybe testing the automatic deletion of a mapping needs to be a web test (in order to trigger hook_ENTITY_TYPE_delete.)

Why is a web test required to trigger hook_ENTITY_TYPE_delete? Can't you delete the entity_test entity type in a unit test?

Berdir’s picture

#2260457: Allow config entities to remove dependent configuration keys when dependencies are deleted due to module uninstall is related I think, and the ideas there to generalize deleting/cleaning-up related/dependant config entities when config entities are deleted. Right now, this deletion only happens when a module is uninstalled, and the cleanup there is also just done in that case. But we could possibly extend that to always use that system, instead of building multiple custom solutions.

Looking at RdfMapping::calculateDependencies(), it doesn't expose dependencies on defined fields yet, sounds like we should do that, similar to how EntityDisplayBase is doing it?

lokapujya’s picture

FileSize
1.47 KB

Let's try it. Note: we don't actually have a test for it here.

Status: Needs review » Needs work

The last submitted patch, 15: 2303541-15.patch, failed testing.

lokapujya’s picture

+++ b/core/modules/rdf/src/Entity/RdfMapping.php
@@ -147,6 +147,25 @@ public function calculateDependencies() {
+    // Create dependencies on both hidden and visible fields.
+    $fields = $this->content + $this->hidden;
+    foreach ($fields as $field_name => $component) {

Need to change the way I get the fields.

Berdir, would we need to wait for #2336727: Use configuration dependencies and onDependencyRemoval to standardise dependency management on configuration entity delete in order to use dependencies? and then implement something in onDependencyRemoval() that would only delete the mapping for just the field and not the whole bundle?

Berdir’s picture

If you add the dependencies, then you need to implement onDependencyRemoval() too, or the whole rdf mapping would get dropped when a field is deleted as part of a module uninstallation.

Once you have that, you can either continue with custom code for now or wait (hope? ;)) for the other issue to happen.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
4.94 KB

Adds a test to #17. Not using dependencies for now. Just want to get the test working. But when I delete() the field, the delete hooks are not triggered.

Status: Needs review » Needs work

The last submitted patch, 19: 2303541-19.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
5.14 KB
792 bytes

Delete the instance. Then, the delete hooks get triggered.

Status: Needs review » Needs work

The last submitted patch, 21: 2303541-21.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
5.07 KB
1.21 KB

Passed locally.

Status: Needs review » Needs work

The last submitted patch, 23: 2303541-23.patch, failed testing.

lokapujya’s picture

+++ b/core/modules/rdf/rdf.module
@@ -575,3 +576,34 @@ function template_preprocess_rdf_metadata(&$variables) {
+/**
+ * Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.
+ */
+function rdf_field_instance_config_delete(FieldInstanceConfigInterface $field_instance) {

This hook gets called when I run the test locally and all tests pass. But, on drupal.org, I can't tell if this hook is getting called. Appears not to be since the debug messages on 142/158 are the same.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
5.23 KB

Putting a debug() in the hook, to see if the hook gets called.

Result: It is not getting called. Reason why is in the next comment.

Status: Needs review » Needs work

The last submitted patch, 26: 2303541-26.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
5.09 KB
2.55 KB

1.) Rerolled due to #2312093: Rename FieldInstanceConfig to FieldConfig.
2.) Removed a debug().
3.) Changed the Assert (post delete) to be more specific.

scor’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -7,6 +7,7 @@
    +use Drupal\rdf\Tests\Field\FieldRdfaTestBase;
     use Drupal\simpletest\DrupalUnitTestBase;
    

    Looks like we are no longer using DrupalUnitTestBase, so maybe this line could be removed?

  2. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -38,10 +39,29 @@ class CrudTest extends DrupalUnitTestBase {
    +  protected $fieldType = 'email';
    

    any particular reason for using email as opposed to a regular text field? email is probably fine too.

  3. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -112,4 +132,34 @@ function testFieldMapping() {
    +    debug($field_mapping);
    

    did you intend to leave this debug() here?

  4. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -112,4 +132,34 @@ function testFieldMapping() {
    +    // Now delete the field.
    

    I was confused initially when reading this comment. We're deleting the field value from the entity. We're not deleting the field per se yet.

  5. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -112,4 +132,34 @@ function testFieldMapping() {
    +    debug($field_mapping);
    

    debug()

Shouldn't we also test the bundle deletion? or is that tested elsewhere?

lokapujya’s picture

Status: Needs work » Needs review
FileSize
5.21 KB
1.7 KB

Made some of the changes. Added some comments.

scor’s picture

Status: Needs review » Needs work

Thanks Jamie. I'm happy with those changes. The only thing remaining now it to also test rdf_entity_bundle_delete().

+++ b/core/modules/rdf/src/Tests/CrudTest.php
@@ -112,4 +131,33 @@ function testFieldMapping() {
+    // No specific reason for choosing an email field.

that comment feels a bit out of place. I don't think we need to say that anywhere.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
6.24 KB
1.97 KB

Tests automatic removal of the mapping by rdf_entity_bundle_delete().

scor’s picture

Status: Needs review » Needs work
+++ b/core/modules/rdf/src/Tests/CrudTest.php
@@ -38,10 +38,29 @@ class CrudTest extends DrupalUnitTestBase {
+    $this->createTestField();

@@ -112,4 +131,59 @@ function testFieldMapping() {
+    entity_test_create_bundle($this->bundle);
...
+    // Get the mapping again, now that it should have been deleted.
+    $field_mapping = rdf_get_mapping('entity_test', 'entity_test')
+      ->getFieldMapping($this->fieldName);

You should check that the entire bundle mapping is deleted, not just the particular field.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
6.82 KB
1.89 KB

Not sure why I needed to create the getId() function.

Fixed a bug in calculatedependecies. With calling save() on the rdf_mapping in the field_config_delete hook, and without checking to see if the object is empty, we got a fatal error.

Status: Needs review » Needs work

The last submitted patch, 34: interdiff-2303541-34.patch, failed testing.

lokapujya’s picture

+++ b/core/modules/rdf/src/Tests/CrudTest.php
@@ -179,11 +179,11 @@ public function testAutoDeleteAfterBundleDelete() {
+

Remove extra line.

lokapujya’s picture

+++ b/core/modules/rdf/src/Entity/RdfMapping.php
@@ -153,7 +160,9 @@ public function calculateDependencies() {
+      if(!empty($bundle_entity)) {

fix coding standard.

scor’s picture

was there a patch attached with your comments #36 and #37?

lokapujya’s picture

No, those were just statements; todos.

lokapujya’s picture

Issue tags: +Needs reroll
suntog’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.82 KB

Fixed a merge conflict.

suntog’s picture

cleaned up blank spaces

Status: Needs review » Needs work

The last submitted patch, 42: 2303541-42.patch, failed testing.

lokapujya queued 42: 2303541-42.patch for re-testing.

lokapujya’s picture

Status: Needs work » Needs review
chrisfromredfin’s picture

I reviewed the code, it all looks good to me. I'm not super familiar with the coding standards for 8, but what I do know of Drupal standards was all there.

I reviewed the behavior in practice -- added/deleted a field, checked the exported config, added a mapping, deleted the field, exported, checked the mapping. Deleted the whole bundle, verified that it was gone.

I ran a the CRUD tests locally--all passed.

FEEDBACK
[1] If I have anything to add, it seems like we're creating a test entity in setUp() and adding one field to it. Then we're removing the field and ensuring there's no mapping on the entity. A more thorough test might be that we add TWO fields to the test entity, then delete just ONE of them, and check the mapping for the whole bundle. This gives us a little bit more test coverage to ensure we're not over-reaching on our delete.

[2] Also, I see that getId() was created for the purpose of a solitary test to call it. Do we really need that? Can't we use ->id like elsewhere, or is it a different kind of ID or something?

lokapujya’s picture

1.) done.
2.) I guess we don't need getId()

plus, removed comment mentioned in #31

chrisfromredfin’s picture

getId() (and call to it) is still there... were you leaving it open for more discussion or should it be gone? I vote to lose it, personally.

lokapujya’s picture

I think I tried removing it and it seemed to work. But I somehow left out the change.

lokapujya’s picture

updated.

Status: Needs review » Needs work

The last submitted patch, 50: 2303541-50.patch, failed testing.

lokapujya queued 50: 2303541-50.patch for re-testing.

lokapujya’s picture

Status: Needs work » Needs review
Sachini’s picture

Re - rolling patch to apply cleanly at commit ffea3bb91d on 8.0.x, with improvements for CrudTest.

The function getId() in RdfMapping had to be introduced again as the fields were made protected. see https://www.drupal.org/node/2384531

lokapujya’s picture

Status: Needs review » Reviewed & tested by the community
scor’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/rdf/src/Tests/CrudTest.php
@@ -31,27 +31,46 @@ class CrudTest extends KernelTestBase {
-  protected $entityType;
+  protected $entity_type;

This should not be changed, it was fixed in #2381921: Clean-up RDF module test members - ensure property definition and use of camelCase naming convention to comply with the coding standards which recommends camelCase instead of under_score notations.

@lokapujya it's best practice to avoid RTBC'ing patches that contain code your wrote :) so that they are reviewed by someone neutral.

Sachini’s picture

Status: Needs work » Needs review
FileSize
8.22 KB

Sorry. Here's the patch with 'enitityType' restored.

Berdir’s picture

It is very likely that this will no longer be required very soon, see #2416409: Delete dependent config entities that don't implement onDependencyRemoval() when a config entity is deleted. That is completing the working that we started with automatic deletion of config based on dependencies.

I'd suggest to provide a test-only patch, that should still fail, and it will probably pass after the referenced issue landed.

lokapujya’s picture

I think we would still need to set up the dependencies in calculateDependencies().

In addition would we need to add the dependencies to existing .yml files? such as:
rdf.mapping.node.article.yml

lokapujya’s picture

First a reroll, but want to try using calculateDependencies().

Status: Needs review » Needs work

The last submitted patch, 60: 2303541-60.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

Just the test.

Status: Needs review » Needs work

The last submitted patch, 62: 2303541-test-only.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
1.2 KB
5.5 KB

Still test only, addressing issues with the tests.

Status: Needs review » Needs work

The last submitted patch, 64: 2303541-64.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
1.41 KB
6.68 KB

Attempting to set up the correct dependencies.

Status: Needs review » Needs work

The last submitted patch, 66: 2303541-66.patch, failed testing.

lokapujya’s picture

  1. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -147,7 +158,16 @@ public function calculateDependencies() {
    +      $mappings = $this->fieldMappings;
    +      $field_definitions = \Drupal::entityManager()->getFieldDefinitions($this->targetEntityType, $this->bundle);
    +      foreach (array_intersect_key($field_definitions, $mappings) as $field_name => $field_definition) {
    +        if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
    +          $this->addDependency('config', $field_definition->getConfigDependencyName());
    +        }
    +      }
    

    Here, I am adding a dependence for each of the field Mappings. However, I only want to set the the dependency for the field that is currently being saved. How do I know which field is being saved? Is it even possible?

  2. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -38,10 +38,29 @@ class CrudTest extends KernelTestBase {
    +    $mapping->setFieldMapping($this->fieldName, array(
    +      'properties' => array('schema:email'),
    +    ))->save();
    

    Since the saving happens here. It is not actually saving the field mapping; it is saving the mappings for all fields of the bundle.

lokapujya’s picture

I may need to go back to the custom deleting of field mappings in #57.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
8.81 KB
3.52 KB

Theoretically, by implementing onDependencyRemoval and returning TRUE, the rdf mapping should not get deleted. Instead, I remove the mapping for just the field that is getting deleted. However, it's still not working in my local testing.

lokapujya’s picture

Even if I just return True from onDependencyRemoval() and do nothing else, the Mapping for field 2 is still getting deleted.

Status: Needs review » Needs work

The last submitted patch, 70: 2303541-70.patch, failed testing.

lokapujya’s picture

lokapujya’s picture

Status: Needs work » Needs review

Ok, so that fixes the problem. Needed to use $this instead of retrieving the mapping. The remaining 3 are side effects of adding calculateDependencies. No clue yet why.

Status: Needs review » Needs work

The last submitted patch, 73: 2303541-73.patch, failed testing.

lokapujya’s picture

Issue tags: +SprintWeekendBOS
lokapujya’s picture

Status: Needs work » Needs review
FileSize
8.73 KB

StandardInstallerTest is failing. That sounds like something is could begetting deleted by calculateDependencies() unexpectedly. But the line that I'm editing in this patch seems to cause it.

Status: Needs review » Needs work

The last submitted patch, 77: 2303541-77.patch, failed testing.

lokapujya’s picture

FileSize
956 bytes

interdiff for 77. this was a wild guess but didn't fix the problem.

lokapujya’s picture

  1. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -147,13 +166,43 @@ public function calculateDependencies() {
    +    if (\Drupal::moduleHandler() && \Drupal::moduleHandler()->moduleExists('field')) {
    +      $mappings = $this->fieldMappings;
    +      $field_definitions = \Drupal::entityManager()->getFieldDefinitions($this->targetEntityType, $this->bundle);
    +      foreach (array_intersect_key($field_definitions, $mappings) as $field_name => $field_definition) {
    +        if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
    +          $this->addDependency('config', $field_definition->getConfigDependencyName());
    +        }
    +      }
    +    }
    

    If I comment this block out, the standardInstall test doesn't fail. I only get the expected fail from the RDF crudtest.

  2. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -147,13 +166,43 @@ public function calculateDependencies() {
    +      $mappings = $this->fieldMappings;
    +      $field_definitions = \Drupal::entityManager()->getFieldDefinitions($this->targetEntityType, $this->bundle);
    +      foreach (array_intersect_key($field_definitions, $mappings) as $field_name => $field_definition) {
    +        if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
    +          $this->addDependency('config', $field_definition->getConfigDependencyName());
    +        }
    +      }
    

    If I comment the inner block, I still get tthe standardInstall test fails.

lokapujya’s picture

#80 was a lie. Got 3 errors, but they were different errors.

I think I understand what is happening now. CalculateDependencies() actually changes configuration; It adds dependencies to the field mappings. Then the StandardInstallTest diffs the deployed config which doesn't have the dependencies in the RDF Mappings. So, I think what needs to happen is that the RDF Mappings deployed .yml needs to have the dependencies. I suspected this, as mentioned way back in comment #59, but forgot about it.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
9.44 KB
3.03 KB

Test out the theory above.

Status: Needs review » Needs work

The last submitted patch, 82: 2303541-82.patch, failed testing.

lokapujya’s picture

Good. That last patch fixed the errors that it was supposed to. There is still an issue with the bundle dependency. First of all, the test doesn't properly test to see if the bundle mapping gets removed. Then there are 2 PHPUnit test errors.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
11.09 KB
4.37 KB

Update the delete bundle test.

Status: Needs review » Needs work

The last submitted patch, 85: 2303541-85.patch, failed testing.

lokapujya’s picture

Satisfy the PHPUnit tests.

lokapujya’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 87: 2303541-86.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
2.06 KB

The remaining fail is from a new test that I added and left out of the interdiff. Here is the interdiff for the new test. This test if for testing the rdf mapping dependency on the bundle. I needed to use an article, because the test case requires having an entity that manages it's bundles using entities. Here is an interdiff that shows the added test.

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -68,6 +69,16 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
       /**
    +   *  Return the id.
    +   *
    +   * @return string
    +   *   The Unique ID for the config entity.
    +   */
    +  public function getId() {
    +    return $this->id;
    +  }
    

    I don't see why this is needed or added here. Every entity has an id() method. just use that. It might not be a great name, but there's no need to duplicate that.

  2. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -132,6 +143,14 @@ public function setFieldMapping($field_name, array $mapping = array()) {
       /**
        * {@inheritdoc}
        */
    +  public function deleteFieldMapping($field_name) {
    +    unset($this->fieldMappings[$field_name]);
    +    return $this;
    

    This is public and @inheritdoc but never defined anywhere on an interface. Does this really need to be public? If yes, it needs to be added and documented on the interface.

    Which is problematic because of BC. I would recommend to avoid this.

  3. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -142,18 +161,49 @@ public function id() {
    +        if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
    +          $this->addDependency('config', $field_definition->getConfigDependencyName());
    +        }
    

    not sure if this came up before but why limit it to field_config?

  4. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -142,18 +161,49 @@ public function id() {
    +        // There may not be a mapping that needs to be adjusted.
    +        if ($this->getId()) {
    

    I don't understand this.

  5. +++ b/core/modules/rdf/src/Entity/RdfMapping.php
    @@ -142,18 +161,49 @@ public function id() {
    +            $this->save();
    

    You're not supposed to save yourself. The API might just be checking if you could be changed or not.

  6. +++ b/core/modules/rdf/src/Tests/CrudTest.php
    @@ -112,4 +131,110 @@ function testFieldMapping() {
    +  public function ptestAutoDelete() {
    

    this test is disabled?

lokapujya’s picture

Status: Needs work » Needs review
FileSize
3.07 KB
13.72 KB

1. ok
2. The method can be private.
3. That was copied from EntityDisplayBase. Seems like it's not needed here.
4. Neither do I. It was copied from somewhere.
5. Thanks!
6. Oops.

How do you delete a bundle?
This is what the test is trying, but I'm not sure this is right:

+++ b/core/modules/rdf/src/Tests/NodeAttributesTest.php
@@ -94,5 +94,40 @@ function testNodeAttributes() {
+    // Now delete the bundle.
+    $bundles = \Drupal::state()->get('node.bundles') ?: array('node' => array('label' => 'Article'));
+    unset($bundles['article']);
+    \Drupal::state()->set('node.bundles', $bundles);
+    \Drupal::entityManager()->onBundleDelete('article', 'node');

Status: Needs review » Needs work

The last submitted patch, 92: 2303541-92.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
13.71 KB
1023 bytes

Try a different way of deleting the bundle.

lokapujya’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lokapujya’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The test is failing on 8.2.x. Something changed since this was written for 8.0.x.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
16.71 KB

Re-roll.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

With rdf being removed in D10 wondering if this is still an issue?

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

RDF is moving out of core and into https://www.drupal.org/project/rdf.

To keep the ball moving closing this as outdated since this moved to PNMI. If still a valid bug please reopen under the contrib module.