Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 10.

To read more about this effort by the Drupal Association, please read: The project update bot is being refreshed to support Drupal 10 readiness of contributed projects

Patches will periodically be added to this issue that remove Drupal 10 deprecated API uses. To stop further patches from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD10" tag from the issue to stop the bot from posting updates.

The patches will be posted by the Project Update Bot official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated patches until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD10" tag is left on this issue, new patches will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the patches posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot patches. The bot will still post new patches then if there is a change in the new generated patch compared to the patch that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated patches.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated patches, remove the "ProjectUpdateBotD10" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated patches again, add back the "ProjectUpdateBotD10" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated patches will be posted here.

    If the issue is reopened, then new automated patches will be posted.

    If you are using another issue(s) to work on Drupal 10 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Providing feedback

If there are problems with one of the patches posted by the Project Update Bot, such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue. For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue.

Issue fork genpass-3287722

Command icon 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

Project Update Bot created an issue. See original summary.

project update bot’s picture

Status: Active » Needs review
StatusFileSize
new390 bytes

This is an automated patch generated by Drupal Rector. Please see the issue summary for more details.

It is important that any automated tests available are run with this patch and that you manually test this patch.

Drupal 10 Compatibility

According to the Upgrade Status module this patch makes this module compatible with Drupal 10! 🎉
This patch updates the info.yml file for Drupal 10 compatibility.

Leaving this issue open, even after committing the current patch, will allow the Project Update Bot to post additional Drupal 10 compatibility fixes as they become available in Drupal Rector.

Debug info

Bot run #127

This patch was created using these packages:

  1. mglaman/phpstan-drupal: 1.1.9
  2. palantirnet/drupal-rector: 0.12.0
project update bot’s picture

Issue summary: View changes
prudloff’s picture

Issue summary: View changes
StatusFileSize
new1.19 KB

ModuleHandlerInterface::getImplementations() is deprecated and Drupal 10 provides no easy way to get a list of modules implementing a hook: https://www.drupal.org/node/3000490
This patch adds an hard-coded list for people that need to use this module on Drupal 10 and don't need other implementations, but we should find a new way to implement this.

yashingole’s picture

StatusFileSize
new421.31 KB
new26.11 KB

I have reviewed and checked Patch #4 this works for drupal 9.5 and drupal 10.0. and 10.0.1
Screenshots of the compatibility on 9.5 and Config page on 10 have been attached for reference:

anybody’s picture

Status: Needs review » Needs work

Drupal 10 is close so this is important.

But the patch introduces a new @todo and
core_version_requirement: ^8 || ^9 || ^10
is incorrect!

Must be
core_version_requirement: ^8.7.7 || ^9 || ^10
or
core_version_requirement: ^8.9 || ^9 || ^10

And please use merge-requests.

hardikpandya made their first commit to this issue’s fork.

hardikpandya’s picture

Status: Needs work » Needs review
rajab natshah’s picture

Priority: Normal » Major
rajab natshah’s picture

Thank you for maintaining the Generate Password module.
Hoping for a soft commit and a soft tag release. To ease testing with Drupal 10
Testing now with git clone git@git.drupal.org:project/genpass.git


Had Real physical testing round for Generate Password with Drupal ~10

composer create-project drupal/recommended-project:~10 /var/www/html/sandboxes/drupal10genpass__test
cd /var/www/html/sandboxes/drupal10genpass__test/
composer require drush/drush:~11.0;

cd /var/www/html/sandboxes/drupal10genpass__test/web/modules
git clone git@git.drupal.org:project/genpass.git
cd genpass/
git fetch origin
git checkout 8.x-1.x

Get the patch and apply it under Drupal 10 site. ( to be able to enable )

wget https://www.drupal.org/files/issues/2022-11-28/genpass-3287722-4.patch
git apply genpass-3287722-4.patch
rm genpass-3287722-4.patch

Change file/directory mod and ownership of files:

cd /var/www/html/sandboxes/drupal10genpass__test/
sudo chmod 775 -R .;sudo chown www-data:$USER -R .;

Install with Drush

./vendor/drush/drush/drush site:install standard --yes --site-name="Generate Password - Real physical testing with Drupal ~10" --account-name="webmaster" --account-pass="d" --account-mail="test@drupal.org" --db-url="mysql://root:123___@localhost/sandboxes_drupal10genpass__test" -vvv ;
./vendor/drush/drush/drush pm:enable genpass
[success] Successfully enabled: genpass

Rebuild the cache:

sudo chmod 775 -R .;sudo chown www-data:$USER -R .;
./vendor/drush/drush/drush cache:rebuild

Open a browser and change the address to:
http://localhost/sandboxes/drupal10genpass__test/web/

After a login with the webmaster test user
When creating a new testing user test.genpass for example
After saving the new user the following message will show up

Status message
Since you did not provide a password, it was generated automatically for this account.
Created a new user account for test.genpass. No email has been sent.

Add user when Generate Password is enabled in Drupal 10

Since you did not provide a password, it was generated automatically for this account.

greggles’s picture

Status: Reviewed & tested by the community » Needs work

There's some unresolved feedback on the merge request from Anybody so moving this back to Needs Work.

The default works, but custom password implementations will not work as expected.

rajab natshah’s picture

Priority: Major » Critical
greggles’s picture

This is still "needs work."

rajab natshah’s picture

Got that Greg, Thanks for having time to follow up on this issue.
Important notes from #12

Noticed Pierre's notes about

modules/contrib/genpass/genpass.module:
┌────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │                           MESSAGE                            │
├────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix    │ 323  │ Call to deprecated method getImplementations() of class      │
│ later  │      │ Drupal\Core\Extension\ModuleHandlerInterface. Deprecated in  │
│        │      │ drupal:9.4.0 and is removed from drupal:10.0.0. Instead you  │
│        │      │ should use ModuleHandlerInterface::invokeAllWith() for hook  │
│        │      │ invocations or you should use                                │
│        │      │ ModuleHandlerInterface::hasImplementations() to determine if │
│        │      │ hooks implementations exist.                                 │
│        │      │                                                              │
└────────┴──────┴──────────────────────────────────────────────────────────────┘
rajab natshah’s picture

Oh the last code was a static return!

Researched a bit on what other modules are doing in this case
https://git.drupalcode.org/project/scheduler/-/commit/1bb684d#66fb3c85a3...

Got the point.
Testing custom module with a hook_password to be listed in the return of the genpass_algorithm_modules function.

/**
 * Return an array of all modules which implement hook_password.
 */
function genpass_algorithm_modules() {
  // Fetch a list of all modules which implement the password generation hook.
  // To be in this list, a module must implement a hook, and return random
  // passwords as strings.

  $return = [];
  \Drupal::moduleHandler()->invokeAllWith('password', function (callable $hook, string $module) use (&$return) {
    $return[$module] = $module;
  });
  return $return;
}

Not sure if I have a push access over the issue fork.
Hoping for Pierre to commit his suggested change.

It could be that invokeAllWith will invoke the functions.
To my understanding. In our case we only want to list not to invoke others.

rajab natshah’s picture

All hook invocation delegated to Module Handler service
#2616814: Delegate all hook invocations to ModuleHandler

https://git.drupalcode.org/project/drupal/-/commit/8f1c7a8#9a1c5d1dd1901...

Use ModuleHandlerInterface::hasImplementations() to determine if hooks implementations exist.

Suggesting to change to use has Implementations:

/**
 * Return an array of all modules which implement hook_password.
 */
function genpass_algorithm_modules() {
  // Fetch a list of all modules which implement the password generation hook.
  // To be in this list, a module must implement a hook, and return random
  // passwords as strings.

  $all_modules = \Drupal::moduleHandler()->getModuleList();
  $return = [];
  foreach ($all_modules as $module_name => $module) {
    if (\Drupal::moduleHandler()->hasImplementations('password', $module_name)) {
      $return[$module_name] = $module_name;
    }
  }

  return $return;
}
rajab natshah’s picture

Status: Needs work » Needs review
grevil’s picture

Status: Needs review » Needs work

If we are using moduleHandler()->hasImplementations, we can't keep the D8 compatibility, as this method was introduced in Drupal 9.4.

grevil’s picture

Furthermore, while running the tests locally, I got the following deprecation notice:

3x: user_password() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Password\PasswordGeneratorInterface::generate() instead. See https://www.drupal.org/node/3153113
3x in GenpassTest::testGenpassConfigsAndCreateUsersByAdmin from Drupal\Tests\genpass\FunctionalJavascript

But I can not seem to find any code using, user_password() and I have no idea what is causing this deprecation notice. Maybe one of the maintainers can rerun the tests using PHP >= 8.1, to see if that problem also appears on remote?

rajab natshah’s picture

Nice, good point Joshua.
To me it feels a new 2.0.x branch would keep deprecated code and what new class/function/service to use. and support for PHP 8.1, PHP 8.2, later on.

  • 2.0.x for ^9 || ^10
  • 8.x-1.x for ^8 || ^9
  • Ditching old ways is good
  • Adopting new better ways is better

Managing between that is a tricky business
Let us see how the final changes will look like.

grevil’s picture

@Rajab Natshah, sounds good! :)

anybody’s picture

@greggles, could you perhaps create that 2.0.x as of #20 and #21? So we can proceed here :)

kkalashnikov made their first commit to this issue’s fork.

kunalgautam’s picture

Hello @Anybody I have created 2.0.x branch in this issue fork. This is MR

f9be2491

greggles’s picture

What would the path to upgrade be for someone on Drupal 9 with this new 2.0.x that's proposed? Do they need to disable genpass as part of the core upgrade process?

rajab natshah’s picture

Suggested to do this in two steps:

  • 2.0.x for ^9 || ^10 ( only new code - ditching any ~8.0 or ~9.0 code using a logic with version compare !version_compare(\Drupal::VERSION, '10.0.0', 'lt')
  • 8.x-1.x for ^8 || ^9 || ^10 ( with old code and new code - only needed for the upgraded process to 2.0.x )

  • Drupal 8 and 9 sites could update to latest version on the genpass ~1.0
  • then after the update to Drupal 10, only change in the composer from ~1.0 to ~2.0

  • No disable for the module
  • No drush updb on the switch from ~1.0 to ~2.0

New features could only be committed to 2.0.x
and freeze new features on the 8.x-1.x branch.

Hoping that this would be a good plan.
Greg, do you find this plan logical? for sure you know more needed cases to cover.

greggles’s picture

Thanks for laying that out, @Rajab Natshah. That mostly makes sense to me. 2.0.x being for 9 or 10 works for me, but I think you maintain a bit more compatibility than needed.

Drupal 8 and 9 sites could update to latest version on the genpass ~1.0
then after the update to Drupal 10, only change in the composer from ~1.0 to ~2.0

No disable for the module
No drush updb on the switch from ~1.0 to ~2.0

New features could only be committed to 2.0.x
and freeze new features on the 8.x-1.x branch.

That plan means that 2.0.x only needs to work with 10.x, right? That seems easier to do.

Another option:

Make 8.x-1.x compatible with both 8.x and 9.x (at this point I don't think we should invest much time in 8, honestly).
Make 2.0.x compatible with both 9.x and 10.x.
The upgrade flow is for 8.x-and 9.x to get on 9.x core with 8.x-1.x. I believe this is already possible and we can say that 8.x-1.x is no longer actively developed. Then once core is at 9.x people should upgrade to genpass 2.x and can upgrade core to 10.x.

Either of these 3 plans (yours, my first modification to yours to drop 10 support from 8.x-1.x branch, the 3rd one here to drop 10 support form 8.x-1.x and adjust the upgrade flow) works for me.

I'm also happy passing on maintainership if someone else wants to become maintainer - please file an issue with links to your activity in this module's queue showing creation of patches, reviews, etc. that demonstrate the work of a maintainer.

grevil’s picture

I am ok, with either keeping the 2.0x branch D9 and D10 compatible OR D10 only.

Although if we want to keep the D9 compatibility we have to define core_version_requirement: ^9.4 || ^10, as explained in #19:

If we are using moduleHandler()->hasImplementations, we can't keep the D8 compatibility, as this method was introduced in Drupal 9.4

rajab natshah’s picture

Thanks, Greg, I agree that your modification plan is better.

Either of these 3 plans (yours, my first modification to yours to drop 10 support from 8.x-1.x branch, the 3rd one here to drop 10 support form 8.x-1.x and adjust the upgrade flow) works for me.

with Joshua's notes too.

2.0.x will have ^9.4 || ^10
8.x-1.x will have ^8 || ^9

Paving the way for a smooth upgrade workflow.


I'm also happy passing on maintainership if someone else wants to become maintainer - please file an issue with links to your activity in this module's queue showing creation of patches, reviews, etc. that demonstrate the work of a maintainer.

Love to help in maintaining the Generate Password module.
#3338506: Offering to Support and Maintain the Generate Password module

rajab natshah’s picture

rajab natshah’s picture

Status: Needs work » Needs review
rajab natshah’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
rajab natshah’s picture

As listed in #17

Having the following back to be committed to the 2.0.x branch.

Use ModuleHandlerInterface::hasImplementations() to determine if hooks implementations exist.

/**
 * Return an array of all modules which implement hook_password.
 */
function genpass_algorithm_modules() {
  // Fetch a list of all modules which implement the password generation hook.
  // To be in this list, a module must implement a hook, and return random
  // passwords as strings.

  $all_modules = \Drupal::moduleHandler()->getModuleList();
  $return = [];
  foreach ($all_modules as $module_name => $module) {
    if (\Drupal::moduleHandler()->hasImplementations('password', $module_name)) {
      $return[$module_name] = $module_name;
    }
  }

  return $return;
}
rajab natshah’s picture

Status: Needs review » Needs work
grevil’s picture

Thank you, Rajab for bringing this issue towards an end! :)

What are the remaining steps to get this committed to 2.0.x? As I am aware, we only need to test your changes (especially the "hasImplementations" part)?!

Or is there anything else to do, as you changed the status to "Needs work"?

rajab natshah’s picture

Rebase failed: Rebase locally, resolve all conflicts, then push the branch. Try again.

  • Rajab Natshah committed f812c6aa on 2.0.x
    Issue #3287722 by Rajab Natshah, hardikpandya, Grevil, kkalashnikov,...

rajab natshah’s picture

Status: Needs work » Needs review
rajab natshah’s picture

  • ✅ Automated unit testing coverage
  • ✅ Automated functional testing coverage

Development version: 2.0.x-dev updated 7 Feb 2023 at 09:35 UTC

rajab natshah’s picture

Status: Needs review » Fixed
grevil’s picture

Great work! Thanks for your time! :)

rajab natshah’s picture

Thank you all, for the nice collaborative work on this issue for this important module.


✅ Released genpass-2.0.0-alpha1
Soft release ( pre-release )
Having more post release testing before releasing the stable 2.0.0 tag.
rajab natshah’s picture

Issue tags: +genpass-2.0.0-alpha1

Status: Fixed » Closed (fixed)

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