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.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | get-class-name-2206961-18.patch | 1.05 KB | dagomar |
| #17 | get-class-name-2206961-17.patch | 1.04 KB | dagomar |
| #13 | panelizer-n2206961-13.patch | 1 KB | damienmckenna |
| #2 | 2206961-update-the-plugin.patch | 1.28 KB | solotandem |
Comments
Comment #1
solotandem commentedComment #2
solotandem commentedAttached patch implements the proposed resolution.
Comment #3
dysproseum commentedFollowed 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
Comment #4
damienmckennaDoes the problem still happen with the -dev version?
Comment #5
chris burge commentedI retested the following scenarios:
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)
Paneilzer 7.x-3.x-dev (no patch)
Panelizer 7.x-3.1 (with patch)
Paneilzer 7.x-3.x-dev (with patch)
Comment #6
solotandem commentedRetested 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.
Comment #7
chris burge commentedAfter 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
Comment #8
saltednutWow, 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.
Comment #9
merlinofchaos commentedThe 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.
Comment #10
merlinofchaos commentedIn 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.
Comment #11
damienmckennaPer merlinofchaos, pushing this back to 'needs work' until an alternative is found.
Comment #12
mglamanHow 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.
Comment #13
damienmckennaBeing 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().
Comment #14
damienmckennaPutting this back to Needs Work as.. it needs work.
Comment #15
mglamanSo, 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:
Comment #16
bpleduc commentedPatch causes WSOD and drush rr fails.
Uninstalling this patch resolved WSOD issues and drush rr failing.
Comment #17
dagomar commentedI 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.
Comment #18
dagomar commentedComment #20
dagomar commentedI probably should have tested the previous patch a bit better, here's another
Comment #21
joelstein commentedThis patch works for me, thanks!
Comment #22
chris burge commentedI test deployed #20 without any issues. Full disclosure: I haven't encountered the WSOD issue described by others.