Bug 30689 - Incorrect Babeltheque setting can cause console warning
Summary: Incorrect Babeltheque setting can cause console warning
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low trivial (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-05 11:03 UTC by Owen Leonard
Modified: 2022-05-13 08:17 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00


Attachments
Bug 30689: Incorrect Babeltheque setting can cause console warning (2.17 KB, patch)
2022-05-05 11:25 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 30689: Incorrect Babeltheque setting can cause console warning (2.22 KB, patch)
2022-05-09 05:59 UTC, David Nind
Details | Diff | Splinter Review
Bug 30689: Incorrect Babeltheque setting can cause console warning (2.28 KB, patch)
2022-05-13 07:17 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2022-05-05 11:03:36 UTC
If you have the "Babeltheque" system preference enabled but the "Babeltheque_url_js" preference is empty, the template will generate an empty <script> tag. This triggers a warning in the browser console.
Comment 1 Owen Leonard 2022-05-05 11:25:49 UTC
Created attachment 134635 [details] [review]
Bug 30689: Incorrect Babeltheque setting can cause console warning

This patch adds an additional system preference check to the part of the
OPAC bibliographic detail template which conditionally loads Babelthèque
JavaScript. The script tag should not be output if there is no
Babeltheque_url_js setting to use.

To test, apply the patch and search for "Babeltheque" in system
preferences.

 - Set "Babeltheque" to "Do" include information.
 - Enter a path in the "Babeltheque_url_js" preference, e.g.
   "https://www.example.com/example.js" It doesn't have to be a valid
   Babeltheque URL.
 - In the OPAC, view the bibliographic detail page for any title. If you
   used a dummy URL for the js preference you should see an error in the
   console about the file not being found. This confirms that the
   template logic is working. If you used a working Babeltheque URL then
   the corresponding content should load.
 - Return to system preferences and remove the URL from the
   "Babeltheque_url_js" preference.
 - Return to the bibliographic detail page in the OPAC and confirm that
   there is no warning in the console about "'src' attribute of <script>
   element is empty."
Comment 2 David Nind 2022-05-09 05:59:26 UTC
Created attachment 134773 [details] [review]
Bug 30689: Incorrect Babeltheque setting can cause console warning

This patch adds an additional system preference check to the part of the
OPAC bibliographic detail template which conditionally loads Babelthèque
JavaScript. The script tag should not be output if there is no
Babeltheque_url_js setting to use.

To test, apply the patch and search for "Babeltheque" in system
preferences.

 - Set "Babeltheque" to "Do" include information.
 - Enter a path in the "Babeltheque_url_js" preference, e.g.
   "https://www.example.com/example.js" It doesn't have to be a valid
   Babeltheque URL.
 - In the OPAC, view the bibliographic detail page for any title. If you
   used a dummy URL for the js preference you should see an error in the
   console about the file not being found. This confirms that the
   template logic is working. If you used a working Babeltheque URL then
   the corresponding content should load.
 - Return to system preferences and remove the URL from the
   "Babeltheque_url_js" preference.
 - Return to the bibliographic detail page in the OPAC and confirm that
   there is no warning in the console about "'src' attribute of <script>
   element is empty."

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2022-05-09 06:18:23 UTC
Testing notes (koha-testing-docker):

- Warning message in browser console before patch applied: ‘src’ attribute of <script> element is empty.

- There was then an empty script tag in the browser source file for the page: <script src=" "></script>

- This was just after this text in the browser source file:

      <div class="babeltheque_adds">
           <div id="BW_critiques_aj"></div>
            <div id="BW_citations_aj"></div>
      </div>

- When patch applied, these were the console error messages:
  . GET https://www.example.com/example.js [HTTP/2 404 Not Found 1554ms]
  . Loading failed for the <script> with source “https://www.example.com/example.js”.
Comment 4 Katrin Fischer 2022-05-13 07:17:33 UTC
Created attachment 134944 [details] [review]
Bug 30689: Incorrect Babeltheque setting can cause console warning

This patch adds an additional system preference check to the part of the
OPAC bibliographic detail template which conditionally loads Babelthèque
JavaScript. The script tag should not be output if there is no
Babeltheque_url_js setting to use.

To test, apply the patch and search for "Babeltheque" in system
preferences.

 - Set "Babeltheque" to "Do" include information.
 - Enter a path in the "Babeltheque_url_js" preference, e.g.
   "https://www.example.com/example.js" It doesn't have to be a valid
   Babeltheque URL.
 - In the OPAC, view the bibliographic detail page for any title. If you
   used a dummy URL for the js preference you should see an error in the
   console about the file not being found. This confirms that the
   template logic is working. If you used a working Babeltheque URL then
   the corresponding content should load.
 - Return to system preferences and remove the URL from the
   "Babeltheque_url_js" preference.
 - Return to the bibliographic detail page in the OPAC and confirm that
   there is no warning in the console about "'src' attribute of <script>
   element is empty."

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 5 Fridolin Somers 2022-05-13 08:17:19 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄