Summary
The "Add Section Content" Panel (pictured in attached image) no longer works due to the commit mentioned in comment #5 below.
Steps to recreate
From a fresh install:
- Create a new space
- Create a new section
- 'Customize the page' using the in-place editor
- Add the 'Add Section Content' pane to the content (found under the 'Open Atrium' section)
- Save the changes and view the page
- There is a blank space where the content creation button should be
Error message received
Checking the error log I see the following:
Warning: array_merge(): Argument #1 is not an array in command_buttons_get_button_class() (line 779 of /var/www/html/transtoolkit/docroot/profiles/openatrium/modules/contrib/command_buttons/command_buttons.module).
Notice: Undefined variable: classes in command_buttons_get_button_class() (line 779 of /var/www/html/transtoolkit/docroot/profiles/openatrium/modules/contrib/command_buttons/command_buttons.module).
Warning: Invalid argument supplied for foreach() in command_buttons_entity_view() (line 601 of /var/www/html/transtoolkit/docroot/profiles/openatrium/modules/contrib/command_buttons/command_buttons.module).Original report
Latest Upgrade affected my custom panel panes module, because it was based on OA's add content panel. Error states the panel is Empty or Inaccessible.
I upgraded to Open Atrium 2.19 and my custom pane is no longer working. When I am editing my panels with IPE the panel (that should have my custom pane) says: Empty or Inaccessible. When I try to add that pane, it still exists as an option, and I get all the fields for settings in that panel, but nothing is rendering. Somehow the content is now considered empty.
Hopefully, this will reveal a necessary edit for others as well in their custom panel panes.
Here is my code:
<?php
/**
* @file oa_notifications_pane.inc
*/
$plugin = array(
'title' => t('OAK Add Section Content'),
'description' => t('Create section content according to allowed content options'),
'single' => TRUE,
'category' => array(t('OAK CCT'), -9),
'edit form' => 'oak_cct_oak_cct_ascp_settings_form',
'render callback' => 'oak_cct_oak_cct_ascp_render',
'required context' => new ctools_context_required(t('Node'), 'node'),
'defaults' => array(
'description' => '',
'image' => '',
),
);
/**
* Provides the form for the widget.
*/
function oak_cct_oak_cct_ascp_settings_form($form, &$form_state) {
$conf = $form_state['conf'];
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('description text'),
'#size' => 50,
'#description' => t('A description.'),
'#default_value' => !empty($conf['description']) ? $conf['description'] : 'default description',
);
$form['image'] = array(
'#type' => 'textfield',
'#title' => t('image text'),
'#size' => 50,
'#description' => t('An image.'),
'#default_value' => !empty($conf['image']) ? $conf['image'] : 'default image text',
);
// no submit
return $form;
}
/**
* Renders the widget.
*/
function oak_cct_oak_cct_ascp_render($subtype, $conf, $args, $context) {
$block_description = $conf['description'];
$block_image = $conf['image'];
$node = $context->data;
if ($node) {
$node_types = oa_buttons_get_command_buttons($node);
if (!empty($node_types)) {
$buttons = command_buttons_machine_name_load(array_keys($node_types));
// display only if have access to button
$access = FALSE;
foreach ($buttons as $key => $button) {
if (node_access('create', $buttons[$key]->name)) {
$access = TRUE;
}
}
$item_list = array();
$classes = array(
'item_class' => array(
'btn btn-primary btn-green btn-mini',
'oa-button',
),
'wrapper_class' => array(
'oa-buttons',
),
);
$block = new stdClass();
if($access){
$block->title = t('Create Content');
$block->content = "<p>" . $conf['description'] . "</p>" . command_buttons_render_buttons($buttons, $classes, $node_types);
}
//$block->description = $conf['description'];
//$block->image = $conf['image'];
}
}
return $block;
}
/**
* Submit function, note anything in the formstate[conf] automatically gets saved
*/
function oak_cct_oak_cct_ascp_settings_form_submit($form, &$form_state) {
foreach (array_keys($form_state['values']) as $key) {
if (isset($form_state['values'][$key])) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
}
Here are results for various printed variables:
$node_types =
Array
(
[oa_wiki_page:11] => Array
(
[value] => oa_wiki_page
[provider_type] => oa_section
[id] => 11
)
)$buttons =
Array
(
)It seems to me that the issue could be here:
$buttons = command_buttons_machine_name_load(array_keys($node_types));
For some reason, this function is now giving an empty $buttons array, where before the update, it was not empty.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Pasted_Image_6_4_14_3_41_PM.jpg | 39.97 KB | SweetTomato |
| #7 | Pasted_Image_6_4_14_3_39_PM.jpg | 82.4 KB | SweetTomato |
Comments
Comment #1
SweetTomato commentedComment #2
SweetTomato commentedSome research that may help:
The last commit: https://github.com/phase2/openatrium-drops-7/commit/8529d9201be88fc59378...
Looks like this changed:
For the function: command_buttons_machine_name_load
$results = db_select('command_buttons', 'b')
->fields('b', array('bid'))
- ->condition('bundle', 'node_add')
->condition('name', $buttons, 'IN')
+ ->orderBy('title')
->execute();
Or it is possible that the array_keys function is not working as it used to... and therefore isn't feeding the correct thing to the command_buttons_machine_name_load function.
Comment #3
SweetTomato commentedDon't know why, especially since that piece of the code hasn't changed in this update, but removing
->condition('name', $buttons, 'IN')from #2 above seems to fix my issue...Comment #4
SweetTomato commentedI also for some reason thought maybe the keys from the node_array might be a problem (they look like this: oa_wiki_article:11).
So changing the command_buttons_machine_name_load function to the following worked. I basically go through the $buttons array (the one in the function, not the empty one from my tests above) and take out the colon and trailing number:
Again, not sure why this works, or what the reason or implication is for the change. As well as why or where that colon and trailing number were added to that array in the latest release of OA2.
Comment #5
SweetTomato commentedHmm... looks like the change in the array_key mentioned above is from the latest commit:
In this function _oa_buttons_get_node_command_buttons:
Comment #6
SweetTomato commentedComment #7
SweetTomato commentedComment #8
jkingsnorth commentedMarked #2324561: 'Add Section Content' pane no longer working as a duplicate
Comment #9
jkingsnorth commentedMarked #2281845: Command List Panes not working as a duplicate, added error message described there to the issue summary here.
Comment #10
jkingsnorth commentedThis still appears to be an issue in 2.3.2
To recreate the error on a fresh installation:
Comment #11
jkingsnorth commentedStill reproducible in 2.3.3
Comment #12
hefox commentedhm, switched it to use 'value' property returned to that function, but guessing it needs further improvement later but that's what the similar spaces one does.
Comment #13
jkingsnorth commentedHi hefox, can you point to the commit for this so we can apply the patch?
Comment #14
hefox commented0348d9635eb20f099b93947aab9c79af13fd04c2 in oa_core
Comment #15
jkingsnorth commentedGreat, and confirmed working for us too. Thanks hefox.