With https://www.drupal.org/community/events/drupal-10-global-porting-day-jul... coming up and https://www.drupal.org/about/core/blog/the-project-update-bot-is-being-r... starting to create automated update suggestion issues like #3290652: Automated Drupal 10 compatibility fixes and #3290604: Automated Drupal 10 compatibility fixes, it's time to start looking at D10.

I updated `core_version_requirement: ^8.8 || ^9 || ^10` in shs.info.yml, but to get an idea of how much work this is going to be. The field configuration worked fine.

Configuring SHS field in D10 working as expected

However when adding or editing the content type with the field configure to use SHS in the form display, the field is rendered as just a text field. If you add a valid term id, the node will be saved and render as expected.

problem with shs field rendering as text field

Somehow no errors are generated.

Issue fork shs-3295761

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

kreynen created an issue. See original summary.

oheller’s picture

If you open the browser inspector, you will see an error about Once not being a function. This is because jquery.once has been removed from core: https://www.drupal.org/node/3158256.

We need to update the library to call core/once and update AppView.js, around ln:42 to properly use once. I've tried but haven't succeeded yet.

oheller’s picture

We have updated the js/views/AppView.js LN: 44 with:

once('shs', this.$el)[0].classList.add('hidden');

This adds the hidden class but we don't have the taxonomy terms added to the containers.

rahul17’s picture

Created a patch for Drupal 10 Compatibility Fixes, please review.

kreynen’s picture

@rahul1707 was that patch created from the current 2.0.x branch?

shs_d10_compatibility_issue_fixes-3349877-1_0.patch:153: trailing whitespace.
        $parents = []; 
error: patch failed: modules/shs_chosen/src/Plugin/views/filter/ShsChosenTaxonomyIndexTidDepth.php:6
error: modules/shs_chosen/src/Plugin/views/filter/ShsChosenTaxonomyIndexTidDepth.php: patch does not apply
error: patch failed: src/Plugin/Field/FieldFormatter/EntityReferenceShsFormatter.php:69
error: src/Plugin/Field/FieldFormatter/EntityReferenceShsFormatter.php: patch does not apply
error: patch failed: src/Plugin/views/filter/ShsTaxonomyIndexTidDepth.php:42
error: src/Plugin/views/filter/ShsTaxonomyIndexTidDepth.php: patch does not apply

I've created an issue branch and started making the changes there. If you could use that as a starting point, I'm happy to review.

godotislate’s picture

Upgrade status has these D10 compatibility warnings against 2.0.0-rc3, and on a quick look, they still seem to apply to latest 2.0.x-dev

Simple hierarchical select 2.0.0-rc3
Scanned on Thu, 03/23/2023 - 16:51.

4 warnings found.

web/modules/contrib/shs/shs.libraries.yml:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ The 'shs.form' library is depending on a deprecated library. │
│ manually │      │ The core/backbone asset library is deprecated in Drupal      │
│          │      │ 9.4.0 and will be removed in Drupal 10.0.0.                  │
│          │      │                                                              │
│ Check    │ 0    │ The 'shs.form' library is depending on a deprecated library. │
│ manually │      │ 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                          │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/shs/shs.info.yml:
┌──────────┬──────┬────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                          MESSAGE                           │
├──────────┼──────┼────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ Value of core_version_requirement: ^8.8 || ^9 is not       │
│ manually │      │ compatible with the next major version of Drupal core. See │
│          │      │ https://drupal.org/node/3070687.                           │
│          │      │                                                            │
└──────────┴──────┴────────────────────────────────────────────────────────────┘

web/modules/contrib/shs/modules/shs_chosen/shs_chosen.info.yml:
┌──────────┬──────┬────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                          MESSAGE                           │
├──────────┼──────┼────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ Value of core_version_requirement: ^8.8 || ^9 is not       │
│ manually │      │ compatible with the next major version of Drupal core. See │
│          │      │ https://drupal.org/node/3070687.                           │
│          │      │                                                            │
└──────────┴──────┴────────────────────────────────────────────────────────────┘

Replacing jquery.once should be relatively straightforward. The larger issue is replacing core/backbone. There seems to be three ways forward:

  1. Replace core/backbone dependency with core/internal.backbone. This would mean requiring at least D9.4. It is also highly discouraged by core maintainers to do this. #3258931: Deprecate backbone and tag it internal
  2. Adding backbone.js as its own library directly in this module
  3. Refactoring the JS implementation to completely remove Backbone

Seems like the last one could be a separate issue to do over a longer term, and possibly be done in a 3.0.x branch. But in order to be D10 compatible in the short term, perhaps one of the first two approaches could be a short term fix?

godotislate’s picture

Also caught these two lines that need updating per Creating an instance of the class Drupal\Core\Database\Query\Condition with the new keyword is deprecated and an API addition with the method Drupal\Core\Database\Query\Query::getConnection():
Drupal\shs_chosen\Plugin\views\filter\ShsChosenTaxonomyIndexTidDepth
l. 139
$or_condition = new Condition('OR');
Drupal\shs\Plugin\views\filter\ShsTaxonomyIndexTidDepth
l. 141
$or_condition = new Condition('OR');

Replacement for both should probably be
$or_condition = $this->database->condition('OR');

rahul17’s picture

Created patch for 2.0.x-dev to fix Drupal 10 compatibility issues. Please review it.

tushar1’s picture

Status: Active » Reviewed & tested by the community
Issue tags: +Drupal 10 compatibility
StatusFileSize
new22.85 KB

I have tested patch on latest 2x version which is applied cleany and working as expected on Drupal 9 & 10..making it RTBC

j.’s picture

Patch is apply and no issues on D10.

kreynen’s picture

"No issues" meaning SHS is fully functional?

j.’s picture

Correct.

kars4’s picture

It is not fully functional for me.
Not working Chosen widget and creating new items.

almador’s picture

StatusFileSize
new87.65 KB

Hi, rahul1707, and thank you so much for the patch!

I'm using the latest shs-2.0.0-rc3 with your patch and I can confirm that it works with selecting hierarchical items.

BUT when I'm trying to allow creating new items on the form display widget:
admin/structure/types/manage/article/form-display

"Allow creating new items
Allow users to create new items of the source bundle."

widget checkbox is gray and not available

p.s. found this, so maybe it's not the patch problem:
related issue

p.s.2 if someone is looking for a solution the patch from here:
https://www.drupal.org/files/issues/2022-11-12/shs-add-new-term-function...
working!

almador’s picture

This patch should help with shs_chosen search not working

kreynen’s picture

Chosen still seems buggy, but core SHS functionality seems to be working as expected in D10. I haven't tested in D9 yet. I opened an MR to the 2.x branch. Not sure if that's the direction @stBorchert and @jhedstrom want to do with this, but this unblocks me on #3290652: Automated Drupal 10 compatibility fixes. If we want to push these changes to a 3.x branch and make that D10 only, I'm happy to help with that.

HUGE thanks to everyone who has contributed!

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

jhedstrom’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

aneida’s picture

Hi, remember 'static' return type declaration is only allowed since PHP 8.0

In php 7.4 not working.

src/Cache/ShsCacheableJsonResponse.php:37
src/Cache/ShsCacheableJsonResponse.php:56
kreynen’s picture

@Aneida That's what I was afraid of. There's only 4 months of D7 support left, but trying to keep everything work with D9/PHP7 and D10/PHP8.1 is challenging. Probably should have gone with a 3.0.x release for D10.

aneida’s picture

Another way would be to add the composer.json file, where the minimum php requirement is indicated. This way, you avoid creating a version that as you mention, will lose maintenance.

https://www.drupal.org/docs/develop/creating-modules/let-drupal-know-abo...

Greetings.

Status: Fixed » Closed (fixed)

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