From 0a649992592e491d92400e66fb6585a5a619baf4 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 13 Sep 2017 12:50:29 +1200 Subject: [PATCH 1/2] MDL-60105 search: Fix fatal error If an indexed file has been modified or deleted the search index will still reference the old file. Remove the file from search results until the change has been indexed. --- search/classes/document.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/search/classes/document.php b/search/classes/document.php index 7ed70558781..97cdc7b9396 100644 --- a/search/classes/document.php +++ b/search/classes/document.php @@ -231,6 +231,8 @@ class document implements \renderable, \templatable { if ($file = $fs->get_file_by_id($id)) { $this->files[$id] = $file; + } else { + unset($this->files[$id]); // Index is out of date and referencing a file that does not exist. } } } From 856fa5844086651c4e3093fbb58d5726daeca3d2 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 13 Sep 2017 12:40:53 +1200 Subject: [PATCH 2/2] MDL-60105 mod_folder: Set timemodified on change Changes to the folder contents were not resulting in the timemodied of the folder activity being set. This prevented global search from picking up the changes. --- mod/folder/edit.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/folder/edit.php b/mod/folder/edit.php index 1d40e4bde55..e4bb89b7702 100644 --- a/mod/folder/edit.php +++ b/mod/folder/edit.php @@ -61,11 +61,11 @@ if ($mform->is_cancelled()) { } else if ($formdata = $mform->get_data()) { $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0); - $DB->set_field('folder', 'revision', $folder->revision+1, array('id'=>$folder->id)); - - // Update the variable of the folder revision so we can pass it as an accurate snapshot later. + $folder->timemodified = time(); $folder->revision = $folder->revision + 1; + $DB->update_record('folder', $folder); + $params = array( 'context' => $context, 'objectid' => $folder->id