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

Curb attempt to iterate over NULL from getParentNidsOfFileEntity() #14

Closed
wants to merge 2 commits into from

Conversation

qadan
Copy link

@qadan qadan commented May 14, 2020

\Drupal\embargoes\EmbargoesEmbargoesService\getParentNidsOfFileEntity() returns either NULL or an array depending on found relationships. Both times it's being used in practice in embargoes.module, the results are being passed to getActiveEmbargoesByNids(), which passes them through to getCurrentEmbargoesByNids(), which passes them through to getAllEmbargoesByNids(), which attempts to iterate over them as an array. If the file entity doesn't have any parents, iterating over NULL causes an error to be thrown.

It's hard to tell the direction to go in here (could do a null check in the .module), but I'm thinking it's perhaps reasonable to enforce that getParentNidsOfFileEntity() returns an array that may be empty if there are no such node IDs or aren't accessible.

@qadan
Copy link
Author

qadan commented Aug 10, 2020

Superseded by #15

@qadan qadan closed this Aug 10, 2020
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

Successfully merging this pull request may close these issues.

2 participants