Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error in PHP 8 #32

Open
zenourn opened this issue Mar 14, 2022 · 1 comment
Open

Fatal error in PHP 8 #32

zenourn opened this issue Mar 14, 2022 · 1 comment

Comments

@zenourn
Copy link

zenourn commented Mar 14, 2022

When using REDCap 12.2.1 and PHP 8.0.14 I get a fatal error when attempting to configure this within a project:

REDCap crashed due to an unexpected PHP fatal error!

Error message: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in modules/email_alerts_v2.3.14/configure.php:46 Stack trace: #0 modules/email_alerts_v2.3.14/configure.php(46): sizeof() #1 redcap_v12.2.1/ExternalModules/index.php(126): require('...') #2 {main} thrown
File: modules/email_alerts_v2.3.14/configure.php
Line: 46

based upon a similar error in another external module:

https://community.projectredcap.org/questions/119956/cross-project-piping-php-8-error.html

It looks like this module is incompatible with PHP 8?

@zenourn
Copy link
Author

zenourn commented May 18, 2022

I got around to fixing this, was due to some changes in PHP8.

in configure.php I changed:

$indexSubSet = sizeof($config['email-dashboard-settings'][1]['value']);

to

$indexSubSet = 0;
$value = $config['email-dashboard-settings'][1]['value'];
if (is_countable($value) && count($value) > 0) {
        $indexSubSet = sizeof($value);
}

in saveForm.php I changed:

$new_alert_id = max($alert_id) + 1;

to:

$max_alert_id = 1;
if (count($alert_id)>0) {
        $max_alert_id = max($alert_id) + 1;
}

and everything seems to work. After further testing and also testing under previous versions of PHP will then submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant