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

Do not treat 0 as boolean value in the REST controller #1276

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

kinow
Copy link
Collaborator

@kinow kinow commented Feb 17, 2022

Reasons for creating this PR

Prevent 0 being treated as a truthy value in the REST controller. Complements #1261

Link to relevant issue(s), if any

Description of the changes in this PR

Same fix as #1261

Known problems or uncertainties in this PR

None.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if not, explain why below)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma
Copy link
Member

osma commented Feb 17, 2022

Can you please rebase @kinow, so we can see if #1277 worked?

@osma
Copy link
Member

osma commented Feb 17, 2022

This is now overlapping with #1267 by @miguelvaara - there are changes to the same lines in ConceptSearchParameters.getSearchTerm. These need to be consolidated somehow. Maybe simply by merging one first, then fixing the conflicts in the other.

@kinow
Copy link
Collaborator Author

kinow commented Feb 17, 2022

Rebased, GH Actions working 🧰 thanks @osma !

@codecov
Copy link

codecov bot commented Feb 17, 2022

Codecov Report

Merging #1276 (5037842) into master (b30ac87) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1276      +/-   ##
============================================
+ Coverage     69.33%   69.36%   +0.02%     
- Complexity     1648     1649       +1     
============================================
  Files            32       32              
  Lines          4047     4047              
============================================
+ Hits           2806     2807       +1     
+ Misses         1241     1240       -1     
Impacted Files Coverage Δ
model/ConceptSearchParameters.php 85.55% <100.00%> (+1.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b30ac87...5037842. Read the comment docs.

@osma
Copy link
Member

osma commented Feb 17, 2022

The code looks good - I think the easiest way forward is to merge this first and then sort out the conflicts in PR #1267, as that one is still a bit WIP (at least the PR description is outdated).

The only thing I wonder about is the title of this PR (and the commit message) which says "Do not treat 0 as truthy value". Isn't the point actually the opposite - "Do not treat 0 as a non-truthy (i.e. false) value"?

@kinow kinow changed the title Do not treat 0 as truthy value in the REST controller Do not treat 0 as boolean value in the REST controller Feb 17, 2022
@kinow
Copy link
Collaborator Author

kinow commented Feb 17, 2022

You're right! s/truthy/boolean , WDYT?

@osma
Copy link
Member

osma commented Feb 17, 2022

Sounds good!

@@ -86,6 +86,26 @@ public function testGetSearchTerm() {
$this->assertEquals('test', $params->getSearchTerm());
}

/**
* For https://github.com/NatLibFi/Skosmos/issues/1275, to verify
* that querying for `0` (zero) does not evaluate it as a truthy
Copy link
Member

Choose a reason for hiding this comment

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

s/truthy/boolean/ here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, missed that one. Just a sec.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. That should be the last one ™

Copy link
Member

Choose a reason for hiding this comment

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

Famous last words!

@sonarcloud
Copy link

sonarcloud bot commented Feb 17, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
4.0% 4.0% Duplication

@osma
Copy link
Member

osma commented Feb 17, 2022

Will do one final test round and then merge!

@osma osma merged commit 5c3cc4d into NatLibFi:master Feb 17, 2022
@osma
Copy link
Member

osma commented Feb 17, 2022

Works like a charm! Thanks a lot @kinow !

@osma osma added this to the 2.14 milestone Feb 17, 2022
@kinow kinow deleted the fix-1275 branch February 17, 2022 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Searching via API using the search term '0' without asterisk (0*) fails
2 participants