lsgs / redcap-record-autonumbering

REDCap External Module enabling different record auto-numbering options
GNU General Public License v3.0
10 stars 8 forks source link

Exception while enabling module: Undefined constant "MCRI\RecordAutonumber\PROJECT_ID" #16

Closed dhuacon closed 2 years ago

dhuacon commented 2 years ago

My Stack: REDCap 12.4.3 · PHP 8.0.0 (Windows OS) · MySQL 5.5.45

Error when trying to install Custom Record Auto-numbering module.

#0 C:\inetpub\wwwroot\redcap\redcap_v12.4.3\ExternalModules\classes\ExternalModules.php(3734): MCRI\RecordAutonumber\RecordAutonumber->__construct()
#1 C:\inetpub\wwwroot\redcap\redcap_v12.4.3\ExternalModules\classes\ExternalModules.php(1777): ExternalModules\ExternalModules::getFrameworkInstance()
#2 C:\inetpub\wwwroot\redcap\redcap_v12.4.3\ExternalModules\manager\ajax\enable-module.php(60): ExternalModules\ExternalModules::enableAndCatchExceptions()
#3 {main}

This module requests the following permissions:

error_module

dr01d3r commented 2 years ago

The error is likely due to this line:

https://github.com/lsgs/redcap-record-autonumbering/blob/c5461a7f80583fbeffee03af8449257139453d8a/RecordAutonumber.php#L49

It's likely that in a recent version of REDCap, the EM framework has pulled further away from the usage of the global constant PROJECT_ID. Additionally, many standard REDCap things (like PROJECT_ID) may not be available during a handful of module-based tasks (i.e. enable, update, and the automated cron that validates EMs).

@lsgs you may want to consider pulling everything out of the constructor, into some initialization method, and only consume it when in project context.

dhuacon commented 2 years ago

The error is likely due to this line:

https://github.com/lsgs/redcap-record-autonumbering/blob/c5461a7f80583fbeffee03af8449257139453d8a/RecordAutonumber.php#L49

It's likely that in a recent version of REDCap, the EM framework has pulled further away from the usage of the global constant PROJECT_ID. Additionally, many standard REDCap things (like PROJECT_ID) may not be available during a handful of module-based tasks (i.e. enable, update, and the automated cron that validates EMs).

@lsgs you may want to consider pulling everything out of the constructor, into some initialization method, and only consume it when in project context.

Any solutions? If not, I would at least like to know if they are working on one. Thanks

thuan-vanngoc commented 2 years ago

I also have the same problem Redcap version 10.6.3, PHP 8.0.13, MySQL 8.0.28, Linux Centos 9 on a new test server

Do you have a solution or a workaround? When do you think you can put a new version to solve this issue ?

Many thanks

lsgs commented 2 years ago

This is fixed with release v1.0.5.