lsgs / redcap-extended-reports

Provides various additional options to enhance REDCap's built-in reporting functionality.
GNU General Public License v3.0
1 stars 4 forks source link

Error: Cannot pass parameter 4 by reference error #6

Closed steentje34 closed 8 months ago

steentje34 commented 1 year ago

Using REDCap v13.1.37 in combination with version 2.0.1 of the external module, we have been receiving the following error:

The 'extended_reports' module threw the following exception when calling the hook method 'redcap_every_page_before_render':

Error: Cannot pass parameter 4 by reference in /var/www/html/rcdemot/modules/extended_reports_v2.0.1/Report.php:1130 Stack trace:

0 /var/www/html/rcdemot/modules/extended_reports_v2.0.1/Report.php(555): MCRI\ExtendedReports\Report->makeCsvValue()

1 /var/www/html/rcdemot/modules/extended_reports_v2.0.1/Report.php(445): MCRI\ExtendedReports\Report->doExtendedReport()

2 /var/www/html/rcdemot/modules/extended_reports_v2.0.1/ExtendedReports.php(66): MCRI\ExtendedReports\Report->exportReport()

3 /var/www/html/rcdemot/redcap_v13.1.37/ExternalModules/classes/ExternalModules.php(3254): MCRI\ExtendedReports\ExtendedReports->redcap_every_page_before_render()

4 /var/www/html/rcdemot/redcap_v13.1.37/ExternalModules/classes/ExternalModules.php(3411): ExternalModules\ExternalModules::startHook()

5 /var/www/html/rcdemot/redcap_v13.1.37/ExternalModules/classes/ExternalModules.php(3444): ExternalModules\ExternalModules::ExternalModules{closure}()

6 /var/www/html/rcdemot/redcap_v13.1.37/Classes/Hooks.php(42): ExternalModules\ExternalModules::callHook()

7 /var/www/html/rcdemot/redcap_v13.1.37/Classes/System.php(837): Hooks::call()

8 /var/www/html/rcdemot/redcap_v13.1.37/Config/init_project.php(7): System::initProjectPage()

9 /var/www/html/rcdemot/redcap_v13.1.37/DataExport/data_export_ajax.php(4): require_once('/var/www/html/r...')

10 {main}

URL: https://demoredcap.uzgent.be/redcap_v13.1.37/DataExport/data_export_ajax.php?pid=411&xml_metadata_options=

Looking at the code, the error originates in this line of code: https://github.com/lsgs/redcap-extended-reports/blob/a0bd9b9adf02be9ec4af252a54fc0b0f995ba5c2/Report.php#L1130

Based on the documentation of the str_replace() function, the 4th parameter is optional and should be a variable, that will hold the number of replacements. As it seems that this 4th parameter is not needed in the scope of this module, I think that dropping this parameter could solve the issue.

I will prepare a pull request for this fix.