From ac814ba3cc8b7ab287a6d8657af4becf141a61f1 Mon Sep 17 00:00:00 2001 From: vasishthsidarala Date: Mon, 10 Jul 2023 14:19:52 +1000 Subject: [PATCH 1/4] add table_exists check in update_object_by_hash function --- classes/local/manager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/local/manager.php b/classes/local/manager.php index c746b9c2..b7779e18 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -139,6 +139,11 @@ public static function update_object_by_hash($contenthash, $newlocation, $filesi $newobject = new stdClass(); $newobject->contenthash = $contenthash; + if (!$DB->get_manager()->table_exists('tool_objectfs_objects')){ + debugging('The tool_objectfs plugin tables have not been installed yet. Skipping update_object_by_hash..'); + return; + } + $oldobject = $DB->get_record('tool_objectfs_objects', ['contenthash' => $contenthash]); if ($oldobject) { $newobject->timeduplicated = $oldobject->timeduplicated; From 4e890428ccfae7f0e676888474ef1ddc9dc64e41 Mon Sep 17 00:00:00 2001 From: vasishthsidarala Date: Mon, 10 Jul 2023 14:29:02 +1000 Subject: [PATCH 2/4] add table_exists check in update_object_by_hash function --- classes/local/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/local/manager.php b/classes/local/manager.php index b7779e18..97de2d9a 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -139,7 +139,7 @@ public static function update_object_by_hash($contenthash, $newlocation, $filesi $newobject = new stdClass(); $newobject->contenthash = $contenthash; - if (!$DB->get_manager()->table_exists('tool_objectfs_objects')){ + if (!$DB->get_manager()->table_exists('tool_objectfs_objects')) { debugging('The tool_objectfs plugin tables have not been installed yet. Skipping update_object_by_hash..'); return; } From cfb35f10824520548b02cb11ba8493bfd371b2e6 Mon Sep 17 00:00:00 2001 From: vasishthsidarala Date: Mon, 10 Jul 2023 15:12:21 +1000 Subject: [PATCH 3/4] using during_initial_install check instead of db call --- classes/local/manager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/classes/local/manager.php b/classes/local/manager.php index 97de2d9a..8a30a4c2 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -139,8 +139,7 @@ public static function update_object_by_hash($contenthash, $newlocation, $filesi $newobject = new stdClass(); $newobject->contenthash = $contenthash; - if (!$DB->get_manager()->table_exists('tool_objectfs_objects')) { - debugging('The tool_objectfs plugin tables have not been installed yet. Skipping update_object_by_hash..'); + if (during_initial_install()) { return; } From eb808d958e72966d99286362183aebabb6cea04b Mon Sep 17 00:00:00 2001 From: vasishthsidarala Date: Wed, 12 Jul 2023 10:56:30 +1000 Subject: [PATCH 4/4] changed line numbers --- classes/local/manager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/local/manager.php b/classes/local/manager.php index 8a30a4c2..89f4f639 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -136,13 +136,14 @@ public static function get_client($config) { */ public static function update_object_by_hash($contenthash, $newlocation, $filesize = null) { global $DB; - $newobject = new stdClass(); - $newobject->contenthash = $contenthash; if (during_initial_install()) { return; } + $newobject = new stdClass(); + $newobject->contenthash = $contenthash; + $oldobject = $DB->get_record('tool_objectfs_objects', ['contenthash' => $contenthash]); if ($oldobject) { $newobject->timeduplicated = $oldobject->timeduplicated;