I've searched the issue queue, but I haven't found an issue dealing with my question:

Let's say a user created an FPP on a page and then the FPP is deleted through the listing under admin/structure/filedable-panels-panes/example-pane/delete. You end up with a "Placeholder for empty or inaccessible "Deleted/removed entity pane" on the page where the FPP was initially added.

Is there a way to handle the deletion of FPP's and also delete any references to the FPP on any pages?
Can I for instance implement a hook_entity_delete() that deletes any rows with the corresponding FPP id (fpid) from the panels_pane table or is that solution too crude?

If there is no way for that: is there any negative impact on performance resulting from the references to non-existing FPP's?

Comments

Marty2081’s picture

Title: How to handle empty placeholders when a FPP is deleted? » How to handle empty placeholders when an FPP is deleted?
Marty2081’s picture

I've implemented the following and that seems to do the trick:

/**
 * Implements hook_entity_delete().
 *
 * Clean up any references to the deleted fieldable_panels_pane from the
 * panels_pane table.
 */
function YOUR_MODULE_entity_delete($entity, $type) {
  if ($type == 'fieldable_panels_pane') {
    db_delete('panels_pane')
      ->condition('type', 'fieldable_panels_pane', '=')
      ->condition('subtype', 'fpid:' . $entity->fpid, '=')
      ->execute();
  }
}

Is there any reason not to implement it like this?

rozh’s picture

FPP's also can be deleted with contextual links. And it is not obvious that you have to edit panel page and delete empty placeholder after you have deleted FPP entity.

I know nothing about performance impact but with error messages enabled I can see notices about missing FPP's:
Notice: Undefined index: bundle in fieldable_panels_panes_load_from_subtype() (line 995 of /home/d1ncj/www/sites/default/modules/fieldable_panels_panes/fieldable_panels_panes.module)