-
Notifications
You must be signed in to change notification settings - Fork 94
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
Don't crash on incomplete vocabulary configuration #1409
Conversation
If a vocabulary configuration has no `void:uriSpace`, an error message should be shown instead of crashing. This fixes NatLibFi#1408.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1409 +/- ##
============================================
+ Coverage 69.55% 69.57% +0.01%
- Complexity 1650 1651 +1
============================================
Files 32 32
Lines 4257 4259 +2
============================================
+ Hits 2961 2963 +2
Misses 1296 1296
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Thanks for the PR! I wonder what the implications are for omitting uriSpace. I mean, this PR obviously fixes the immediate crash, but the setting is used in several places in both PHP and JS code, so just returning a |
Without |
I tested this PR locally on a vocabulary with a commented out uriSpace setting. As expected it fixes the immediate PHP crash. But there are consequences on the JS side. When clicking a concept from the hierarchy, this error is shown on the JS console:
I traced this to some fragile JS code that is run when doing partial page loads. It can be fixed by this patch to diff --git a/view/scripts.twig b/view/scripts.twig
index 2b77ae9f..725444ec 100644
--- a/view/scripts.twig
+++ b/view/scripts.twig
@@ -31,6 +31,8 @@ var prefLabels = [{"lang": "{{ search_results|first.label.lang }}","label": "{{
{% endif %}
{% if request.vocab and request.vocab.uriSpace %}
var uriSpace = "{{ request.vocab.uriSpace }}";
+{% else %}
+var uriSpace = null;
{% endif %}
var showNotation = {% if request.vocab and not request.vocab.config.showNotation %}false{% else %}true{% endif %};
{% if request.vocab %} I will try to add this fix to this PR branch before merging it. It seems that the |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Thank you for the PR @nichtich ! This will go into the |
If a vocabulary configuration has no
void:uriSpace
, an error message should be shown instead of crashing. This closes #1408.