Skip to content

SolrUtils::escapeQueryChars returns null if an empty string is passed in #83

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

Closed
datadestroyd opened this issue Mar 28, 2025 · 0 comments · Fixed by #84
Closed

SolrUtils::escapeQueryChars returns null if an empty string is passed in #83

datadestroyd opened this issue Mar 28, 2025 · 0 comments · Fixed by #84
Assignees

Comments

@datadestroyd
Copy link

The following code:

<?php

var_dump(SolrUtils::escapeQueryChars(""));

Resulted in this output:

NULL

But I expected this output instead:

string(0) ""

The documentation states that the function will return the escaped string or false on failure. I don't think escaping an empty string should result in failure, but even if this was intended, the result should be false, not null.

Additionally, I would be like to know under what circumstances escaping even can fail. Maybe the documentation could give an example?

bix0r added a commit to bix0r/pecl-search_engine-solr that referenced this issue Mar 31, 2025
Fixes php#83
There is no reason for returning null given an empty string.
Plus, the methods don't actually "say" they return null, ever.
Also, escapeQueryChars() actually never returns false.
That will be fixed in documentation.
@bix0r bix0r self-assigned this Mar 31, 2025
@bix0r bix0r closed this as completed in #84 Apr 21, 2025
@bix0r bix0r closed this as completed in 3124b1d Apr 21, 2025
bix0r added a commit that referenced this issue Apr 21, 2025
Fix bad return or empty string arguments in SolrUtils
bix0r added a commit to bix0r/doc-en that referenced this issue Apr 21, 2025
As noted in php/pecl-search_engine-solr#83, and fixed in php/pecl-search_engine-solr#84 the method actually never returns anything else then a string.
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 a pull request may close this issue.

2 participants