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

Fix null-handling of skosmos:sparqlGraph #930

Merged
merged 2 commits into from
Feb 11, 2020

Conversation

danmichaelo
Copy link
Contributor

The skosmos:sparqlGraph vocabulary property is listed as optional, but when not set, Skosmos will produce a notice:

Notice:  Trying to access array offset on value of type null in /var/www/html/model/sparql/GenericSparql.php on line 155

The first commit:

  • Adds a null check to the GenericSparql::isDefaultEndpoint() method.
  • Moves the null check from GenericSparql::generateFromClause() to GenericSparql::getVocabGraphs() and updates the former method to use the latter to reduce code duplication.
  • Updates docstrings to use string|null

The second commit:

  • Updates GenericSparql::formatFilterGraph to not add a FILTER clause if none of the vocabularies have a skosmos:sparqlGraph. This adreses the issues where you would always get zero results if you didn't specify skosmos:sparqlGraph for any vocabulary, since that would result in this: FILTER (?graph IN ()).

Note: Apart from the case skosmos:sparqlGraph is not defined for any vocabulary, there is also the case where skosmos:sparqlGraph is specified for some of the vocabularies, but not for others. In that case, the default search will only return results for the vocabularies that do specify skosmos:sparqlGraph, which is potentially confusing I guess. Perhaps it should be noted in the docs that it's a good idea to either include skosmos:sparqlGraph for all vocabularies or for none?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@osma osma added the bug label Feb 10, 2020
@osma osma self-assigned this Feb 10, 2020
@osma osma added this to the Next Tasks milestone Feb 10, 2020
@osma
Copy link
Member

osma commented Feb 10, 2020

Thanks, I will review it soon!

@codecov
Copy link

codecov bot commented Feb 10, 2020

Codecov Report

Merging #930 into master will increase coverage by 7.44%.
The diff coverage is 75%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #930      +/-   ##
============================================
+ Coverage     57.62%   65.06%   +7.44%     
  Complexity     1489     1489              
============================================
  Files            32       32              
  Lines          4170     3690     -480     
============================================
- Hits           2403     2401       -2     
+ Misses         1767     1289     -478
Impacted Files Coverage Δ Complexity Δ
model/Model.php 83.68% <ø> (+3.36%) 105 <0> (ø) ⬇️
model/Vocabulary.php 88.23% <ø> (+1.09%) 107 <0> (ø) ⬇️
model/sparql/GenericSparql.php 92.75% <75%> (+24.67%) 303 <0> (+1) ⬆️
model/resolver/LOCResource.php 0% <0%> (ø) 6% <0%> (ø) ⬇️
model/resolver/WDQSResource.php 0% <0%> (ø) 3% <0%> (ø) ⬇️
controller/Controller.php 13.79% <0%> (+0.3%) 38% <0%> (ø) ⬇️
controller/RestController.php 4.55% <0%> (+0.56%) 147% <0%> (ø) ⬇️
model/Request.php 67.07% <0%> (+0.8%) 50% <0%> (ø) ⬇️
model/ConceptPropertyValue.php 80.24% <0%> (+0.97%) 46% <0%> (ø) ⬇️
model/PluginRegister.php 70.14% <0%> (+1.03%) 28% <0%> (ø) ⬇️
... and 15 more

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 8b34b23...1c02ad7. Read the comment docs.

@osma
Copy link
Member

osma commented Feb 11, 2020

Hmm the Codecov report looks surprising. I'm pretty sure this PR won't increase coverage by over 7 % :)

@osma osma merged commit 1c02ad7 into NatLibFi:master Feb 11, 2020
@osma
Copy link
Member

osma commented Feb 11, 2020

Thanks, looks good and I merged it.

I fixed a couple of minor issues (based on Scrutinizer complaints) in subsequent commits.

@osma osma modified the milestones: Next Tasks, 2.3 Feb 11, 2020
@danmichaelo danmichaelo deleted the fix-graph-null branch February 11, 2020 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants