From 5021b3a5b5e03f0f8744a784c4fcf6f216769bf9 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 10 Feb 2023 10:41:50 +0000 Subject: [PATCH] MDL-68776 search: remove support for optional add_documents return. All six returned array elements must now be present. --- search/classes/manager.php | 22 ++-------------------- search/upgrade.txt | 5 +++++ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/search/classes/manager.php b/search/classes/manager.php index bbb81080e81..fd25afa2cf7 100644 --- a/search/classes/manager.php +++ b/search/classes/manager.php @@ -1289,15 +1289,8 @@ class manager { if ($batches !== $numdocs + $numdocsignored) { $batchinfo = ' (' . $batches . ' batch' . ($batches === 1 ? '' : 'es') . ')'; } - } else if (count($result) === 5) { - // Backward compatibility for engines that don't return a batch count. - [$numrecords, $numdocs, $numdocsignored, $lastindexeddoc, $partial] = $result; - // Deprecated since Moodle 3.10 MDL-68690. - // TODO: MDL-68776 This will be deleted in Moodle 4.2. - debugging('engine::add_documents() should return $batches (5-value return is deprecated)', - DEBUG_DEVELOPER); } else { - throw new coding_exception('engine::add_documents() should return $partial (4-value return is deprecated)'); + throw new \coding_exception('engine::add_documents() should return 6 values'); } if ($numdocs > 0) { @@ -1454,19 +1447,8 @@ class manager { if ($batches !== $numdocs + $numdocsignored) { $batchinfo = ' (' . $batches . ' batch' . ($batches === 1 ? '' : 'es') . ')'; } - } else if (count($result) === 5) { - // Backward compatibility for engines that don't return a batch count. - [$numrecords, $numdocs, $numdocsignored, $lastindexeddoc, $partial] = $result; - // Deprecated since Moodle 3.10 MDL-68690. - // TODO: MDL-68776 This will be deleted in Moodle 4.2 (as should the below bit). - debugging('engine::add_documents() should return $batches (5-value return is deprecated)', - DEBUG_DEVELOPER); } else { - // Backward compatibility for engines that don't support partial adding. - list($numrecords, $numdocs, $numdocsignored, $lastindexeddoc) = $result; - debugging('engine::add_documents() should return $partial (4-value return is deprecated)', - DEBUG_DEVELOPER); - $partial = false; + throw new \coding_exception('engine::add_documents() should return 6 values'); } if ($numdocs > 0) { diff --git a/search/upgrade.txt b/search/upgrade.txt index d7037ad1856..27b9451e800 100644 --- a/search/upgrade.txt +++ b/search/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /search/*, information provided here is intended especially for developers. +=== 4.2 === + +* Support for optional final element returned by engine `add_documents()` implementations is now removed, all + six expected returned array elements must be present + === 3.10 === * Search indexing now supports sending multiple documents to the server in a batch. This is implemented