CMS MADE SIMPLE FORGE

SmartForms

 

[#12752] Editing a form gives an error (PHP 8.2+)

avatar
Created By: Matt Hornsby (DIGI3) (DIGI3)
Date Submitted: Fri Sep 06 16:25:57 -0400 2024

Assigned To:
Version: 2.1.0
CMSMS Version: 2.2.21
Severity: None
Resolution: None
State: Open
Summary:
Editing a form gives an error (PHP 8.2+)
Detailed Description:
Steps to reproduce:
-Clean install of SmartForms with PHP 8.2 or 8.3
-Edit one of the default included forms.

PHP Fatal error:  Duplicate declaration of static variable $tester in
/path/modules/SmartForms/action.admin_edit_form.php on line 17


History

Comments
avatar
Date: 2025-09-19 09:38
Posted By: Finn Lovenkrands (webform)

I can confirm trying to edit a SmartForm gives 500 error after upgrading PHP to
8.3
      
avatar
Date: 2025-10-04 17:15
Posted By: Jocelyn Lusseau (kraygoon)

I've fixed the problem this way :

-----
if( !$this->VisibleToAdminUser() ) exit;

// ❌ Remove this line :
// static $tester, $scanner;

$make_field_list = function( array $fields ) {
-----

And remove "use ($scanner,$tester)"

-----
$do_scan = function( Form $form, $smarty ) use ($scanner,$tester) {
-----

Become

-----
$do_scan = function( Form $form, $smarty ) {
-----

The code tried to capture $scanner and $tester that didn't even exist in parent
scope, then declared them as static. PHP 8.3 now catches this error instead of
silently allowing it.