"Uncaught ValueError: Path cannot be empty" when importing module settings to new project
Closed this issue · 2 comments
tertek commented
On PHP8 PDF Injector will throw the following error when accessing the module page, if:
- module settings have been imported
- module settings include injections with reference to documents
REDCap crashed due to an unexpected PHP fatal error!
Error message: Uncaught ValueError: Path cannot be empty in modules/pdf_injector_v2.1.0/pdfInjector.php:828 Stack trace: #0 modules/pdf_injector_v2.1.0/pdfInjector.php(828): file_get_contents() #1 modules/pdf_injector_v2.1.0/Injections.php(54): STPH\pdfInjector\pdfInjector->base64FromId() #2 redcap_v12.0.25/ExternalModules/index.php(126): require('...') #3 {main} thrown
File: modules/pdf_injector_v2.1.0/pdfInjector.php
Line: 828
Possible problem:
The documents are not ported during export, having an non-existing $path
. This why the function file_get_contents($path)
call at line 828 throws above error.
Suggestion to fix:
Check if $path
is true:
if($path) {
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
return 'data:image/' . $type . ';base64,' . base64_encode($data);
}
tertek commented
Note: The problem during export still stays. A specific issue for that needs to be openend.