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

Split OAI server attachNonDeleted function #4160

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

LuomaJuha
Copy link
Contributor

@LuomaJuha LuomaJuha commented Dec 13, 2024

Splits attachNonDeleted metadata fetching part to its own function for easier local modifications.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @LuomaJuha, this is a good idea! Just a couple of comments....

module/VuFind/src/VuFind/OAI/Server.php Show resolved Hide resolved
module/VuFind/src/VuFind/OAI/Server.php Outdated Show resolved Hide resolved
@LuomaJuha LuomaJuha requested a review from demiankatz December 17, 2024 10:06
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested adding a comment below.

Also, I think perhaps there is a simpler and clearer approach to the return value. My understanding is that if the XML is empty, it means there is no XML and the record should be skipped... but if the XML is false, it means there was some kind of error. So I think we could change this in two possible ways:

Option 1: Change the return value of getRecordAsXML to string|false, and then return the XML directly. In the empty check, you can return $xml !== false; so you return false for an error and true for any other empty condition.

Option 2: Change the default_return key of getRecordAsXML to error_encountered (or something similar), and instead of setting it to false in the default case, set it to $xml === false.

What do you think?

module/VuFind/src/VuFind/OAI/Server.php Show resolved Hide resolved
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more comment-related suggestion!

module/VuFind/src/VuFind/OAI/Server.php Outdated Show resolved Hide resolved
@LuomaJuha LuomaJuha requested a review from demiankatz December 17, 2024 13:11
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @LuomaJuha, I think we're almost done, but your most recent change highlighted a flaw in the existing code that I think we might as well clean up while we're here. See below for details!

{
if ('oai_vufind_json' === $format && $this->supportsVuFindMetadata()) {
// Return empty string instead of false for BC.
return $this->getVuFindMetadata($record) ?: '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the commitment to backward compatibility here, but I actually think in this instance, it was a bug that we didn't handle false return values from getVuFindMetadata(). I'd suggest allowing the false return, and also fixing the return type annotation and comment on getVuFindMetadata() to reflect the possibility that an error can occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, well, from an improvement to a bugfix, will adjust :)

@LuomaJuha LuomaJuha requested a review from demiankatz December 18, 2024 12:00
@demiankatz demiankatz added this to the 11.0 milestone Dec 18, 2024
@demiankatz demiankatz added the architecture pull requests that involve significant refactoring / architectural changes label Dec 18, 2024
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and tests are still passing. Thanks, @LuomaJuha!

@demiankatz demiankatz merged commit 45dff88 into vufind-org:dev Dec 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture pull requests that involve significant refactoring / architectural changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants