Failed locally cache tracking code file

Created on 15 March 2023, over 1 year ago
Updated 1 December 2023, 10 months ago

Problem/Motivation

Doesn't possible to use option "Locally cache tracking code file".

error: Refused to execute script from 'https://****/sites/default/files/googleanalytics/js?rrksba' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

Steps to reproduce

Enable option "Locally cache tracking code file" and check JS errors

Proposed resolution

The cached file should have extension "js"

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

2.7

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany M@ster

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @M@ster
  • πŸ‡¬πŸ‡§United Kingdom Greg Varga

    A temporary, quick fix until the official solution comes out.

    all/modules/contrib/google_analytics/googleanalytics.module
    index f7325a92..b4308522 100644
    --- a/sites/all/modules/contrib/google_analytics/googleanalytics.module
    +++ b/sites/all/modules/contrib/google_analytics/googleanalytics.module
    @@ -540,8 +540,7 @@ function googleanalytics_search_get_keys() {
      */
     function _googleanalytics_cache($location, $synchronize = FALSE) {
       $path = 'public://googleanalytics';
    -  $file_destination = $path . '/' . basename($location);
    +  $file_destination = $path . '/' . basename($location, ".js").".js";
    
       if (!file_exists($file_destination) || $synchronize) {
         // Download the latest tracking code.
         $result = drupal_http_request($location);
    
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States cboyden

    I've added the above suggested code as a patch so it can be tested.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Just ran into the same issue. Any idea why this happened exactly NOW?

    Any Drupal core changes or browser updates that may have caused this?

  • πŸ‡ΊπŸ‡ΈUnited States briand44

    The patch in #3 applied cleanly against 7.x-2.8 and resolved this issue for us, thanks!

Production build 0.71.5 2024