Problem/Motivation

Hello project maintainers,

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

Patches will be added to this issue that remove Drupal 10 deprecated API uses.

Remaining tasks

------ ------------------------------------------------
modules/contrib/select2/select2.libraries.yml
------ ------------------------------------------------
The 'select2.min' 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

------ ------------------------------------------------
line modules/contrib/select2/modules/select2_facets/src/Plugin/facets/widget/Select2Widget.php
------ ------------------------------------------------
109 The 'select2_facets/drupal.select2_facets.select2-widget' library is not defined because the defining extension is not installed. Cannot decide if it is deprecated or not.
------ ------------------------------------------------
modules/contrib/select2/modules/select2_publish/src/Element/StatusProperties.php
------ ------------------------------------------------
54 The 'select2_publish/select2.publish' library is not defined because the defining extension is not installed. Cannot decide if it is deprecated or not.

Issue fork select2-3310051

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

psingh10 created an issue. See original summary.

anchal_gupta’s picture

StatusFileSize
new1.18 KB

I have uploaded the patch. please review

psingh10’s picture

Issue summary: View changes

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

reenaraghavan’s picture

Assigned: psingh10 » Unassigned
StatusFileSize
new2.21 KB

Attached patch. Needs review.

berdir’s picture

Status: Active » Needs review
ameymudras’s picture

Status: Needs review » Needs work
StatusFileSize
new108.86 KB
new94.45 KB

Tested this module on Drupal 10.0.x and php 8.1 & following are my observations

- The patch #5 applies cleanly
- Was able to install 'Select2', 'Select2 Publish' and 'Select2 Facets' modules
- For node article tags taxonomy reference field used Select2 widget with default options
- Node add page the taxonomy reference field doesn't render correctly and there is a js error in the console
- Upgrade status also mentions a couple of issues which need to be fixed
- modules/select2_facets/js/select2-widget.js makes use of .once

$('.js-facets-select2.js-facets-widget')
  .once('js-facets-select2-widget-on-selection-change')
  .each(function () {
berdir’s picture

+++ b/js/select2.js
@@ -7,7 +7,7 @@
     attach: function (context) {
-      $('.select2-widget', context).once('select2-init').each(function () {
+      once('select2-init', '.select2-widget', context).forEach(function () {
         var config = $(this).data('select2-config');

this is not correctly converted. forEach works different and an argument needs to be passed in.

The easier, minimal fix is to pass once() to a jquery object like this: $(once()).each(... then the rest can remain unchanged.

ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new2.83 KB
new995 bytes

Adding a patch to fix the above issues

dishakatariya’s picture

Hi, @ameymudras, Verified and tested given patch #9. and checked in upgrade status. This is giving errors.

kristen pol’s picture

Status: Needs review » Needs work

@DishaKatariya What errors? Can you post into a comment please?

Moving back to needs work based on #10.

dishakatariya’s picture

It is compatible in upgrade status but giving warning errors now.

dishakatariya’s picture

Assigned: Unassigned » dishakatariya
dishakatariya’s picture

Assigned: dishakatariya » Unassigned
chr.fritsch’s picture

Status: Needs work » Needs review

I have prepared a PR on github for D10 compatibility. Would be nice to get some reviews

https://github.com/thunder/select2/pull/121

kristen pol’s picture

Issue tags: +Drupal 10 porting day

Working during porting day.

@chr.fritsch Thanks for the changes. The expected workflow is to either update the patch from #9 and attach it here or create an MR (GitLab) and use that. Would you be able to do one of these approaches so it's easier for the community to review and test with existing tools like DrupalPod? Thanks.

chr.fritsch’s picture

Hi @Kristen Pol: The development of the select2 module has always been on github. I am trying to move it to d.o. in #3271610: Move testing to d.do to make it easier for the community, but some tests are failing on d.o. that are not failing locally or on github. So, until #3271610: Move testing to d.do is not fixed, the development will stay on github.

kristen pol’s picture

Oh! My mistake then… I didn't realize… thanks for the info.

chr.fritsch’s picture

I was able to invest some time and was able to finally move the select2 tests to drupal.org. Thanks to gitlab CI. Yay 🥳

So this issue has now a gitlab MR and is successfully tested by gitlab ci :)

kristen pol’s picture

Great 👍 Let us know how we can help 🙂

daniel.bosen’s picture

Status: Needs review » Reviewed & tested by the community

lgtm

kristen pol’s picture

Status: Reviewed & tested by the community » Active

Yay! Since you committed this, moving this back to Active for now so no one works on this but the bot can add patches. Feel free to marked fixed though :)

Community folks, see the compatible release here: https://www.drupal.org/project/select2/releases/8.x-1.x-dev

kristen pol’s picture

Oh! This isn't a bot issue 😂

@chr.fritsch Can this issue be moved to fixed or is there more to do?

chr.fritsch’s picture

Status: Active » Fixed
laura.gates’s picture

Adding a FYI: If you're having issues with Select2 and PHP 8.1 try to download the latest develop version of the library (https://github.com/select2/select2) and replace it with the 2020 release.

Status: Fixed » Closed (fixed)

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