From 78c875b02e233d1afec3995d1ef38420dc4d7a8b Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 17 May 2022 15:16:08 +1200 Subject: [PATCH] FIX Check current controller has a functional link --- src/Model/ElementForm.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Model/ElementForm.php b/src/Model/ElementForm.php index 78cd3a5..184fe67 100644 --- a/src/Model/ElementForm.php +++ b/src/Model/ElementForm.php @@ -7,6 +7,7 @@ use SilverStripe\Control\Controller; use DNADesign\Elemental\Models\BaseElement; use DNADesign\ElementalUserForms\Control\ElementFormController; +use SilverStripe\Control\RequestHandler; class ElementForm extends BaseElement { @@ -37,10 +38,16 @@ public function Form() return $controller->renderWith(UserDefinedFormController::class .'_ReceivedFormSubmission'); } + // $current may not have a functional Link(), e.g. QueuedTaskRunner during solr reindex + // surpress E_USER_WARNING from RequestHandler::Link() if url_segment config missing + set_error_handler(fn(int $errno, string $errstr) => true, E_USER_WARNING); + $link = $current->Link(); + restore_error_handler(); + $form = $controller->Form(); $form->setFormAction( Controller::join_links( - $current->Link(), + $link, 'element', $this->owner->ID, 'Form'