Problem/Motivation

Under the right conditions (e.g. enabling a feature involving panelizer and the panelizer permissions for a content type),

'module' => 'panelizer',
'name' => 'administer panelizer node page content',
- 'roles' => array(
- 'administrator' => 'administrator',
- ),
),

the permissions will not be assigned to the role and the following warnings are displayed:

  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page content".
  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page context".
  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page defaults".
  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page layout".
  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page overview".
  • Warning in features rebuild of panelizer_test. No module defines permission "administer panelizer node page settings".

The call sequence looks like:

panelizer_permission
panelizer_get_plugins_with_hook()
$plugins = panelizer_get_entity_plugins()
$handler = panelizer_entity_plugin_get_handler($plugin)

As part of enabling the feature, hook_permission() is called multiple times. On the first pass, the $handler is initialized in panelizer_entity_plugin_get_handler() with a "basic" $plugin. When features gets around to doing its processing, the passed $plugin argument has been updated by features (the panelizer user permissions have been set for the content type), but is ignored and the returned $handler still has attached the "original" processed $plugin. When user_permission_features_rebuild() executes, the permissions are missing and it sets the warning messages shown above.

Steps to Reproduce

  • Panelize the Basic Page content type
  • Assign permissions
    • Node Basic page: Administer Panelizer default panels, allowed content and settings.
    • Node Basic page: Administer Panelizer overview
    • Node Basic page: Administer Panelizer settings
    • Node Basic page: Administer Panelizer context
    • Node Basic page: Administer Panelizer layout
    • Node Basic page: Administer Panelizer content
  • Export feature
    • Panelizer (panelizer defaults)
      • Basic Page default (node:page:basic_page_default)
    • Permissions (user_permission)
      • Panelizer: Node Basic page: Administer Panelizer content
      • Panelizer: Node Basic page: Administer Panelizer context
      • Panelizer: Node Basic page: Administer Panelizer default panels, allowed content and settings.
      • Panelizer: Node Basic page: Administer Panelizer layout
      • Panelizer: Node Basic page: Administer Panelizer overview
      • Panelizer: Node Basic page: Administer Panelizer settings
    • Strongarm (variable)
      • panelizer_defaults_node_page
      • panelizer_node:page_allowed_layouts
      • panelizer_node:page_allowed_layouts_default
      • panelizer_node:page_allowed_types_default
      • panelizer_node:page_default
  • Enable feature on new site

Set-up Info

Drupal 7.26
CTools 7.x-1.4
Features 7.x-2.0
Panelizer 7.x-3.1

Proposed resolution

In panelizer_entity_plugin_get_handler(), update the plugin attached to an existing handler.

Remaining tasks

Review and test.

User interface changes

None.

API changes

None.

Set issue priority to Major because this bug breaks deployment.

Comments

solotandem’s picture

Title: Exported Permissions are Overridden on Feature Enable » Update the plugin attached to an existing handler
Issue summary: View changes
solotandem’s picture

Status: Active » Needs review
StatusFileSize
new1.28 KB

Attached patch implements the proposed resolution.

dysproseum’s picture

Followed above steps and could not reproduce the warnings when enabling the feature. Used the same versions listed with a clean install of Drupal 7:

Drupal 7.26
CTools 7.x-1.4
Features 7.x-2.0
Panelizer 7.x-3.1

damienmckenna’s picture

Version: 7.x-3.1 » 7.x-3.x-dev

Does the problem still happen with the -dev version?

chris burge’s picture

I retested the following scenarios:

  • Panelizer 7.x-3.1 (no patch)
  • Paneilzer 7.x-3.x-dev (no patch)
  • Panelizer 7.x-3.1 (with patch)
  • Paneilzer 7.x-3.x-dev (with patch)

In each scenario, I created a new site and exported basic Panelizer configuration, including permissions. I then created another new site and attempted to deploy Panelizer configuration with Features. In each instance, the deployment of permissions failed. I enabled the test features through the UI: Administration » Structure » Features.

Panelizer 7.x-3.1 (no patch)

  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page content".
  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page context".
  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page defaults".
  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page layout".
  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page overview".
  • Warning in features rebuild of panelizer_export. No module defines permission "administer panelizer node page settings".

Paneilzer 7.x-3.x-dev (no patch)

  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page choice".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page content".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page context".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page defaults".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page layout".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page overview".
  • Warning in features rebuild of panelizer_export_2. No module defines permission "administer panelizer node page settings".

Panelizer 7.x-3.1 (with patch)

  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page content".
  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page context".
  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page defaults".
  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page layout".
  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page overview".
  • Warning in features rebuild of panelizer_export_3. No module defines permission "administer panelizer node page settings".

Paneilzer 7.x-3.x-dev (with patch)

  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page choice".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page content".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page context".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page defaults".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page layout".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page overview".
  • Warning in features rebuild of panelizer_export_4. No module defines permission "administer panelizer node page settings".
solotandem’s picture

Retested using 2014-04-25 dev release of Paneilzer 7.x-3.x (revision 72b5e00) . Results are consistent with and without the plugin patch from #2 applied. Without the patch the warnings were displayed. With the patch no warnings.

chris burge’s picture

After further testing, I can confirm the patch works. On my second round of testing, I recreated the feature but did not include the Strongarm module or any records from the variables table.

In order for permissions to be successfully exported/imported, the corresponding Strongarm value(s) must be included. In my case, I was panelizing the Basic page content type. Thus, I needed to include the 'panelizer_defaults_node_page' Strongarm value.

During this round of testing, I used Panelizer 7.x-3.x-dev.

Thanks for your work on this @dysproseum and @solotandem

saltednut’s picture

Status: Needs review » Reviewed & tested by the community

Wow, thanks for the extremely thorough issue summary and examples.

This is a longstanding issue that I have seen many times - in the past I have even seen the original author and maintainer of this module dismiss this as a "chicken-egg" situation with no fix.

I ran into this issue again today when exporting some Panelizer settings and enabling Features. I was seeing similar errors to the ones described. After applying the patch, everything is working correctly.

This is likely also a fix for:
#2121971: Panelizer permissions warnings
#2282545: Installation warnings: 'No module defines permission...'

Re: #7 - my feature also includes the strongarm vars so I cannot confirm if this is the case but it sounds correct.

In any case, I think this should be committed.

merlinofchaos’s picture

The attached patch will cause white screens if an entity plugin is somehow removed from the system but content still refers to its class, because the check that makes sure $class is valid was removed.

I would recommend not committing until that is addressed.

merlinofchaos’s picture

In addition, I am not comfortable with this particular fix, because it is going to rerun ->init() potentially many times on a request, causing that array to be copied unnecessarily a lot.

I would urge you to explore seeing if you can have the plugin be updated by whatever process features is doing to actually enable it. Perhaps panelizer can respond in some way and do this - which would be more efficient than this solution.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

Per merlinofchaos, pushing this back to 'needs work' until an alternative is found.

mglaman’s picture

How is the feature module being enabled? I've experienced issues when enabling features through Drush versus the UI, simply because Features implements its own "throttling" mechanism when being run through Drush on rebuilds.

It'd be good to test this over UI and Drush to see if that matters, because then it is most definitely a Features issue.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1 KB

Being more honest on what's happening in the patch, i.e. the plugin is initialized on every single call to panelizer_entity_plugin_get_handler().

damienmckenna’s picture

Status: Needs review » Needs work

Putting this back to Needs Work as.. it needs work.

mglaman’s picture

So, randomly, this started occurring for me and causing integrity constraint errors, causing installation to fail. Patch didn't help. This is based off of Panopoly, so not sure if Panopoly just has a bad config? Could explain what's being seen in #2282545

Example:

Starting Drupal installation. This takes a few seconds ...                  [ok]
WD php: PDOException: SQLSTATE[23000]: Integrity constraint              [error]
violation: 1048 Column 'module' cannot be null: INSERT INTO
{role_permission} (rid, permission, module) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 3
    [:db_insert_placeholder_1] => administer panelizer user user
breadcrumbs
    [:db_insert_placeholder_2] => 
)
 in user_role_grant_permissions() (line 3113 of
/var/www/HARHAR/modules/user/user.module).
bpleduc’s picture

Patch causes WSOD and drush rr fails.

Uninstalling this patch resolved WSOD issues and drush rr failing.

dagomar’s picture

StatusFileSize
new1.04 KB

I also experienced WSOD after using this patch. I am not 100% sure what causes it, it seems the panelizer_entity_plugin_get_handler is called before the class can be loaded, which in my case causes the WSOD (PHP Fatal error: Class name must be a valid object or a string). I was able to fix this by making sure that $class is not empty after attempting to load it with ctools_plugin_get_class. I have created a new patch.

dagomar’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 17: get-class-name-2206961-17.patch, failed testing.

dagomar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB

I probably should have tested the previous patch a bit better, here's another

joelstein’s picture

This patch works for me, thanks!

chris burge’s picture

I test deployed #20 without any issues. Full disclosure: I haven't encountered the WSOD issue described by others.