Drupal 10 compatibility fixes

Created on 9 August 2022, over 2 years ago
Updated 21 February 2023, almost 2 years ago

Problem/Motivation

Getting the following error after setting bootstrap Administration theme in d10.

error:

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\Core\Theme\Registry::__construct(): Argument #7 ($runtime_cache) must be of type Drupal\Core\Cache\CacheBackendInterface, string given, called in /var/www/html/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeRegistry.php on line 51 in Drupal\Core\Theme\Registry->__construct() (line 184 of core/lib/Drupal/Core/Theme/Registry.php).

After solving which, the following error appears:

Fatal error: Declaration of Drupal\bootstrap\SerializedResponse::getContent() must be compatible with Symfony\Component\HttpFoundation\Response::getContent(): string|false in /var/www/html/web/themes/contrib/bootstrap/src/SerializedResponse.php on line 163

Steps to reproduce

1. Install theme
2. Make this theme as Administration theme.

Drupal Version : 10.0.0-alpha7
Php version: 8.1.8

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇮🇳India omkar-pd

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States benjaminarthurt Syracuse, NY

    #26 works against the current Drupal 10.0.2 w/ php 8.2.1 Now that D10 is no longer a beta release it would be great to get this into patch committed.

  • 🇺🇸United States hockey2112

    #26 worked for me, thanks!

  • 🇬🇧United Kingdom 2dareis2do

    Thank you Heddn

  • 🇺🇸United States Chris Matthews

    Any chance the patch in #26 🐛 Drupal 10 compatibility fixes Fixed could at least be committed to 8.x-3.x-dev ?

  • 🇪🇸Spain dromansab

    Hello,

    I have found another compatibility related with the deprecated use of jquery.once in Drupal 10. I have created another issue https://www.drupal.org/project/bootstrap/issues/3336901 🐛 Uncaught TypeError: $(...).once is not a function with Drupal 10 Closed: duplicate

  • Status changed to Needs work almost 2 years ago
  • 🇵🇹Portugal jcnventura

    Thanks for that @dromansab. I think we need to handle the transition to core/once on this issue and mark 🐛 Uncaught TypeError: $(...).once is not a function with Drupal 10 Closed: duplicate as a duplicate.

    There's no real D10 support while the theme continues to use jquery.once.

  • 🇺🇸United States shelane

    Indeed. This is where I could use some community help with converting that code.

  • 🇨🇦Canada TrevorBradley

    Is it possible that a fix can happen against the 3.x branch? If not - shouldn't 3.x have D10 compatibility removed so it correctly shows as incompatible (and this task get bumped to the 4.x branch)?

    Any thoughts about bumping this to Major priority?

    I wish I knew enough about the Bootstrap/JS side to help here. I don't think I can upgrade by Bootstrap sites to D10 until this is resolved.

  • 🇨🇦Canada TrevorBradley

    OK, I make NO guarantees here, but this is my first pass at revising the jquery .once() as per the instructions as described in https://www.drupal.org/node/3158256

    Attached is the jquery patch against the latest 8.x-3.x dev branch, and also a revised patch that includes @heddn's patch from #26

    I expect this to be broken, do NOT deploy this to production sites, but hopefully this pushes the issue forward.

  • Status changed to Needs review almost 2 years ago
  • 🇺🇸United States Gorf

    Sorry, just getting lost a little in the back and forth. I've got the Response::getContent(): error in a brand new deployment of D10 with Bootstrap 3.26 on PHP 8.1.14. I get the error trying to access the Settings of the theme once it's installed via Composer. Is the correct patch to test here just 3302607-39.patch? Or do I need to do the bootstrap_jquery_once.patch as well? I'd like to roll this out and test it since I've got everything in a new running state.

  • 🇨🇦Canada TrevorBradley

    @geoffrsweet - just to clarify:

    3302607-26.patch tried to fix issues with the composer install. However, people were also saying jquery.once is no longer supported, and will also be a D10 blocker.

    I created bootstrap_jquery_once.patch as a first draft to updating jquery.once(), but it doesn't include the fixes in 3302607-26.patch.

    3302607-39.patch contains both heddn's 3302607-26.patch and my jquery.once fix.

    If you're talking about the bootstrap settings page at /admin/appearance/settings/bootstrap - I can access this page without error with the 3302607-39.patch patch.

  • 🇧🇾Belarus f1mishutka Minsk

    3302607-39.patch worked for me, Drupal 10.0.3.

    Thank you!

  • 🇺🇸United States Gorf

    I think I am dumb here but I removed the stable version of bootstrap and replaced it with the dev branch. Then reran my patch and I'm still getting file not found errors:

    :$ patch --dry-run -ruN -d bootstrap < 3302607-39.patch
    checking file bootstrap.info.yml
    checking file composer.json
    can't find file to patch at input line 29
    Perhaps you should have used the -p or --strip option?
    The text leading up to this was:
    --------------------------
    |diff --git a/js/misc/batch.js b/js/misc/batch.js
    |index a424305..70af6c6 100644
    |--- a/js/misc/batch.js
    |+++ b/js/misc/batch.js
    --------------------------
    File to patch:
    Skip this patch? [y] q
    Skipping patch.
    3 out of 3 hunks ignored
    can't find file to patch at input line 57
    Perhaps you should have used the -p or --strip option?
    The text leading up to this was:
    --------------------------
    |diff --git a/js/misc/form.js b/js/misc/form.js
    |index 0b09d16..9712243 100644
    |--- a/js/misc/form.js
    |+++ b/js/misc/form.js
    --------------------------
    File to patch:

    I'm in /themes/contrib/ which is where composer installs bootstrap.

  • 🇨🇦Canada TrevorBradley

    @geoffrsweet: Most of us are using composer. Maybe I'm not applying patches the way you do. This is working for me:

    $ git clone --branch '8.x-3.x' https://git.drupalcode.org/project/bootstrap.git
    $ cd bootstrap
    $ patch -p1 < ../3302607-39.patch
    patching file bootstrap.info.yml
    patching file composer.json
    patching file js/misc/batch.js
    patching file js/misc/form.js
    patching file js/misc/vertical-tabs.js
    patching file js/modules/filter/filter.js
    patching file js/text/text.js
    patching file js/theme-settings.js
    patching file src/Bootstrap.php
    patching file src/Plugin/Alter/ThemeRegistry.php
    patching file src/Plugin/Provider/ProviderBase.php
    patching file src/SerializedResponse.php

    I managed to get

    patch --dry-run -p1 -d bootstrap < 3302607-39.patch

    to work. Not sure what -ruN does - the documentation explicitly says to use the p1 parameter .

  • 🇳🇱Netherlands Summit

    Hi, #45 worked for me. Thanks Trevor!, but off course when I do Composer Update, I have to add patch again. So please commit. Thanks!

  • 🇨🇦Canada TrevorBradley

    @Summit - you can add patches to composer.json so that it applies the patch every time you run composer install or composer update. It's super convenient. Instructions here.

  • 🇺🇸United States Gorf

    Oh good grief. I'm an idiot. Yes ok, correcting the command works fine and the patch solves this for me. Also thanks for the instructions on patching. I've made those updates too.

  • Status changed to Fixed almost 2 years ago
  • 🇺🇸United States shelane

    I did two separate commits to separate the credit listings for the jQuery once and the other D10 issues. I've also updated the minimum version to be 9.5 (which I believe also requires php 8.1). I'm currently checking to see if there are any other issues that need to be included in a release. Most likely release will be on Tues, Feb 21.

  • 🇮🇳India sourav_paul Kolkata

    Thanks! @TrevorBradley
    (#39) 3302607-39.patch works for me...

  • 🇨🇦Canada TrevorBradley

    @Sourav_Paul: There's plenty of examples over at [#3158256] : https://www.drupal.org/node/3158256

    The "More code change examples" talks about an alternate way to do once():

    $(once('tableresponsive', 'table', context)).find(...
    $(once('tableresponsive', 'table', context)).prepend(...
    $(once('tableresponsive', 'table', context)).each(...

    Should all work in theory.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024