Commit cfa75df1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move the check for deleted groups when creating a View

When constructing a View, we only need to perform the deleted group
check when pulling a view record out of the db, not every time we
create a View.  This change allows faster creation of View objects
in those cases where we already have all the data at hand.

Change-Id: I4d13446f31d841323692923a1cfc2647a2f3b2ed
Signed-off-by: default avatarRichard Mansfield <>
parent c79a8e0e
......@@ -116,7 +116,12 @@ class View {
public function __construct($id=0, $data=null) {
if (!empty($id)) {
$tempdata = get_record('view','id',$id);
$tempdata = get_record_sql('
FROM {view} v LEFT JOIN {group} g ON =
WHERE = ? AND ( IS NULL OR g.deleted = 0)',
if (empty($tempdata)) {
throw new ViewNotFoundException(get_string('viewnotfound', 'error', $id));
......@@ -145,12 +150,6 @@ class View {
$this->atime = time();
$this->columns = array();
$this->dirtycolumns = array();
if ($this->group) {
$group = get_record('group', 'id', $this->group);
if ($group->deleted) {
throw new ViewNotFoundException(get_string('viewnotfound', 'error', $id));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment