CMS MADE SIMPLE FORGE

CGFEURegister

 

[#12296] Error 500 if field fault

avatar
Created By: TimdeBuurman (timdebuurman)
Date Submitted: Thu Apr 23 03:44:07 -0400 2020

Assigned To: Robert Campbell (calguy1000)
Version: 1.0.4
CMSMS Version: 2.2.14
Severity: Major
Resolution: None
State: Open
Summary:
Error 500 if field fault
Detailed Description:
Hi,

The website page gone white after putting the tag on it.
At first could not find anything.

Later found out that there was a fault in /lib/class.RegField.php what was
triggered because I had only one field in a dropdown.
The field in my dropdown triggerd this fault in the code and gave a error 500

Solution:

Added 'Exception' in the code below (2 places) in /lib/class.RegField.php from
line 77

Current code:

if( $obj->required != 1 && $obj->required != 2 ) throw new
\InvalidArgument('Invalid required value.  must be 1 or 2');
        switch( $obj->type ) {
        case 4: // dropdown
        case 5: // multiselect
        case 7: // radiobtns
if( !is_array($obj->options) || count($obj->options) < 2 ) throw new
\InvalidArgument('dropdown/radio button fields must have at least 2 options');
            break;
        }


Fixed:

if( $obj->required != 1 && $obj->required != 2 ) throw new
\InvalidArgumentException('Invalid required value.  must be 1 or 2');
        switch( $obj->type ) {
        case 4: // dropdown
        case 5: // multiselect
        case 7: // radiobtns
if( !is_array($obj->options) || count($obj->options) < 2 ) throw new
\InvalidArgumentException('dropdown/radio button fields must have at least 2
options');
            break;
        }


History