A given panel can have multiple variants, with selection rules used to determine which one is used. They are queried in order of weight, and the first variant found with a successful selection rule is the variant which is used, so the weights are critical data (for instance, you need your special-case variants to be lighter than the 'default' variant you wish to fall through to if the special-case rules do not match).

In the case of the page_manager_handlers component (node_view and term_view panels, for instance), these variant weights are not exported and imported. Changing the weights does not change the status of the feature.

CTools definitely includes the variant weight (as $handler->weight) if I manually export a variant, so I'm guessing this is something which is missing from Features.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

barraponto’s picture

I guess the $handler->weight refers to the page_manager handler, not the variant. But then, I don't know how to export them either. Just posting to say this bug bites me too.

Sergii’s picture

I just checked $handler->weight is the variant weight.
I manually put different weight to exported feature (in file) and after reinstailling the variants weights were precisely such.

Sergii’s picture

And the problem is that when ctools build object in ctools_export_load_object it takes weight not from page_manager_weights table, but from property 'weight' in 'page_manager_handlers'. Maybe these should be syncronized.

Sergii’s picture

He-he, they did it on purpose, but forgot to include into export procedure. See

/**
 * Set an overidden weight for a task handler.
 *
 * We do this so that in-code task handlers don't need to get written
 * to the database just because they have their weight changed.
 */
function page_manager_update_task_handler_weight($handler, $weight) {
hefox’s picture

So, is this a ctools or features bug?

Sergii’s picture

And here's patch. Don't forget to clean cache before using.

Sergii’s picture

Status: Active » Needs review
hefox’s picture

Project: Features » Chaos Tool Suite (ctools)
Status: Needs review » Needs work

So, tis a ctools issue.

Patch is done from root of site instead of root of ctools (cd to ctools directory and use --relative).

merlinofchaos’s picture

The weight should be properly handled with the task handler is loaded, not when it is exported. How could it possibly work correctly otherwise?

jweowu’s picture

Status: Needs work » Needs review
FileSize
1.22 KB

#6 re-rolled via a checkout of ctools

jweowu’s picture

Status: Needs review » Needs work

I missed #9 while generating the patch. I'm guessing that means it's back to "needs work".

Sergii’s picture

The weight should be properly handled with the task handler is loaded, not when it is exported. How could it possibly work correctly otherwise?

It's not possible to alter anything on the load stage: ctools_export_load_object

I tested again my patch and it seems it's not possible to revert weights if there's no appropriate database record.
Here's my idea is to add extra ['export']['load callback'] which simulates correct 'export_type' on the export stage.
Now ctools_component_features_revert checks the state and there's no ways to force deletion.

/**
 * Master implementation of hook_features_revert() for all ctools components.
 */
function ctools_component_features_revert($component, $module) {
  if ($objects = features_get_default($component, $module)) {
    foreach ($objects as $name => $object) {
      // Some things (like views) do not use the machine name as key
      // and need to be loaded explicitly in order to be deleted.
      $object = ctools_export_crud_load($component, $name);
      if ($object && ($object->export_type & EXPORT_IN_DATABASE)) {
        _ctools_features_export_crud_delete($component, $object);
      }
    }
  }
}

The patch is in the attachment.

Sergii’s picture

Status: Needs work » Needs review
FileSize
2.2 KB

Sorry, there's the relative one

Sergii’s picture

I tested moving of weight to 'load callback' and it works.
Another one patch.

tim.plunkett’s picture

Status: Needs review » Needs work
+++ b/page_manager/page_manager.moduleundefined
@@ -697,6 +697,31 @@ function page_manager_export_task_handler($handler, $indent = '') {
+ * Since weight is duplicated across the tables:

Function summary must be one line, and start with a verb.

+++ b/page_manager/page_manager.moduleundefined
@@ -697,6 +697,31 @@ function page_manager_export_task_handler($handler, $indent = '') {
+ * ¶

Missing @param and @return docs

+++ b/page_manager/page_manager.moduleundefined
@@ -697,6 +697,31 @@ function page_manager_export_task_handler($handler, $indent = '') {
+  ¶

Trailing whitespace

Sergii’s picture

Status: Needs work » Needs review
FileSize
2.3 KB

Documentation fixed. Please review.

merlinofchaos’s picture

I believe this would be more efficient query-wise if we used the 'load subrecords callback' instead. Plus it should also be less code.

Sergii’s picture

I think it's not possible.
'subrecords callback' modifies only $cache variable which contains no $handler object if handler exported to code.

jweowu’s picture

Re-rolling #16 to apply cleanly.

jweowu’s picture

Initial testing seems good. For my node_view and term_view panels, drush features-revert now correctly sets the variant weights as they were when the feature was exported. I tried a few simple cases of re-ordering and reverting, and nothing unexpected happened.

Thanks Sergii.

acbramley’s picture

Applied patch #19, reexported my panels feature and weights are now correctly shown in the export, moved a variant around, then reverted and it went back to the correct spot +1 RTBC

jweowu’s picture

As a follow-up, I haven't encountered any problems with this patch since installing it, so I'd call it "tested" at least.

Do comment 17 and 18 still need discussion? If Sergii is correct about that, and people are otherwise happy with the code, then this could presumably be considered RTBC.

Josh Waihi’s picture

Reroll with ctools 7.x-1.1

Status: Needs review » Needs work

The last submitted patch, page_manager_weight_export-1371436-20.patch, failed testing.

Josh Waihi’s picture

Status: Needs work » Needs review
FileSize
2.4 KB

Whoops, set the base dir as page_manager rather than ctools. Now fixed.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed and pushed #25.

Status: Fixed » Closed (fixed)

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

danielnolde’s picture

Damn, though the commit exists, it doesn't seem to work (anymore?).
Variant weights of panel pages are not exported/reverted correctly (using ctools-7.x-1.3+3-dev, panels-7.x-3.3+41-dev and features-7.x-2.0-rc1.
Bad combination of module version, or can anyone reproduce that this still not working?

Begun’s picture

I can confirm the same problem here. We are using:

  • features 7.x-2.0-rc1
  • ctools 7.x-1.2
  • panel 7.x-3.2
acbramley’s picture

Using:

Panels 7.x-3.3
Features 7.x-2.0-rc3 (you should at least upgrade this)
CTools 7.x-1.3

It works perfectly

acbramley’s picture

Issue summary: View changes

typo/rewording