Access denied on Display Fields settings page for Full view mode
Point of everything below: Getting access denied on Display settings pages can be caused by not having a view mode set to custom display settings in a robust enough manner.
Put this code in a test.php file and run it, you can see your lovely giant variable and it can fix you up fine for developing (get access to the settings page again).
<?php
define('DRUPAL_ROOT', getcwd());
require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$fbs = variable_get('field_bundle_settings');
print "<pre>";
print var_export($fbs, TRUE);
print "</pre>";
variable_set('field_bundle_settings', $fbs);
?>
This fixes access to the view mode settings page and you can edit it, and export your configuration, and bring it live-- if you try to edit it on live, or edit it later on local dev after the live database has been re-exported, it will fail again and you will have to re-do this-- because the view mode won't be in the database, only in strongarm's export which does not quite work.
The problem is the way Features with Strongarm saves view mode configuration. It works fine for all actual use - displaying - of the content type with that view mode, but it can fail to be available in time when going to the settings page.
Either setting these bundle-level settings in the database or using hook_entity_info_alter() to tell all nodes to provide, for instance, the Full view mode for custom settings will work. (But while hook_entity_info_alter() is the more permanent solution, it does not always work.) If the variable is captured into code with Strongarm, however, and is not in the variable table, it fails in some weird way and you can get access denied on that settings page.
admin/structure/types/manage/project/display/full
Amazing. Somehow strongarm is just totally failing.
The first time around through (well first you can see it is caching just the values defined by default in node_entity_info
drupal strongarm variable empty second look - no, actually it is empty in its first look. How is field_bundle_settings being called before a hook_init in a -1000 weighted module (namely Strongarm)
<?php
function field_bundle_settings($entity_type, $bundle, $settings = NULL) {
$stored_settings = variable_get('field_bundle_settings', array());
debug($entity_type . ' and ' . $bundle, 'entity type and bundle');
debug($stored_settings, 'stored_settings');
debug($settings, 'settings passed into field_bundle_settings');
?>
...
and
<?php
function field_view_mode_settings($entity_type, $bundle) {
$cache = &drupal_static(__FUNCTION__, array());
if ($bundle == 'project') {
debug($cache, 'cache');
// kill the cache
$cache = array();
}
if (!isset($cache[$entity_type][$bundle])) {
$bundle_settings = field_bundle_settings($entity_type, $bundle);
$settings = $bundle_settings['view_modes'];
debug($settings, 'settings from bundle_settings');
?>
Debug: cache: array ( 'node' => array ( 'project' => array ( 'teaser' => array ( 'custom_settings' => true, ), ), ), ) in field_view_mode_settings() (line 625 of /home/ben/code/sdl/web/modules/field/field.module). Debug: entity type and bundle: 'node and project' in field_bundle_settings() (line 583 of /home/ben/code/sdl/web/modules/field/field.module). Debug: stored_settings: array ( 'file' => array ( 'default' => array ( 'view_modes' => array ( ), 'extra_fields' => array ( 'form' => array ( ), 'display' => array ( 'file' => array ( 'media_small' => array ( 'weight' => 0, 'visible' => false, ), ), ), ), ), 'image' => array ( 'view_modes' => array ( ), 'extra_fields' => array ( 'form' => array ( ), 'display' => array ( 'file' => array ( 'media_small' => array ( 'weight' => 0, 'visible' => false, ), ), ), ), ), 'audio' => array ( 'view_modes' => array ( ), 'extra_fields' => array ( 'form' => array ( ), 'display' => array ( 'file' => array ( 'media_small' => array ( 'weight' => 0, 'visible' => false, ), ), ), ), ), 'video' => array ( 'view_modes' => array ( ), 'extra_fields' => array ( 'form' => array ( ), 'display' => array ( 'file' => array ( 'media_small' => array ( 'weight' => 0, 'visible' => false, ), ), ), ), ), ), 'node' => array ( 'project' => array ( 'view_modes' => array ( 'full' => array ( 'custom_settings' => true, ), 'teaser' => array ( 'custom_settings' => true, ), 'rss' => array ( 'custom_settings' => false, ), 'search_index' => array ( 'custom_settings' => false, ), 'search_result' => array ( 'custom_settings' => false, ), 'print' => array ( 'custom_settings' => false, ), ), 'extra_fields' => array ( 'form' => array ( ), 'display' => array ( ), ), ), ), ) in field_bundle_settings() (line 584 of /home/ben/code/sdl/web/modules/field/field.module). Debug: settings passed into field_bundle_settings: NULL in field_bundle_settings() (line 585 of /home/ben/code/sdl/web/modules/field/field.module). Debug: settings from bundle_settings: array ( 'full' => array ( 'custom_settings' => true, ), 'teaser' => array ( 'custom_settings' => true, ), 'rss' => array ( 'custom_settings' => false, ), 'search_index' => array ( 'custom_settings' => false, ), 'search_result' => array ( 'custom_settings' => false, ), 'print' => array ( 'custom_settings' => false, ), ) in field_view_mode_settings() (line 632 of /home/ben/code/sdl/web/modules/field/field.module). Debug: cache: array ( ) in field_view_mode_settings() (line 625 of /home/ben/code/sdl/web/modules/field/field.module). Debug: entity type and bundle: 'node and project' in field_bundle_settings() (line 583 of /home/ben/code/sdl/web/modules/field/field.module). Debug: stored_settings: array ( ) in field_bundle_settings() (line 584 of /home/ben/code/sdl/web/modules/field/field.module). Debug: settings passed into field_bundle_settings: NULL in field_bundle_settings() (line 585 of /home/ben/code/sdl/web/modules/field/field.module). Debug: settings from bundle_settings: array ( ) in field_view_mode_settings() (line 632 of /home/ben/code/sdl/web/modules/field/field.module).
with a print_r'd debug_backtrace in variable_get itself, we see the firsttime field_bundle_settings is looked for it returns nothing (this confuses me because i thought the problem was in the second lookup for some reason, but whatever)
<?php
function variable_get($name, $default = NULL) {
global $conf;
if ($name == 'field_bundle_settings') {
print 'variable_get<pre>';
print_r($conf[$name]); // , 'variable_get');
print_r(debug_backtrace());
print '</pre>';
}
return isset(
$conf[$name]) ? $conf[$name] : $default;
}
?>
variable_get Array ( [0] => Array ( [file] => /home/ben/code/sdl/web/modules/field/field.module [line] => 582 [function] => variable_get [args] => Array ( [0] => field_bundle_settings [1] => Array ( ) ) ) [1] => Array ( [file] => /home/ben/code/sdl/web/modules/field/field.module [line] => 630 [function] => field_bundle_settings [args] => Array ( [0] => node [1] => project ) ) [2] => Array ( [file] => /home/ben/code/sdl/web/modules/field_ui/field_ui.module [line] => 246 [function] => field_view_mode_settings [args] => Array ( [0] => node [1] => project ) ) [3] => Array ( [function] => _field_ui_view_mode_menu_access [args] => Array ( [0] => node [1] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [2] => full [3] => user_access [4] => administer content types ) ) [4] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 622 [function] => call_user_func_array [args] => Array ( [0] => _field_ui_view_mode_menu_access [1] => Array ( [0] => node [1] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [2] => full [3] => user_access [4] => administer content types ) ) ) [5] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 775 [function] => _menu_check_access [args] => Array ( [0] => Array ( [path] => admin/structure/types/manage/%/display/full [load_functions] => Array ( [4] => node_type_load ) [to_arg_functions] => [access_callback] => _field_ui_view_mode_menu_access [access_arguments] => a:5:{i:0;s:4:"node";i:1;i:4;i:2;s:4:"full";i:3;s:11:"user_access";i:4;s:24:"administer content types";} [page_callback] => drupal_get_form [page_arguments] => a:4:{i:0;s:30:"field_ui_display_overview_form";i:1;s:4:"node";i:2;i:4;i:3;s:4:"full";} [delivery_callback] => [fit] => 123 [number_parts] => 7 [context] => 1 [tab_parent] => admin/structure/types/manage/%/display [tab_root] => admin/structure/types/manage/% [title] => Full content [title_callback] => t [title_arguments] => [theme_callback] => [theme_arguments] => a:0:{} [type] => 132 [description] => [position] => [weight] => 0 [include_file] => modules/field_ui/field_ui.admin.inc [href] => admin/structure/types/manage/project/display/full [tab_root_href] => admin/structure/types/manage/project [tab_parent_href] => admin/structure/types/manage/project/display [options] => Array ( ) ) [1] => Array ( [0] => admin [1] => structure [2] => types [3] => manage [4] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [5] => display [6] => full ) ) ) [6] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 458 [function] => _menu_translate [args] => Array ( [0] => Array ( [path] => admin/structure/types/manage/%/display/full [load_functions] => Array ( [4] => node_type_load ) [to_arg_functions] => [access_callback] => _field_ui_view_mode_menu_access [access_arguments] => a:5:{i:0;s:4:"node";i:1;i:4;i:2;s:4:"full";i:3;s:11:"user_access";i:4;s:24:"administer content types";} [page_callback] => drupal_get_form [page_arguments] => a:4:{i:0;s:30:"field_ui_display_overview_form";i:1;s:4:"node";i:2;i:4;i:3;s:4:"full";} [delivery_callback] => [fit] => 123 [number_parts] => 7 [context] => 1 [tab_parent] => admin/structure/types/manage/%/display [tab_root] => admin/structure/types/manage/% [title] => Full content [title_callback] => t [title_arguments] => [theme_callback] => [theme_arguments] => a:0:{} [type] => 132 [description] => [position] => [weight] => 0 [include_file] => modules/field_ui/field_ui.admin.inc [href] => admin/structure/types/manage/project/display/full [tab_root_href] => admin/structure/types/manage/project [tab_parent_href] => admin/structure/types/manage/project/display [options] => Array ( ) ) [1] => Array ( [0] => admin [1] => structure [2] => types [3] => manage [4] => project [5] => display [6] => full ) ) ) [7] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 1676 [function] => menu_get_item [args] => Array ( ) ) [8] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 1691 [function] => menu_get_custom_theme [args] => Array ( [0] => 1 ) ) [9] => Array ( [file] => /home/ben/code/sdl/web/includes/common.inc [line] => 4945 [function] => menu_set_custom_theme [args] => Array ( ) ) [10] => Array ( [file] => /home/ben/code/sdl/web/includes/bootstrap.inc [line] => 1918 [function] => _drupal_bootstrap_full [args] => Array ( ) ) [11] => Array ( [file] => /home/ben/code/sdl/web/index.php [line] => 20 [function] => drupal_bootstrap [args] => Array ( [0] => 7 ) ) ) variable_get Array ( [file] => Array ( [default] => Array ( [view_modes] => Array ( ) [extra_fields] => Array ( [form] => Array ( ) [display] => Array ( [file] => Array ( [media_small] => Array ( [weight] => 0 [visible] => ) ) ) ) ) [image] => Array ( [view_modes] => Array ( ) [extra_fields] => Array ( [form] => Array ( ) [display] => Array ( [file] => Array ( [media_small] => Array ( [weight] => 0 [visible] => ) ) ) ) ) [audio] => Array ( [view_modes] => Array ( ) [extra_fields] => Array ( [form] => Array ( ) [display] => Array ( [file] => Array ( [media_small] => Array ( [weight] => 0 [visible] => ) ) ) ) ) [video] => Array ( [view_modes] => Array ( ) [extra_fields] => Array ( [form] => Array ( ) [display] => Array ( [file] => Array ( [media_small] => Array ( [weight] => 0 [visible] => ) ) ) ) ) ) [node] => Array ( [project] => Array ( [view_modes] => Array ( [full] => Array ( [custom_settings] => 1 ) [teaser] => Array ( [custom_settings] => 1 ) [rss] => Array ( [custom_settings] => ) [search_index] => Array ( [custom_settings] => ) [search_result] => Array ( [custom_settings] => ) [print] => Array ( [custom_settings] => ) ) [extra_fields] => Array ( [form] => Array ( ) [display] => Array ( ) ) ) ) ) Array ( [0] => Array ( [file] => /home/ben/code/sdl/web/modules/field/field.module [line] => 582 [function] => variable_get [args] => Array ( [0] => field_bundle_settings [1] => Array ( ) ) ) [1] => Array ( [file] => /home/ben/code/sdl/web/modules/field/field.module [line] => 630 [function] => field_bundle_settings [args] => Array ( [0] => node [1] => project ) ) [2] => Array ( [file] => /home/ben/code/sdl/web/modules/field_ui/field_ui.module [line] => 246 [function] => field_view_mode_settings [args] => Array ( [0] => node [1] => project ) ) [3] => Array ( [function] => _field_ui_view_mode_menu_access [args] => Array ( [0] => node [1] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [2] => full [3] => user_access [4] => administer content types ) ) [4] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 622 [function] => call_user_func_array [args] => Array ( [0] => _field_ui_view_mode_menu_access [1] => Array ( [0] => node [1] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [2] => full [3] => user_access [4] => administer content types ) ) ) [5] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 775 [function] => _menu_check_access [args] => Array ( [0] => Array ( [menu_name] => management [mlid] => 946 [plid] => 938 [link_path] => admin/structure/types/manage/%/display/full [router_path] => admin/structure/types/manage/%/display/full [link_title] => Full content [options] => Array ( ) [module] => system [hidden] => -1 [external] => 0 [has_children] => 0 [expanded] => 0 [weight] => 0 [depth] => 6 [customized] => 0 [p1] => 2 [p2] => 20 [p3] => 31 [p4] => 106 [p5] => 938 [p6] => 946 [p7] => 0 [p8] => 0 [p9] => 0 [updated] => 0 [path] => admin/structure/types/manage/%/display/full [load_functions] => Array ( [4] => node_type_load ) [to_arg_functions] => [access_callback] => _field_ui_view_mode_menu_access [access_arguments] => a:5:{i:0;s:4:"node";i:1;i:4;i:2;s:4:"full";i:3;s:11:"user_access";i:4;s:24:"administer content types";} [page_callback] => drupal_get_form [page_arguments] => a:4:{i:0;s:30:"field_ui_display_overview_form";i:1;s:4:"node";i:2;i:4;i:3;s:4:"full";} [delivery_callback] => [fit] => 123 [number_parts] => 7 [context] => 1 [tab_parent] => admin/structure/types/manage/%/display [tab_root] => admin/structure/types/manage/% [title] => Full content [title_callback] => t [title_arguments] => [theme_callback] => [theme_arguments] => a:0:{} [type] => 132 [description] => [position] => [include_file] => modules/field_ui/field_ui.admin.inc [link_weight] => 0 [href] => admin/structure/types/manage/project/display/full [tab_root_href] => admin/structure/types/manage/project [tab_parent_href] => admin/structure/types/manage/project/display ) [1] => Array ( [0] => admin [1] => structure [2] => types [3] => manage [4] => stdClass Object ( [name] => Project [base] => node_content [description] => Use for building projects of the Studio. [has_title] => 1 [title_label] => Title [help] => [type] => project [custom] => 0 [modified] => 0 [locked] => 1 [disabled] => [is_new] => 1 [module] => feature_projects [orig_type] => project [disabled_changed] => ) [5] => display [6] => full ) ) ) [6] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 2407 [function] => _menu_translate [args] => Array ( [0] => Array ( [menu_name] => management [mlid] => 946 [plid] => 938 [link_path] => admin/structure/types/manage/%/display/full [router_path] => admin/structure/types/manage/%/display/full [link_title] => Full content [options] => Array ( ) [module] => system [hidden] => -1 [external] => 0 [has_children] => 0 [expanded] => 0 [weight] => 0 [depth] => 6 [customized] => 0 [p1] => 2 [p2] => 20 [p3] => 31 [p4] => 106 [p5] => 938 [p6] => 946 [p7] => 0 [p8] => 0 [p9] => 0 [updated] => 0 [path] => admin/structure/types/manage/%/display/full [load_functions] => Array ( [4] => node_type_load ) [to_arg_functions] => [access_callback] => _field_ui_view_mode_menu_access [access_arguments] => a:5:{i:0;s:4:"node";i:1;i:4;i:2;s:4:"full";i:3;s:11:"user_access";i:4;s:24:"administer content types";} [page_callback] => drupal_get_form [page_arguments] => a:4:{i:0;s:30:"field_ui_display_overview_form";i:1;s:4:"node";i:2;i:4;i:3;s:4:"full";} [delivery_callback] => [fit] => 123 [number_parts] => 7 [context] => 1 [tab_parent] => admin/structure/types/manage/%/display [tab_root] => admin/structure/types/manage/% [title] => Full content [title_callback] => t [title_arguments] => [theme_callback] => [theme_arguments] => a:0:{} [type] => 132 [description] => [position] => [include_file] => modules/field_ui/field_ui.admin.inc [link_weight] => 0 [href] => admin/structure/types/manage/project/display/full [tab_root_href] => admin/structure/types/manage/project [tab_parent_href] => admin/structure/types/manage/project/display ) [1] => Array ( [0] => admin [1] => structure [2] => types [3] => manage [4] => project [5] => display [6] => full ) ) ) [7] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 2283 [function] => menu_link_get_preferred [args] => Array ( ) ) [8] => Array ( [file] => /home/ben/code/sdl/web/includes/menu.inc [line] => 2425 [function] => menu_set_active_trail [args] => Array ( ) ) [9] => Array ( [file] => /home/ben/code/sdl/web/modules/toolbar/toolbar.module [line] => 342 [function] => menu_get_active_trail [args] => Array ( ) ) [10] => Array ( [file] => /home/ben/code/sdl/web/modules/toolbar/toolbar.module [line] => 318 [function] => toolbar_in_active_trail [args] => Array ( [0] => admin/dashboard ) ) [11] => Array ( [file] => /home/ben/code/sdl/web/modules/toolbar/toolbar.module [line] => 202 [function] => toolbar_menu_navigation_links [args] => Array ( [0] => Array ( [49980 Tasks 21] => Array ( [link] => Array ( [menu_name] => management [mlid] => 21 [plid] => 2 [link_path] => admin/tasks [router_path] => admin/tasks [link_title] => Tasks [options] => Array ( ) [module] => system [hidden] => -1 [external] => 0 [has_children] => 0 [expanded] => 0 [weight] => -20 [depth] => 2 [customized] => 0 [p1] => 2 [p2] => 21 [p3] => 0 [p4] => 0 [p5] => 0 [p6] => 0 [p7] => 0 [p8] => 0 [p9] => 0 [updated] => 0 [load_functions] => [to_arg_functions] => [access_callback] => user_access [access_arguments] => a:1:{i:0;s:27:"access administration pages";} [page_callback] => system_admin_menu_block_page
strongarm and cache flushing (fairly certain unrelated)
Comments
Had the same problem
I had the same problem, and seems to be related to this core issue;
http://drupal.org/node/1211008#comment-5253754
and strongarm has a patch ready to go once this is committed here:
http://drupal.org/node/1306924
In the mean time, I find that if you go to the main "Manage Display" page for the content type in question ( admin/structure/types/manage//display ) and click save, the success message should say something like "The mode now uses custom display settings". And you should find you have access to the settings page, and that everything now works as expected.
Hope that helps someone...
Post new comment