Difficult migration from Drupal 9 to 10

Created on 18 June 2023, about 1 year ago
Updated 19 July 2023, 12 months ago

Problem/Motivation

Captcha 1.2 supports Drupal 9.
Captcha 2.0 supports Drupal 10.

This means it is not possible to migrate D9-10 without a simultaneous upgrade of the Captcha module (unless you uninstall Captcha prior to upgrade, and reinstall after, which is not ideal).

Proposed resolution

Either release 1.3 with D10 compatibility, or add D9 compatibility to version 2.1. Please have at least one version that supports both major Drupal releases to allow a straightforward migration.

I can see the appeal of version 2.0 not being encumbered with Drupal 8/9 legacy code, but would it be possible to make minimal changes to 1.2 to support D10?

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

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

Comments & Activities

  • Issue created by @lostcarpark
  • 🇮🇪Ireland lostcarpark

    Please see this article from Matt Glaman recommending an overlap release:

    https://mglaman.dev/blog/drupal-module-semantic-versioning-drupal-core-s...

  • Status changed to Needs work about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks for the link @lostcarpark. I'm with you and happy to review a MR, if someone prepares and tests it.
    We already invested a lot of open source time (=money) into the module as a very small company, so this is a bonus community job.

    Upgrading works, like you described, but it's not that convenient, due to the technical incompatibilities.

    Thank you.

  • 🇮🇪Ireland lostcarpark

    It looks like most of the D10 fixes were merged into the 1.x branch, but it seems it wasn't complete, so D10 support was removed by 🐛 Image not shown, PHP error Closed: duplicate .

    I'll do some tinkering.

  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @lostcarpark indeed that was one of the upstream Symfony incompatibilities. There might be more, I'm unsure.

  • Finding the same, can 2.x not be made compatible with Drupal 9?

  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • 🇳🇱Netherlands JohanKleene Helmond

    Just tried suggestion #6. Seems to work without problems on 9.5.9.

  • 🇮🇪Ireland lostcarpark

    Is the reason 2.x doesn't support D9 because of Symfony 6 calls that aren't supported in Symfony 4, or because it uses PHP 8 syntax?

    If the latter, it would be possible for 2.x to specify a minimum PHP version of 8.1 for the module. Sites wishing to use it would have to upgrade the PHP version, but they'd need to do that anyway to be compatible with D10.

    If it needs Symfony 6, then perhaps @JohanKleene didn't happen to hit any of the functionality that hits calls unsupported in Symfony 4.

  • 🇲🇦Morocco b.khouy 🇲🇦 Morocco

    It would be better if we could commit the #7 patch as a prerelease for example 2.0-alpha, because the composer dependency error is triggered before the composer patches step was invoked.

  • 🇲🇦Morocco b.khouy 🇲🇦 Morocco

    I've created a temporarily alternative package to make module upgrade more easier and here are the steps to follow:

    1 - Remove existing drupal/captcha package: composer remove drupal/captcha

    2 - Require bkhouy/captcha package: composer require bkhouy/captcha:^2.0

    3 - Continue upgrading the rest of your project...

    4 - Once you finish the upgrade and your project is running on Drupal 10 version on production, then you need to rollback to drupal/captcha module by following those steps:

    => Remove bkhouy/captcha package: composer remove bkhouy/captcha
    => Require drupal/captcha package: composer require drupal/captcha:^2.0

  • Status changed to Needs work 12 months ago
  • 🇺🇸United States japerry KVUO

    Woah, sorry I haven't been getting notifications here -- I did NOT see what happened to captcha. But basically, this is a classic case for not following best practices for major versions:

    https://medium.com/jakob-on-drupal/dont-go-making-major-version-changes-...

    I'll see if we can prioritize fixing the 1.x and 2.x issues for Drupal 10. Acquia has an interest in making sure this module is compatible.

  • 🇩🇪Germany Anybody Porta Westfalica

    @japerry thanks for your feedback and support. We're very happy about experienced developers who'd like to help.
    But please ensure to stay friendly and keep in mind that each of us invested a lot of time here to push things forward as good as possible. Talk is cheap and it's easy to criticize each other. On the other hand, first please take a look at how long there was no progress in this module, lots of bugs and the codebase is ancient in large parts.

    If you have clever ideas how to fix things here, let's do it. But also let's appreciate each other's hard work. Nobody intentionally did bad things here, and if you take a deeper look at the reasons, you may see that. And of course we're willing to learn!

    PS: I'd be super grateful if Acquia helps with CAPTCHA again. We're just a small company and there's a lot of work of any category in this module to do.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • @japerry opened merge request.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.6
    last update 12 months ago
    2 pass, 18 fail
  • 🇺🇸United States japerry KVUO

    Yes, I apologize that we haven't been more involved. We're a small team, so we're not able to get to all the modules that I either co-maintain as fast as I'd like. That said, please reach out if you have questions regarding module compatibility, as this is probably the area we have the most expertise.

    That said -- there are some red flags here on the 1.x to 2.x changeover. First, while there was an incompatibility in the StreamedResponse classes, they aren't really written correctly in the first place. I've made a PR that moves most of that logic into the existing Render Service (which only had one static method.. huh).... and a callable StreamResponse instead of extending the Response classes. This will make Captcha compatible with Drupal 9.4+ and concievably 8.9, but I don't have tests for that, and its been long enough that I'm fine with upping the minimum version to 9.4 from 8.9. Interesting side effect, moving the extended Response into a service has found more deprecations, which are fixed in this PR as well.

    FWIW: There shouldn't have been a new version. 8.x-1.x would have been just fine. But that ship sailed... so instead, I'm suggesting we do what ctools does, which is get 2.x and 8.x-1.x to be the same codebase and make 8.x-1.x as supported, not recommended. This will allow 8.x-1.x and 2.x to support Drupal 9 and 10, with 8.x-1.x dropping support for Drupal 11. This will also allow modules that depend on captcha (8.x-1.x) time to upgrade to the 2.x branch in their composer files, allowing a more seamless upgrade to Drupal 10 and get captcha into a good spot when Drupal 11 comes out (which shouldn't require 3.x)

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 12 months ago
    4 pass, 16 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 12 months ago
    44 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • Status changed to Needs review 12 months ago
  • 🇺🇸United States japerry KVUO

    I have a working version for 1.x and 2.x users on Drupal 9 and 10. Some of the PHP8+ code has been reverted until enough time has passed for users to get off 7.4. I also added an upgrade hook for the move of modules in 8.x-1.x to 2.x. This works well and takes care of a hopefully rare case when someone has the test modules enabled (Drupal won't find them, but they shouldn't be installed anyway).

    While there might be some question about the PHP 8 reverts, specifically code related to #3075256: [2.x only] Error calling _captcha_insert_captcha_element -- the method validtion (array|null) isn't going to fix the underlying problem anyway, and just leads to incompatibility.

    With this last MR push, things should work correctly on both versions, resolving the need to maintain 8.x-1.x and 2.x separately.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 12 months ago
    44 pass
  • Status changed to RTBC 12 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @japerry for your clever fixes! I agree, we should have seen that it would have been possible to make 8.x-1.x Drupal 10 compatible that way. And I have to admit, that it was not really simple to get into the (partially) code that was from the early days of Drupal 8 or even Drupal 7 and before. Things like

    Render Service (which only had one static method.. huh)

    were from 2015 for example. So I still hope we made a lot of things better here and not worse with our maintainership.

    So thank you very very much for cleaning things up and helping here with your huge experience! :)

    What are the next steps? The MR is against 2.x, should we prepare the 8.x-1.x changes (as of #14) here as separate MR? Or what would you suggest?

    PS: Regarding the red flags and legacy code, also see the other issues and 🌱 [META] Plan for CAPTCHA 2.1.x release Active . There's surely a lot that can be improved in the CAPTCHA module, and I'm very much looking forward to doing that as a team. Once again, very happy to see more progress in this very widely used module.

    All tests pass, I don't see anything I'd suggest to change. Nice and RTBC from my side.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • 🇩🇪Germany Grevil

    @japerry thanks for your cleanup! Changes LGTM, I simply dropped the D8 compatibility (as it has reached its EOL). Apologies for the inconvenient module upgrade, but as @Anybody already said, we are a tiny team of 3 developers (me and @Anybody are the only ones active in Drupal issue queues) and we simply do not have the resources to refactor most of the legacy code inside CAPTCHA.

    Hence, we tried keeping the old code alive and building / adjusting on top of it. When it came to the Drupal 10 changes, we simply wanted to conform to the new Symfony method changes and couldn't think of a better idea, than dropping the support for older Drupal versions. Of course, stuff like 🐛 Image not shown, PHP error Closed: duplicate shouldn't slip through, but it occasionally does!

    But as already mentioned by @Anybody, we didn't change the StreamedResponse logic at all, we just made sure it worked with D10!
    See #3320867: [META][2.x] CAPTCHA 2.0.x release for a list of most changes we did here!

    Nevertheless, great to have you on board again @japerry! A seasoned Acquia developer is always appreciated! 🙂👍

    RTBC +1

  • 🇮🇪Ireland lostcarpark

    Thanks for the awesome work on this. It will make D10 migration a lot more straightforward.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update 12 months ago
    44 pass
    • japerry committed 76d740ec on 2.x
      Issue #3367503 by japerry, Grevil: Difficult migration from Drupal 9 to...
  • Status changed to Fixed 12 months ago
  • 🇺🇸United States japerry KVUO
  • Status changed to Needs work 12 months ago
  • 🇺🇸United States ChrisSnyder Maryland
  • 🇺🇸United States ChrisSnyder Maryland

    This related issue 💬 Problem after updating to 2.0.1 Closed: duplicate is possibly caused by this issue.

  • Status changed to Fixed 12 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Setting this fixed again, let's please proceed in 🐛 captcha_update_8906 hook updating core.extension.yml incorrectly Fixed

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

Production build 0.69.0 2024