Missing FitVids.js library causes error in file_get_contents

Created on 22 January 2025, 5 months ago

**Problem/Motivation:**
When the FitVids module is installed, it references a JavaScript file (`jquery.fitvids.js`) that is not included in the module package. This causes errors such as:

Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

2.1

Component

Code

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

Merge Requests

Comments & Activities

  • Issue created by @Haris Khan Jadoon
  • Merge request !7fix: Missing FitVids.js issue → (Open) created by Haris Khan Jadoon
  • 🇮🇳India ravi.joshi53

    Issue
    The problem persist with all of the newer versions such as fitvids 2.1.0, fitvids 2.0.0, fitvids 2.0.x-dev, fitvids 8.x-1.1. It can easily be reproduced just by installation say composer require 'drupal/fitvids:^2.1' or other.

    Workaround
    As a workaround, I made it work by changing $path inside fitvids.install file from $path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js'; to $path = DRUPAL_ROOT . '/modules/contrib/fitvids/js/jquery.fitvids.js';. Also enable js/jquery.fitvids.js: {} and disable /libraries/fitvids/jquery.fitvids.js: {} inside fitvids.libraries.yml file. The error is gone but haven't tested it yet. I need to create a page containing video to test it.

    PS
    I believe that there should be a better way to set $path, i.e., $path = DRUPAL_ROOT . '/modules/contrib/fitvids/js/jquery.fitvids.js'; such as $path = libraries_get_path('fitvids') . '/js/jquery.fitvids.js';. This needs to be tested first.

  • Issue was unassigned.
  • Status changed to Needs review 4 days ago
  • 🇬🇧United Kingdom therobyouknow

    Thank you @ravi.joshi53 in comment #4 - https://www.drupal.org/project/fitvids/issues/3501317#comment-15991650 🐛 Missing FitVids.js library causes error in file_get_contents Needs work
    - I tried out your solution and I found it to work. I have produced a patch for your solution - https://www.drupal.org/files/issues/2025-06-27/fitvids-issue-3501317-com... . (my patch works when applied to 2.1.0 version of the fitvids module)

    I have laid out your comment #4 below to be more readable

    in:
    fitvids.install

    replace:
    $path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js';

    with:
    $path = DRUPAL_ROOT . '/modules/contrib/fitvids/js/jquery.fitvids.js';

    in:
    fitvids.libraries.yml

    uncomment/enable:
    js/jquery.fitvids.js: {}

    comment out/disable:
    /libraries/fitvids/jquery.fitvids.js: {}

    This is my patch file as aforementioned:

    https://www.drupal.org/files/issues/2025-06-27/fitvids-issue-3501317-com... (my patch works when applied to 2.1.0 version of the fitvids module)

    Here is my full composer.json file showing how I apply the patch:

    {
        "name": "drupal/legacy-project",
        "description": "Project template for Drupal 9 projects with composer following drupal/drupal layout",
        "type": "project",
        "license": "GPL-2.0-or-later",
        "homepage": "https://www.drupal.org/project/drupal",
        "support": {
            "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
            "chat": "https://www.drupal.org/node/314178"
        },
        "repositories": [
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            }
        ],
        "require": {
            "composer/installers": "^1.9",
            "cweagans/composer-patches": "^1.7",
            "drupal/better_exposed_filters": "6.0.3",
            "drupal/block_classes": "^1.0",
            "drupal/classy_paragraphs": "^2.0",
            "drupal/color_field": "^3.0",
            "drupal/core-composer-scaffold": "^9.4",
            "drupal/core-project-message": "^9.4",
            "drupal/core-recommended": "^9.4",
            "drupal/core-vendor-hardening": "^9.4",
            "drupal/ctools": "^4.1",
            "drupal/entity_usage": "^2.0@beta",
            "drupal/fitvids": "^2.1",
            "drupal/fontawesome": "^2.26",
            "drupal/media_responsive_thumbnail": "^1.5",
            "drupal/menu_link_attributes": "^1.5",
            "drupal/metatag": "^1.26",
            "drupal/page_specific_class": "^2.0",
            "drupal/paragraphs": "^1.17",
            "drupal/publication_date": "^2.0@beta",
            "drupal/quick_node_clone": "^1.18",
            "drupal/seo_checklist": "^5.2",
            "drupal/simple_sitemap": "^4.1",
            "drupal/structure_sync": "^2.0",
            "drupal/svg_image": "^3.0",
            "drupal/twig_tweak": "^3.3",
            "drupal/viewsreference": "^1.8",
            "drush/drush": "^11.6"
        },
        "conflict": {
            "drupal/drupal": "*"
        },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "config": {
            "allow-plugins": {
                "composer/installers": true,
                "cweagans/composer-patches": true,
                "dealerdirect/phpcodesniffer-composer-installer": true,
                "drupal/core-composer-scaffold": true,
                "drupal/core-project-message": true,
                "drupal/core-vendor-hardening": true
            },
            "sort-packages": true
        },
        "extra": {
            "drupal-scaffold": {
                "locations": {
                    "web-root": "web/"
                }
            },
            "installer-paths": {
                "web/core": [
                    "type:drupal-core"
                ],
                "web/libraries/{$name}": [
                    "type:drupal-library"
                ],
                "web/modules/contrib/{$name}": [
                    "type:drupal-module"
                ],
                "web/profiles/contrib/{$name}": [
                    "type:drupal-profile"
                ],
                "web/themes/contrib/{$name}": [
                    "type:drupal-theme"
                ],
                "drush/Commands/contrib/{$name}": [
                    "type:drupal-drush"
                ],
                "web/modules/custom/{$name}": [
                    "type:drupal-custom-module"
                ],
                "web/profiles/custom/{$name}": [
                    "type:drupal-custom-profile"
                ],
                "web/themes/custom/{$name}": [
                    "type:drupal-custom-theme"
                ]
            },
            "drupal-core-project-message": {
                "include-keys": [
                    "homepage",
                    "support"
                ],
                "post-create-project-cmd-message": [
                    "<bg=blue;fg=white>                                                         </>",
                    "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                    "<bg=blue;fg=white>  from the drupal/legacy-project template!               </>",
                    "<bg=blue;fg=white>                                                         </>",
                    "",
                    "<bg=yellow;fg=black>Next steps</>:",
                    "  * Install the site: https://www.drupal.org/docs/8/install",
                    "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                    "  * Get support: https://www.drupal.org/support",
                    "  * Get involved with the Drupal community:",
                    "      https://www.drupal.org/getting-involved",
                    "  * Remove the plugin that prints this message:",
                    "      composer remove drupal/core-project-message"
                ]
            },
            "patches": {
                "drupal/color_field": {
                    "3309269 patch to get color_field working with php 7.4 v2": "patches/color_field-php74-compatibility-3309269-2.patch"
                },
                "drupal/fitvids": {
                    "3501317 patch for fix to use libs that exist, https://www.drupal.org/project/fitvids/issues/3501317#comment-15991650": "patches/fitvids-issue-3501317-comment-15991650-missing-fitbitjs-lib-patch-for-v210.patch"
                }
            }
        }
    }
    

    Note that I am working with a Drupal 9 core version of my site, but I would expect this patch to work for later versions.

    Here's a nice guide for creating patches: https://drupal.stackexchange.com/a/287849/1082

    Tip: I used BeyondCompare to copy across the changes before creating the patch.

Production build 0.71.5 2024