Recently, I set up an instance of OpenScholar Beta-14, went to set up an example scholar site through Create content -> Scholar Site and then proceeded to check on the Site Layout functionality in the Control Panel. After messing around with the layout a while, I clicked Save and that's when the problem started. A PHP error popped up on the resulting page telling me there was a problem in:
openscholar_vsite/vsite_layout/vsite_layout_ui/includes/vsite_layout_ui.inc : line 575
...which I found out was a line of PHP code written more like Javascript. After messing with it, debugging, then eventually changing the following lines as below, it worked:
From:
function _vsite_layout_ui_add_new_widgets(&$widgets) {
$all_widgets = vsite_layout_get_widgets();
foreach ($all_widgets as $key => &$w) {
$w['region'] = false;
if($w['factory']) unset($all_widgets[$key]);
}
$all_widgets += $widgets;
}
To:
function _vsite_layout_ui_add_new_widgets(&$widgets) {
$all_widgets = vsite_layout_get_widgets();
foreach ($all_widgets as $key => &$w) {
$w['region'] = false;
if($w['factory']) unset($all_widgets[$key]);
}
// Just commenting this out for now (May come back to this later)
// array_merge($widgets, $all_widgets);
}
Just seeing if anyone else has/is having problems with the Site Layout functionality and whether this was something that I inadvertently caused or if it's an official bug. Be good to hear feedback on my solution/whether I undid something intentional by the programmers.
Thanks,
Grant
Comments
Commenting out that line
Commenting out that line completely defeats the purpose of that function.
That function is supposed to take an incomplete list of widgets and fill it in with any missing ones. It uses += to prevent existing settings from being blown away. And you'll still get an error with array_merge, because the problem isn't with this function.
That error occurs because one or both of the arguments for += isn't an array. They're both expected to be arrays. I'm guessing its $widgets that's the problem.
$widgets is faulty
I see your point -- so what's a good way to test correct data for $widgets? My best guess is to use Devel to figure out where the data goes bad.
Grant Dickie
ARHU Web & Applications Developer
University of Maryland, College Park
First check which argument
That function gets called at line 407 of the same file. If something goes wrong with getting the widgets from the spaces override, $widgets could be not an array.