Comment 3 for bug 1287262

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Too bad, that was the only lead I had! ;)

Hm, well based on the fact that it says "(id=)", we know the $layoutid variable is null or an empty string. That means the only code path it could have followed was that $this->get_layout() returned null, and $numrows == 1.

That's not too surprising. New pages start out with a NULL layout and numrows set to 1. This changes if the user picks a different layout from the layouts tab, in which case it changes to point to the chosen layout. If the user adds or removes columns by using the optional account setting that lets you add/remove columns from the layout page using buttons, then it goes back to NULL.

When the layout is NULL, the number of columns on each row, and their widths, is meant to be determined by looking in the view_rows_columns table (which in turn maps to the view_layout_columns table to get the widths of the columns).

Now, with a $layoutid of NULL and a $numrows of 1, the code is going to go through the series of loops inside the if statement "if ($numrows == 1)". Based on the fact that it throws that exception, it means that it made it out without finding a suitable layout, and hence never assigned a value to $layout->id. So that means you're missing records from one or more of these tables: "view_layout_rows_columns", "view_layout", or "usr_custom_layout".

Since this happens with newly created groups, probably what happened is that the group homepage template page didn't get its layout information properly updated to the new layout format.

Hm... all that code inside the "else if (!$layoutid) {" part of that function is pretty wonky, especially the part for $numrows == 1. Perhaps, rather than trying to fix the layout records for the group homepage by hand, you could just delete the special block for handling pages with just 1 row, so that they're handled the same as pages with multiple rows? And get rid of the part where it checks the $layout->id and throws an exception. So then it'll look like this:

        else if (!$layoutid) {
                // multiple rows
                // get widths for each row, based on equal spacing of columns
                $layoutid = 0;
                $layout->id = $layoutid;
                foreach ($columnsperrow as $row) {
                    $numcolumns = $row->columns;
                    $widths = self::$defaultcolumnlayouts[$numcolumns];
                    $layout->rows[$row->row]['widths'] = $widths;
                    $layout->rows[$row->row]['columns'] = $numcolumns;
                }
        }

        return $layout;