-1

I am trying to apply patch to the core file but none solution work for me. even not able commit core file changes due composer restriction

composer.json

{
"name": "pantheon-upstreams/drupal-project",
"description": "Install Drupal 9 with Composer on Pantheon.",
"type": "project",
"license": "MIT",
"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    },
    {
        "type": "path",
        "url": "upstream-configuration"
    },
    {
        "type": "package",
        "package": {
            "name": "woocommerce/flexslider",
            "version": "2.7.2",
            "type": "drupal-library",
            "source": {
                "url": "https://github.com/woocommerce/FlexSlider.git",
                "type": "git",
                "reference": "2.7.2"
            }
        }
    },
    {
  "type": "package",
  "package": {
    "name": "jsor/jcarousel",
    "version": "0.3.8",
    "type": "drupal-library",
    "dist": {
      "url": "https://github.com/jsor/jcarousel/archive/0.3.8.zip",
      "type": "zip"
    }
  }
},
{
  "type": "package",
  "package": {
    "name": "snake-345/jcarouselswipe",
    "version": "0.3.7",
    "type": "drupal-library",
    "dist": {
      "url": "https://github.com/snake-345/jcarouselswipe/archive/0.3.7.zip",
      "type": "zip"
    }
  }
}
],
"require": {
    "bower-asset/bootstrap": "^3.3",
    "bower-asset/jquery-simple-color": "^1.2",
    "bower-asset/spectrum": "^1.8",
    "composer/installers": "^1.9",
    "cweagans/composer-patches": "^1.7",
    "drupal/address": "^1.11",
    "drupal/admin_toolbar": "^3.1",
    "drupal/aos-aos": "^1.0",
    "drupal/better_exposed_filters": "^5.2",
    "drupal/better_search": "^1.6",
    "drupal/better_social_sharing_buttons": "^4.0",
    "drupal/bootstrap_barrio": "^5.5",
    "drupal/captcha": "^1.4",
    "drupal/color_field": "^3.0",
    "drupal/core-composer-scaffold": "^9.2",
    "drupal/core-recommended": "^9.2",
    "drupal/csv_serialization": "^2.1",
    "drupal/ctools": "^3.4",
    "drupal/devel_entity_updates": "^3.0",
    "drupal/diff": "^1.0",
    "drupal/disable_link_rel": "^2.0",
    "drupal/embed": "^1.6",
    "drupal/entity": "^1.4",
    "drupal/entity_browser": "^2.8",
    "drupal/entity_embed": "^1.2",
    "drupal/entity_reference_revisions": "^1.10",
    "drupal/extlink": "^1.6",
    "drupal/field_group": "^3.2",
    "drupal/field_permissions": "^1.2",
    "drupal/file_mdm": "^2.4",
    "drupal/flexslider": "^2.0",
    "drupal/fontawesome": "^2.23",
    "drupal/fontawesome_menu_icons": "^1.9",
    "drupal/googlemap_block": "2.x-dev@dev",
    "drupal/gtranslate": "^1.14",
    "drupal/hacked": "^2.0@beta",
    "drupal/header_and_footer_scripts": "^3.0",
    "drupal/honeypot": "^2.1",
    "drupal/hubspot": "^1.0@alpha",
    "drupal/inline_entity_form": "^1.0@RC",
    "drupal/jcarousel": "^6.0@alpha",
    "drupal/jquery_carousel": "^1.0",
    "drupal/lazy": "^3.11",
    "drupal/link_attributes": "^1.11",
    "drupal/menu_block": "^1.8",
    "drupal/menu_link_attributes": "^1.2",
    "drupal/metatag": "^1.21",
    "drupal/nofollowlist": "^2.0",
    "drupal/page_manager": "^4.0@beta",
    "drupal/paragraphs": "^1.15",
    "drupal/pathauto": "^1.11",
    "drupal/profile": "^1.4",
    "drupal/quick_node_clone": "^1.15",
    "drupal/recaptcha": "^3.0",
    "drupal/redirect": "^1.8",
    "drupal/redis": "^1.5",
    "drupal/responsive_menu": "^4.4",
    "drupal/schema_metatag": "^2.3",
    "drupal/search_api": "^1.28",
    "drupal/search_exclude_nid": "^2.0@alpha",
    "drupal/sophron": "^1.2",
    "drupal/state_machine": "^1.6",
    "drupal/token": "^1.7",
    "drupal/twig_tweak": "^3.1",
    "drupal/typed_data": "^1.0@beta",
    "drupal/views_autocomplete_filters": "^1.3",
    "drupal/views_autosubmit": "^1.4",
    "drupal/views_blogspot_archive": "^1.4",
    "drupal/views_conditional": "^1.5",
    "drupal/views_data_export": "^1.1",
    "drupal/views_infinite_scroll": "^2.0",
    "drupal/views_slideshow": "^4.8",
    "drupal/we_megamenu": "^1.13",
    "drupal/webform": "^6.1",
    "drupal/webform_spam_words": "^2.0",
    "drupal/youtube": "^2.0",
    "drush/drush": "^10",
    "jsor/jcarousel": "^0.3.8",
    "npm-asset/jquery": "^2.2",
    "oomphinc/composer-installers-extender": "^2.0",
    "pantheon-systems/drupal-integrations": "^9",
    "pantheon-upstreams/upstream-configuration": "self.version",
    "snake-345/jcarouselswipe": "^0.3.7",
    "wikimedia/composer-merge-plugin": "^2.0",
    "woocommerce/flexslider": "~2.0"
},
"require-dev": {
    "drupal/core-dev": "^9.2"
},
"conflict": {
    "drupal/drupal": "*"
},
"minimum-stability": "stable",
"prefer-stable": true,
"extra": {
    "drupal-scaffold": {
        "locations": {
            "web-root": "./web"
        },
        "allowed-packages": [
            "pantheon-systems/drupal-integrations"
        ],
        "file-mapping": {
            "[project-root]/.editorconfig": false,
            "[project-root]/pantheon.upstream.yml": false,
            "[project-root]/.gitattributes": false
        }
    },
    "installer-types": [
       "npm-asset",
       "bower-asset"
    ],
    "installer-paths": {
        "web/core": [
            "type:drupal-core"
        ],
        "web/libraries/{$name}": [
            "type:bower-asset",
            "type:npm-asset",
            "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"
        ],
        "web/private/scripts/quicksilver/{$name}/": [
            "type:quicksilver-script"
        ]
    },
    "composer-exit-on-patch-failure": true,
    "patchLevel": {
        "drupal/core": "-p2"
    },
    "merge-plugin": {
        "include": [
            "web/modules/contrib/webform/composer.libraries.json"
        ]
    }
},
"enable-patching": true,
"composer-exit-on-patch-failure": true,
"patches": {
     "drupal/core": {
        "Public files directory Not fully protected": "https://www.drupal.org/files/issues/2020-03-04/3117665-non_apache_servers_4.patch",
        "Illegal offset type in isset or empty core": "https://www.drupal.org/files/issues/2023-01-25/taxonomies-view-filter-core-fixes.patch",
        "view filter working core": "https://www.drupal.org/files/issues/2023-01-25/date-view-filter-core_0.patch"                       
      }
     },
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "platform": {
        "php": "7.4"
    },
    "allow-plugins": {
        "composer/installers": true,
        "cweagans/composer-patches": true,
        "drupal/core-composer-scaffold": true,
        "dealerdirect/phpcodesniffer-composer-installer": true,
        "wikimedia/composer-merge-plugin": true,
        "oomphinc/composer-installers-extender": true
    }
}
}

.gitignore

# This file contains .gitignore rules that are often used with Drupal projects.
# Because .gitignore is specific to your site and its deployment processes, you
# may need to uncomment, add, or remove rules.

# Pantheon commits a settings.php for environment-specific settings.
# Place local settings in settings.local.php
/web/sites/*/settings.local.php
/web/sites/*/services*.yml
!/web/sites/*/services.pantheon.*.yml
!/web/sites/*/services.yml

# Ignore paths that contain user-generated content.
/web/sites/*/files
/web/sites/*/private

# Ignore SimpleTest multi-site environment.
/web/sites/simpletest


# Ignore custom modules managed by Composer.
#
# When a development team creates one or more custom modules that
# are intended for use on more than one site, the typical strategy
# is to register them in Packagist and give them the type
# `drupal-custom-module` instead of `drupal-module`. This will cause
# Composer to install them to the directory `modules/custom`.
# This will cause a build error on Pantheon unless this location
# is .gitignore'd as shown below.
#
# An alternate strategy for custom modules is to commit them
# directly to the repository of the site where they are used. This
# is commonly done with modules that are specific to just one site.
# 
# Sites that have both Composer-managed custom modules and custom
# modules that are committed directly to the repository may ignore
# the `modules/custom` directory with the first rule shown below,
# and then allow the locations to be committed on a case-by-case
# basis by re-adding paths using `!` rules. A path that begins with
# a `!` will allow a previously-ignored path to be added to the
# repository. Note, however, that a path cannot be re-added if any
# of its parent directories are excluded. This is why we use the
# rule `/modules/custom/*` instead of `/modules/custom`. Alternately,
 # you might instead commit Git-tracked custom modules to some other
# path, such as /web/modules/<site-namespace>.
#
 # Sites that do not have any Composer-managed custom modules do
# not need to use any of the `modules/custom` rules below.
# ------------------------------------------------------------------
#/web/modules/custom/*
#!/web/modules/custom/module_in_repo


# Ignore directories generated by Composer
#
# See the "installer-paths" section in the top-level composer.json
# file.
# ------------------------------------------------------------------
/drush/Commands/contrib/
!/web/core/modules/web/views/src/Plugin/views/filter/Date.php
!/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
 /web/libraries/
/web/private/scripts/quicksilver
/web/themes/contrib/bootstrap_barrio/css/components/forum.css
/web/themes/contrib/bootstrap_barrio/css/components/image-widget.css
!/web/libraries/flexslider
!/web/core/modules/web/views/src/Plugin/views/filter/Date.php
!/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php


# Generally you should only ignore the root vendor directory. It's important
# that core/assets/vendor and any other vendor directories within contrib or
# custom module, theme, etc., are not ignored unless you purposely do so.
/vendor/

# Ignore other scaffold files
#
# Ignore all files placed directly at the project root. Rely on
# .gitignore files placed by drupal/core-composer-scaffold to avoid
# build errors that arise if non-ignored files are scaffolded.
# ------------------------------------------------------------------
/.editorconfig
/.gitattributes

# The pantheon-systems/drupal-integrations project places a
# .drush-lock-update file at the project root.
/.drush-lock-update

# The drupal/core-composer-scaffold component will write .gitignore
# files to other locations where it scaffolds files that are not
# already ignored. We must also ignore these generated files.
/web/**/.gitignore


# Other common rules
# ------------------
# Ignore files generated by PhpStorm
#/.idea/

# Ignore .env files as they are personal
#/.env

1 Answer 1

3

patches needs to be placed inside the extra section (on the same level as patchLevel, installer-types, etc.), not on the root level.

{
    "name": "pantheon-upstreams/drupal-project",
    ...(trimmed)...
    "extra": {
         ...(trimmed)...
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": {
            "drupal/core": {
                "Public files directory Not fully protected": "https://www.drupal.org/files/issues/2020-03-04/3117665-non_apache_servers_4.patch",
                "Illegal offset type in isset or empty core": "https://www.drupal.org/files/issues/2023-01-25/taxonomies-view-filter-core-fixes.patch",
                "view filter working core": "https://www.drupal.org/files/issues/2023-01-25/date-view-filter-core_0.patch"                       
            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.