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

Allow for value to be absent #1047

Merged
merged 1 commit into from
Aug 8, 2024
Merged

Allow for value to be absent #1047

merged 1 commit into from
Aug 8, 2024

Conversation

adam-vessey
Copy link

GitHub Issue: (link)

Islandora/documentation#2338

  • Other Relevant Links (Google Groups discussion, related pull requests,
    Release pull requests, etc.)

What does this Pull Request do?

A brief description of what the intended result of the PR will be and/or what
problem it solves.

What's new?

A in-depth description of the changes made by this PR. Technical details and
possible side effects.

  • Changes x feature to such that y
  • Added x
  • Removed y
  • Does this change add any new dependencies?
  • Does this change require any other modifications to be made to the repository
    (i.e. Regeneration activity, etc.)?
  • Could this change impact execution of existing code?

How should this be tested?

A description of what steps someone could take to:

  • Reproduce the problem you are fixing (if applicable)
  • Test that the Pull Request does what is intended.
  • Please be as detailed as possible.
  • Good testing instructions help get your PR completed faster.

Documentation Status

  • Does this change existing behaviour that's currently documented?
  • Does this change require new pages or sections of documentation?
  • Who does this need to be documented for?
  • Associated documentation pull request(s): ___ or documentation issue ___

Additional Notes:

Any additional information that you think would be helpful when reviewing this
PR.

Interested parties

Tag (@ mention) interested parties or, if unsure, @Islandora/committers

@xurizaemon
Copy link

I do not think the change here is correct. \Drupal\islandora\IslandoraUtils::getTermForUri accepts a string per its phpdoc comment, so should not be passed NULL. It doesn't yet have a type declaration on the function argument but may in future.

Regardless, it doesn't make sense to pass NULL to an entityquery (which getTermForURI() will run) to obtain a NULL, that just moves the issue up the chain.

I propose this instead: #1048

Not yet tested, but will be able to in a few hours.

@adam-vessey
Copy link
Author

@xurizaemon: I'm not seeing where in my code it would be possible for NULL to be passed to IslandoraUtils::getTermForUri()? NULL would be false-y, so it would just memoize and return NULL?

-      $this->structuredTextTerm = $this->utils->getTermForUri($this->options['structured_text_term_uri']);
+      $uri = $this->options['structured_text_term_uri'] ?? NULL;
+      $this->structuredTextTerm = $uri ? $this->utils->getTermForUri($uri) : NULL;

If it's not in the ->options array, $uri would be NULL, if $uri is NULL (or otherwise false-y), it would assign NULL directly ->structuredTextTerm, which already nullable, as the return from ::getTermFormUri() is nullable.

@xurizaemon
Copy link

You're right, I'd misread that on my mobile. Apologies and carry on! I will test your fix in a few hours, since I can repro this.

@xurizaemon
Copy link

Tested locally, this works perfectly well and as @adam-vessey indicated above. Thanks!

@rosiel rosiel merged commit ea87476 into 2.x Aug 8, 2024
27 checks passed
@rosiel rosiel deleted the adam-vessey-patch-1 branch August 8, 2024 17:02
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.

3 participants