Problem/Motivation
More projects will be moved to Drupal 10 moving forward so it would be good if the module could be updated accordingly.
Steps to reproduce
Check the module status using upgrade-status - this shows that the module is not compatible with Drupal 10 yet.
Proposed resolution
Update the module code and yml files to support Drupal 10.
Drupal Upgrade Status return
| File name | Line | Error |
|---|---|---|
| modules/contrib/commerce_cart_flyout/src/Plugin/Block/CartBlock.php | 128 | Call to deprecated function drupal_get_path(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use Drupal\Core\Extension\ExtensionPathResolver::getPath() instead. |
| modules/contrib/commerce_cart_flyout/src/Plugin/Block/CartBlock.php | 128 | Call to deprecated function file_create_url(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the appropriate method on \Drupal\Core\File\FileUrlGeneratorInterface instead. |
| modules/contrib/commerce_cart_flyout/src/Plugin/Block/CartBlock.php | 128 | Call to deprecated function file_url_transform_relative(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use Drupal\Core\File\FileUrlGenerator::transformRelative() instead. |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'flyout' library is depending on a deprecated library. The core/jquery.once asset library is deprecated in Drupal 9.3.0 and will be removed in Drupal 10.0.0. Use the core/once library instead. See https://www.drupal.org/node/3158256 |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'flyout' library is depending on a deprecated library. The core/backbone asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'flyout' library is depending on a deprecated library. The core/underscore asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'add_to_cart' library is depending on a deprecated library. The core/jquery.once asset library is deprecated in Drupal 9.3.0 and will be removed in Drupal 10.0.0. Use the core/once library instead. See https://www.drupal.org/node/3158256 |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'add_to_cart' library is depending on a deprecated library. The core/backbone asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.libraries.yml | 0 | The 'add_to_cart' library is depending on a deprecated library. The core/underscore asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. |
| modules/contrib/commerce_cart_flyout/commerce_cart_flyout.info.yml | 0 | Value of core_version_requirement: ^8 || ^9 is not compatible with the next major version of Drupal core. See https://drupal.org/node/3070687. |
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | commerce_cart_flyout-3359110.patch | 8.02 KB | sarwan_verma |
| #15 | Drupal10-support.png | 22.19 KB | sarwan_verma |
| #3 | d10_support-3359110.patch | 2.05 KB | pedro franco |
Issue fork commerce_cart_flyout-3359110
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gisleRemoved tag that should only be used for issues created by the update bot.
Comment #3
pedro franco commentedComment #6
valicOpened MR, added additional changes on top of patch from #3 - mostly removal of jQuery once in favor of core once implementation
Comment #7
anybodyDrupal 9 EOL is close and this is used on > 1.000 projects.
Comment #8
pedro franco commentedCan someone please review the PR opened by valic?
Comment #9
grevil commentedSure thing!
Comment #10
grevil commentedComment #11
grevil commented"getPath()" already returns a relative path as a string:
Comment #12
grevil commentedDrupal < 9.5 has reached its EOL.
Comment #13
grevil commentedNotes on using "internal.backbone":
Same with "internal.underscore":
Comment #14
grevil commented"once" calls have "find" already integrated in their specification, see https://www.drupal.org/node/3158256. Furthermore, it was possible to drop the jquery dependency for the "add-to-cart" library.
Comment #15
sarwan_verma commentedHey all,
I have update the module to be worked with drupal 10 & created the patch also.
Please review & let me know if any other issues.
Comment #16
grevil commentedConcerning #13, here is a pretty good guide on removing "underscore" with vanilla js: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore. And removing backbone shouldn't be too hard.
Comment #17
grevil commentedAs Drupal 10 also introduces native es6, see https://www.drupal.org/node/3305487, I suggest removing the old non es6 files and replacing them with the es6 files.
A new SemVer branch is adviced.
Comment #18
grevil commentedJust discussed #13 internally with @Anybody, and it probably makes sense to depend on the internal library for now and create a major follow-up issue removing the deprecated backbone and underscore dependencies.
Comment #19
grevil commentedThe "commerce_cart_api" module, this module depends on, is not yet Drupal 10 ready.
POSTPONED on #3332548: Drupal 10 update.
Comment #20
grevil commentedComment #21
grevil commentedSeems to work as expected, we now only need to wait for the parent issue to resolve.
Comment #22
anybodyLet's review this now, so we can push this forward asap!
Comment #23
anybodyThanks @Grevil, great work! All reviewed and LGTM!
Now let's hope the parent task also gets resolved and add a major follow-up to replace the internal libraries!
(Perhaps AI can help to do that?)
@Maintainers: Please update credits!
Comment #24
grevil commentedI don't think @mglaman wants this to not be backwards compatible, so we should give it a similar treatment like in #3332548: Drupal 10 update.
Comment #25
rajab natshahComment #27
jon pollard commentedAdding in the fork, I am getting an empty div instead of my cart block
<div class="cart-flyout" data-once="cart-block-render"></div>Am I missing a library somewhere perhaps?
Comment #28
neograph734I am experiencing the same, although this used to work earlier. Still trying to figure it out.
Comment #29
neograph734I am afraid that somewhere in Grevils changes the js has gotten corrupted.
When I patch with the first commit made in the merge request, my cart block works as expected.
You can use this patch link for composer patches: https://git.drupalcode.org/project/commerce_cart_flyout/-/commit/9cca30d...
Since the last commit from AlexBukach is not in there, you will have to use the patch from #3364476: after upgrading to Commerce Core 8.x-2.36 this module doesn't work which fixes the same thing. (That is what I did.) You could probably isolate the last commit from this MR in a similar fashion as I isolated the first commit too.
Edit, this is the patch of the last commit:
https://git.drupalcode.org/project/commerce_cart_flyout/-/commit/2d1f81e...
Comment #30
neograph734Adding related issue with overlapping patch.
Comment #31
jon pollard commentedHaving previously got this working on one site, I now can't get it to work on another. It would be really great to get these changes bundled up into a release.
Comment #33
elc commentedComment #34
neograph734Thanks ELC, I believe the block is showing again.
Leaving at NR because of #24.
Comment #35
elc commentedBackwards compatibility is actually pretty much out the window right now. Despite the current info.yml claim of ^9.5 || ^10, this fork should be a hard ^10, and given the cut-off, a new Semantic Version based branch/release should be made.
This does really seem to be more a browser thing than a drupal core restriction.
"drupal/core": "^9.3 || ^10"Might have to separate out only was is absolutely necessary for D10 compat into 8.x-1.x branch, and then make a 2.0.x branch for the version with the hard breaking changes.
Backing out the es6 change, min version can be core:9.3.0. Not actually sure were the min version 9.5 has come from.
How backware compatible does it need to be given the issues?
Comment #36
svendecabooter@ELC I haven't looked at the all the code / progress, but what does the dropping of backwards compatibility imply?
Is it just that the module will not be able to work on both D9 and D10 simultaneously?
Or is it that there will be no upgrade path when upgrading from D9 to D10?
If it's only the first, I would opt for a D10-only branch (2.x?) and not worry about any D8 / D9 backwards compatibility there.
D8 and D9 are no longer supported, and they already have a working 8.x-1.9 release, so websites staying on those Drupal core versions can stay with that release. But I think the majority of sites will upgrade to D10, and thus to the 2.x branch of this module.
This module is currently the only remaining blocker for one of our sites, so I'd like to assess when we will be able to unblock this.
Comment #37
svendecabooterThe https://www.drupal.org/project/commerce_cart_api module now has a D10 release, so that's no longer a blocking factor in getting this module to D10 I reckon?
Comment #38
elc commentedI probably should have set this to NR as it needs @mglaman or another maintainer to decide the path to choose.
It boils down to 1 release branch or two. I think it should be done as 2 releases for ease of upgrading:
Any older sites then have a progression to the fully supported version.
Choosing the path to a single release branch means jumping straight to D10 only. Or just leaving the es6 compiling in until its use is removed which would allow D9.3/D10.
A new release branch will be needed at some point as the Block Annotation will be changed to an Attribute in D10.2 which is again a hard cut-off to previous versions. Again which could be delayed until D11 although there will be a deprecation notice. @see #3252386: Use PHP attributes instead of doctrine annotations
Comment #39
mglamanCan someone explain why we had to change the files from es6 extension? We should just fix usage of `once` in the JavaScript. This makes it easier to review.
We should be able to do a minor release and support D10 with minimum changes.
Also, the event subscriber could use a decorator and setter pattern to avoid constructor breaks. But that can be a different issue.
Comment #40
nmillin commented@mglaman, it looks like sarwan_verma did that back in comment 15 - https://www.drupal.org/files/issues/2023-09-28/commerce_cart_flyout-3359...
I was able to use the patch with https://github.com/mglaman/composer-drupal-lenient (wish I found this project earlier...). I'm kicking the tires of commerce (no live site yet), but things work.
@mglaman can you review if this is the correct direction, and then maybe someone with more commerce experience than I can polish the patch (if needed). Thanks!
Comment #42
rwanthI made a new branch, 3359110-d10-minimal-change, that combines @sarwan_verma's work from #15 and @AlexBukach's from #26. This working for me on both D9 and D10.
Comment #43
mglamanThanks @rwanth I'll find some time to review. I appreciate it!
Comment #45
mglamanThis looks great, thank you! https://git.drupalcode.org/project/commerce_cart_flyout/-/merge_requests/13
Comment #46
alfthecat commentedWorks great on my side, just on /admin/reports/updates it shows as "Not compatible".
Comment #47
anybody@mglaman any plans for a release? Currently there's no more D10 compatible release visible on the project page!
Comment #48
mttsmmrssprks commentedApologies for the repeated question here but are there plans for a release of a D10-compatable version of this module? We'd like to implement this on a D10 site.
Thank you for your work on upgrading this so far.
Comment #49
mglamanTaking a look and landing this
Comment #50
mglamanUpdating credit. Thanks, everyone. Added GitLab CI in another issue. Waiting to see those results (no tests, but PHPStan will run.)
Comment #53
mglamanThank you, everyone, and for your patience! Cutting a release shortly.
Comment #54
mglaman