We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
null
Suppose you have a simple entry search like the following:
{% set results = craft.entries() .search('foo') .orderBy('score') .all() %} {% for r in results %} {{ r.searchScore }} {% endfor %}
This will output all search scores of matching entries. However all numbers were cast to an integer.
If you inspect the search scores at this point (https://github.com/craftcms/cms/blob/v3/src/elements/db/ElementQuery.php#L2909), you'll get the actual floating numbers.
At some point however they are cast to an integer, and I think the culprit could be this line (https://github.com/craftcms/cms/blob/v3/src/base/Element.php#L1837):
$this->searchScore = (int)$this->searchScore ?: null;
searchScore's below 1 should be set to a 0 or the actual floating value.
searchScore
searchScore's below 1 are set to null instead of a number.
3.7.54
PHP 8.0.18
No response
MySQL
The text was updated successfully, but these errors were encountered:
13cc01f
Thanks for reporting that! Just released Craft 3.7.55 and 4.2.5 with a fix.
Sorry, something went wrong.
Awesome, thanks!
No branches or pull requests
What happened?
Description
Suppose you have a simple entry search like the following:
This will output all search scores of matching entries. However all numbers were cast to an integer.
If you inspect the search scores at this point (https://github.com/craftcms/cms/blob/v3/src/elements/db/ElementQuery.php#L2909), you'll get the actual floating numbers.
At some point however they are cast to an integer, and I think the culprit could be this line (https://github.com/craftcms/cms/blob/v3/src/base/Element.php#L1837):
$this->searchScore = (int)$this->searchScore ?: null;
Expected behavior
searchScore
's below 1 should be set to a 0 or the actual floating value.Actual behavior
searchScore
's below 1 are set tonull
instead of a number.Craft CMS version
3.7.54
PHP version
PHP 8.0.18
Operating system and version
No response
Database type and version
MySQL
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: