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

Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array #45

Open
tertek opened this issue Jul 24, 2024 · 6 comments

Comments

@tertek
Copy link
Collaborator

tertek commented Jul 24, 2024

Issue reported by user on REDCap Community:

"I've encountered an error with the module I was hoping you could help with.

The issue occurs when trying to open the injected PDF using the action tag field.
Also, when trying to open the pdf from the record home page nothing happens.

REDCap Version 14.0.33
PDF Injector - v3.1.0

REDCap crashed due to an unexpected PHP fatal error!

Error message: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in modules\pdf_injector_v3.1.0\pdfInjector.php:314 Stack trace: #0 modules\pdf_injector_v3.1.0\pdfInjector.php(314): array_filter() #1 modules\pdf_injector_v3.1.0\preview.php(13): STPH\pdfInjector\pdfInjector->renderInjection() #2 redcap_v14.0.33\ExternalModules\index.php(146): require('...') #3 {main} thrown
File: modules\pdf_injector_v3.1.0\pdfInjector.php
Line: 314"

Source:

https://redcap.vumc.org/community/post.php?id=108925&comment=235866

@tertek
Copy link
Collaborator Author

tertek commented Jul 24, 2024

Could you please explain what you mean by "using the action tag field" ?

@tertek
Copy link
Collaborator Author

tertek commented Jul 24, 2024

Also please report your PHP version.

@BHDIdata
Copy link

Hello, David here, I will provide as much as I can:

PHP 8.1.3 (Windows OS)

This field when clicking on the button shows the original error:

685 | [gp_letter_inject] | Gp Letter Injection Test | descriptiveField Annotation: @PDFI='260472' -- | -- | -- | --

image

Clicking on the thumbnail below does not do anything:
image

I have cloned the project and the cloned version works fine, with all pdf injections running, but in the original project (which was created 2023-11-28) it does not work.

@tertek
Copy link
Collaborator Author

tertek commented Jul 24, 2024

Hi @BHDIdata
The error is referring to line 314 where user permissions are being checked:

$no_access_forms = array_keys(array_filter($user_rights[$user_id]["forms"], function($value){
return $value == 0;
}));

Could you please compare the user's rights that you encounter the error with, and report back if there is anything different regarding access on that specific project and form?

It is a bug for sure! Thanks :)

@tertek
Copy link
Collaborator Author

tertek commented Jul 24, 2024

@BHDIdata The second issue with the thumbnail seems to be a problem in JavaScript. Could you please open the Developer Tools of your browser and check if there are any red messages (errors?)

Please also ensure, that in Module settings the option "Debug" is enabled.

image

@BHDIdata
Copy link

Ahh interesting, I realised that my admin account was not actually added to the permissions of the project, since as an admin I rarely need to be. Adding my admin account to the project with permissions has allowed me to access the injected pdf using the action tag button inside the instrument.

However, the javascript button and thumbnail still do not activate

I've refreshed the page and opened the console, this error appears when clicking the button:

image

record_home.php?pid=1093&arm=1&id=ELF_001:128
Uncaught ReferenceError: ELF_001 is not defined
at HTMLAnchorElement.onclick (record_home.php?pid=1093&arm=1&id=ELF_001:128:220)

In this project, "ELF_001" is the name of the first record, implemented by a module "Custom Record Auto-numbering - v1.0.6" by Luke Stevens (Murdoch Children's Research Institute)
The cloned project does not have this, as I had not thought it necessary for testing, but perhaps that is the cause.

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

2 participants