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

Function preg_replace could return null in case of an error #11

Merged
merged 5 commits into from
Jan 2, 2024

Conversation

xmorave2
Copy link
Contributor

No description provided.

@xmorave2 xmorave2 requested a review from EreMaijala December 14, 2023 11:48
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 for this! I'll wait to see what @EreMaijala thinks before merging. In the meantime, a couple of small things to consider:

1.) Do you mind adding a bullet point about this fix to the "Fixed" section of the "next release" section of CHANGELOG.md? (something like "Do not allow the MarcXml serialization's toString method to illegally return null." would work).

2.) Is there an easy way to cover this case in the test suite? If not, it's probably not a major problem, but if you had a specific test case that led you to make this adjustment, it's probably a good idea to incorporate it to prevent regressions.

Thanks again!

@EreMaijala
Copy link
Contributor

@xmorave2 Is there a real world case where this happens? I wonder if it would make sense to return the unclean XML instead of an empty string?

@demiankatz
Copy link
Member

...or, alternatively, just throw an exception if this is not really an expected situation.

@xmorave2
Copy link
Contributor Author

@EreMaijala Yes, there is real case - we found a record provided by a library system with this issue.

But i realize, that when preg_replace fails, the string is so bad, that it does not make sense to try it use somehow.... So I ended up with just throwing an exception.

@xmorave2
Copy link
Contributor Author

@demiankatz I also updated the changelog and added a simple test

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, @xmorave2!

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.

Actually, I see one small problem -- this just needs vendor/bin/phing php-cs-fixer run on it to fix a minor issue with quotes. Once that is done and @EreMaijala approves of the changes, I can mint a new release so we can move forward with vufind-org/vufind#3276

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 had a few free moments this morning, so I went ahead and applied the style fix. I think this is ready to merge, but I'll wait until @EreMaijala has a chance to look at it first.

@demiankatz demiankatz merged commit 9291757 into vufind-org:dev Jan 2, 2024
3 checks passed
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