Research-IT-Swiss-TPH / redcap-pdf-injector

PDF Injector is a REDCap module that enables you to populate fillable PDFs with record data from variables.
https://research-it-swiss-tph.github.io/redcap-pdf-injector/
MIT License
7 stars 8 forks source link

Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in .\[..]\batch.php:123 #28

Closed tertek closed 9 months ago

tertek commented 1 year ago

When trying a batch download (through REDCap reports), there will be an error in following scenario:

Full Error Message:

Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in \www\redcap\modules\pdf_injector_v2.2.0\batch.php:123 Stack trace: #0 \www\redcap\modules\pdf_injector_v2.2.0\batch.php(123): fwrite(false, '%PDF-1.6\n%\xE2\xE3\xCF\xD3\n...') #1 \www\redcap\redcap_v12.4.26\ExternalModules\index.php(126): require('C:\\laragon\\www\\...') #2 {main} thrown in \www\redcap\modules\pdf_injector_v2.2.0\batch.php on line 123
REDCap crashed due to an unexpected PHP fatal error!

Error message: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in modules\pdf_injector_v2.2.0\batch.php:123 Stack trace: #0 modules\pdf_injector_v2.2.0\batch.php(123): fwrite(false, '%PDF-1.6\n%\xE2\xE3\xCF\xD3\n...') #1 redcap_v12.4.26\ExternalModules\index.php(126): require('C:\\laragon\\www\\...') #2 {main} thrown
File: modules\pdf_injector_v2.2.0\batch.php
Line: 123
tertek commented 1 year ago

this issue is a secondary consequence from insufficient memory_limit during zip creation. File deletion will not be processed which leads to blocking fopen which returns false to fwrite.

Possible fix: