Hi Nicolas, The way we create a view is with the default layout, that is 1 row - 3 columns. After the view is created, we are able to edit the layout: create a new one or assign an existing from the db.
In this case, you are reaching that part of the code because $this->layout has a value, and $this->columnsperrow and $this->numrows are populated in a way that $this->columnsperrow === false || ($this->numrows > 0 && count($this->columnsperrow) != $this->numrows) is true. For us, this will be a special case of missing information and the code is just trying to recover from this. That's why I don't think we should be touching these lines. But in your case, it looks like you are creating a new view and a new layout at the same time. maybe the correct way of resolving the issue would be to create the view with a default layout, create the layout in the DB and just after this, assign the layout to the view. But as Kristina said, it would be helpful to know more about integration. Cecilia -- You received this bug notification because you are a member of Mahara Contributors, which is subscribed to Mahara. Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it! https://bugs.launchpad.net/bugs/1700997 Title: View::create() throws an error if a layout has to be created on the fly Status in Mahara: New Bug description: We have an external app that creates Views in Mahara. While creating Views it creates the corresponding layout if needed. However, an error was alwasys thrown at lib/view.php:334 when calling ensure_record_exists('view_rows_columns', $vrc, $vrc);. As the $vrc record is created, the DB insert fails because $vrc->view is null, as the view is not (yet) created. The attached patch fixes this by ensuring the view is saved in the DB (and thus haves an ID) before attempting to create the $vrc object. Mahara version : 17.04.2 OS : GNU/Linux Debian 8.8 DB : MySQL 5.5 PHP : 5.6 To manage notifications about this bug go to: https://bugs.launchpad.net/mahara/+bug/1700997/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~mahara-contributors Post to : [email protected] Unsubscribe : https://launchpad.net/~mahara-contributors More help : https://help.launchpad.net/ListHelp

