-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this 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!
@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? |
...or, alternatively, just throw an exception if this is not really an expected situation. |
@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. |
@demiankatz I also updated the changelog and added a simple test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @xmorave2!
There was a problem hiding this 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
There was a problem hiding this 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.
No description provided.