Problem/Motivation

Mini panels can use the context of the active page manager page.

Depending on how the block render call is invoked, the wrong type of entity context can be loaded, for example a taxonomy term can be loaded as a node.

This will cause a panels mini block to be rendered even though a required context does not exist.

In certain circumstances it can also cause an EntityMalformedException in entity_extract_ids() in /includes/common.inc , for example when a ctools access plugin checks for a value on a node field, against a taxonomy context.

panels_min_block_list_alter() prevents this from happening when the blocks are added to regions via the core block system. It checks that the page manager contexts match the required mini panel contexts, if they don’t it removes the block from the list of renderable blocks.

However other modules that render the block may not invoke this alter hook, for example the context module.

Steps to reproduce (on a default install):

1.Download and enable context, panels, page manager and mini panels
2.Create a mini panel with a required context “node”.
3. Create a pane in the mini panel with some custom text.
4. Add a visibility rule to the pane that checks the value of a field on the node, eg the body field.
5. Save the mini panel (example mini panel export attached).
6. In page manager, enable the ‘taxonomy/term’ page.
7. In context, create a new context
8. Add a path condition ‘taxonomy*’
9. Add a block reaction adding the mini panel you created above to a region. (example context attached)
10. Create a term in an existing taxonomy (you may need to create a vocab first).
11. View the term you have created. You will get an EntityMalformedException error.

Proposed resolution

1.Move the requirements matching check from panels_mini_block_list_alter() to a stand alone function, panels_mini_match_requirements().
2.Check for requirements via panels_mini_match_requirements() from both panels_mini_block_list_alter() and panels_mini_block_view().

Patch to follow.

Remaining tasks

Reviews needed.

User interface changes

In some production sites, mini panels that should not appear because a required context is not present might currently appear. Applying this patch would cause those mini panels to disappear.

Comments

tripper54’s picture

Status: Active » Needs review
StatusFileSize
new3 KB

Patch for review, implementing the proposed resolution in the issue description.

b-prod’s picture

Status: Needs review » Needs work

Actually your patch does not allow to push custom contexts using the panels_mini_block_contexts_alter() hook, so it breaks integration with third-party modules.

b-prod’s picture

Status: Needs work » Needs review
StatusFileSize
new4.97 KB

The ctools_context_match_required_contexts() function is definitively not the one to used for merging Page Manager contexts to the Mini Panel required ones.

This function expects the contexts to be in the same order, which will only address a few cases.

I do not agree with the block filtering, that is only based on Page Manager. The contexts may depend on the current page and be dynamically added by third-party modules, so we shouldn't filter the block list to my opinion.

Question: Should we add a new setting in mini panel configuration form (content type handler), that allow to use the contexts in the exact same order than the current page?
This setting could be enabled by default to ensure backward compatibility with the way page contexts are curently injected in mini panel.
We should rely on ctools_context_match_required_contexts() first then check for each injected context if it matches with the required context defined in the mini panel.

An other settings could be added to define if the mini panel should only be used within Page Manager. If so, we could remove it from the block alter hook if the requirements are not OK.

b-prod’s picture

Any news on this? Some feedback?

japerry’s picture

Status: Needs review » Closed (outdated)

Drupal 7 is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.