Download & Extend

Force reverting a mini panel in a feature deletes its block settings

Project:Panels
Version:7.x-3.x-dev
Component:Mini panels
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Steps to recreate:
1. Create a mini panel
2. Export it to a feature and add that feature to the drupal install
3. Change the block settings for the mini panel (e.g. move it into a new region)
4. Execute drush fr feature_name --force

The block settings will be deleted where the expected behavior would be for them to be left untouched.

This is because reverting a mini panel basically just deletes any database copy that might exist. The delete function is:

<?php
/**
* Remove a mini panel.
*/
function panels_mini_delete($mini) {
 
db_delete('panels_mini')
    ->
condition('name', $mini->name)
    ->
execute();

  if (
db_table_exists('block') && $mini->type != t('Overridden')) {
   
// Also remove from block table as long as there isn't a default that may appear.
   
db_delete('block')
      ->
condition('delta', $mini->name)
      ->
condition('module', 'panels_mini')
      ->
execute();
  }
 
panels_delete_display($mini->did);
}
?>

So if the mini panel isn't overridden (which it probably isn't if you're forcing a revert) it will also delete the block settings. :(

Solution is not to delete block settings when the delete is happening because of a revert. I'll attach patches in a reply.

Comments

#1

#2

Version:7.x-3.x-dev» 6.x-3.x-dev
AttachmentSize
panels-6.x-3.x-reverting-mini-panels-deletes-block-settings-1841782-2.patch 1.9 KB

#3

Version:6.x-3.x-dev» 7.x-3.x-dev
Status:active» needs review

#4

There's a bug is this patch... should be as $component is not defined

function panels_mini_features_revert($module) {
  if ($objects = features_get_default('panels_mini', $module)) {
    foreach ($objects as $object) {
      panels_mini_delete($object, FALSE);
    }
  }
}

#5

I think it would be better to just check for "in code" as well as "overridden" as reasons not to delete the block.

That wasn't considered a possibility because generally you can't call a delete on a mini panel that isn't in the database, but such a barrier would be simpler than this patch and should solve the problem.

#6

Status:needs review» needs work

#7

Status:needs work» needs review

Here's a quick patch to do as I suggested -- can someone experiencing this issue test it for me to make sure it resolves the problem?

AttachmentSize
1841782-features-force-revert.patch 617 bytes