Automated Drupal 10 compatibility fixes

Created on 18 July 2022, over 2 years ago
Updated 23 December 2023, 12 months ago

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 โ†’ .

๐Ÿ“Œ Task
Status

RTBC

Version

2.1

Component

Code

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    Please fix this for D10 and issue a release. This simple module is really useful and important when importing images from others.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    Please fix this for D10!

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    mukesh88: Which version does this patch?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    Still does not work.
    1. The patch is strange in that it is applied from the Web dorectory, not the directory of the module itself.
    2. It applied to the release 2.1.0 version.
    3. The icon appears and rotates the thumbnails
    4. BUT it throws a php error:

    Error: Class "FileSystemInterface" not found in
                                                         simple_image_rotate_rotate_image() (line 194 of
                                                         /home/orcmaorg/public_html/web/modules/contrib/simple_image_rotat
                                                         e/simple_image_rotate.modul
  • tjtj โ†’ i have created patch for 2.1.x version and patch is created to change the path of module itself and i have checked after save node i amn't getting any error also checked the FileSystemInterface class is already include in 2.1.x version. attached screenshot of node edit and node image rotate

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    [~/www/web/modules/contrib/simple_image_rotate]# patch -p1 < 3298061-12.patch
    patching file js/simple_image_rotate.js
    Hunk #1 FAILED at 19.
    Hunk #2 succeeded at 36 (offset -1 lines).
    1 out of 2 hunks FAILED -- saving rejects to file js/simple_image_rotate.js.rej
    patching file simple_image_rotate.info.yml
    patching file simple_image_rotate.libraries.yml
    patching file simple_image_rotate.module
    Hunk #1 succeeded at 65 (offset -3 lines).
    Hunk #2 FAILED at 193.
    1 out of 2 hunks FAILED -- saving rejects to file simple_image_rotate.module.rej

    cat simple_image_rotate.js.rej
    --- js/simple_image_rotate.js
    +++ js/simple_image_rotate.js
    @@ -19,14 +19,12 @@
               // Leaving out absolute icon placement for now.
               // $('.rotate-icon').parent('.image-preview').addClass('rotate-enabled');
                 // Treat click on rotate image icon
    -            $(".rotate-icon").once().click(function (e) {
    -
    +            $(once('rotate', '.rotate-icon', context)).each(function () {
    +              $(this).on('click', function(e) {
                     // Prevent default click on rotate icon
                     e.preventDefault();
    -                // Current rotate value and thumbnail image
    -                var rotate = parseInt($(this).attr("data-rotate"));
    -                $image = $(this).closest(".image-widget").find("img")
    -                    .add($(this).closest(".media-library-add-form li").find('[data-drupal-selector="edit-preview"] img'));
    +                var rotate = parseInt($(this).attr("data-rotate")),
    +                $image = $(this).closest(".image-widget").find("img");
                     // Rotate Input
                     $rotate_input = $(this).closest(".image-widget").find('.rotate');
                     // Remove current rotate CSS class
  • This 2 line was not in js file when i was created patch. After cloning 2.1.x branch and recreate patch

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    The patch applied. But when I added the rotate box option to the image field, it does not appear when I make a new instance of that content type.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    See two images

  • @tjtj I checked the new instance of content type and used existing image field and added image rotate box and create content with new content type image is rotate. see the attached images.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    Then please issue this so I need not jump through patch hoops in my composer file.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    What is the holdup in releasing this for Drupal 10?

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium mgstables

    I used patch #17 on a downloaded version 2.1.1-alpha1 (manual by hand)

    I also changed line 197 in simple_image_rotate.module from:
    if (file_move($file, $new_uri, FileSystemInterface::EXISTS_ERROR)) {
    to:
    if (\Drupal::service('file.repository')->move($file, $new_uri, FileSystemInterface::EXISTS_ERROR)) {

    Module installed and tested on the imagefield of "article".

    The icon was visible and usable and the image rotated.

    Drupal 10.0.8
    PHP 8.1.6

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tjtj

    MGStables: Yes that worked perfectly. Thank you.
    Now someone please release the new version.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jaime@gingerrobot.com

    jaimekristene โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jaime@gingerrobot.com

    I added #17 and #23 to the git branch. I also added a composer.json file so that I could import it directly into my installation with composer.

      "repositories": [
            {
                "type": "vcs",
                "url": "https://git.drupalcode.org/issue/simple_image_rotate-3298061.git"
            },
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8",
                "exclude": ["drupal/simple_image_rotate"]
    
            }
    ]

    Then further down:

            "drupal/simple_image_rotate": "dev-3298061-automated-drupal-10",
    
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium mgstables

    Thanks jaime@gingerrobot.com for this git version.

    I've tested the git version from #26 and it didn't work. So I compared it with my self-patched version that did work.
    In simple_image_rotate.module on line 74, an important element has been removed. (Maybe accidentally removed a line too much?)
    $elements = &$field_widget_complete_form['widget'];

    Now this is:

    function simple_image_rotate_field_widget_complete_form_alter(&$field_widget_complete_form, FormStateInterface $form_state, array $context) {
      $field_definition = $context['items']->getFieldDefinition();
      $field_name = $field_definition->getType();

    If I put this line back, it works again.

    function simple_image_rotate_field_widget_complete_form_alter(&$field_widget_complete_form, FormStateInterface $form_state, array $context) {
      $elements = &$field_widget_complete_form['widget'];
      $field_definition = $context['items']->getFieldDefinition();
      $field_name = $field_definition->getType();

    Drupal 10.1.2
    PHP 8.1.6

  • First commit to issue fork.
  • ๐Ÿ‡ช๐Ÿ‡ธSpain markus_petrux

    Hello,

    I committed the fix to set the value for $elements, see #27

    So back to ready to be reviewed.

    Best regards,
    Marc

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium mgstables

    Latest git version works perfectly. The icon was visible and usable and the image rotated.

    Drupal 10.1.4
    PHP 8.1.6

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sagesolutions

    You should simplify the once() function override in MR !4

    Before:
    $(".rotate-icon").once().click(function (e) {

    After:
    $(once('rotate', '.rotate-icon', context)).on('click', function (e) {

  • Assigned to ankithashetty
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankithashetty Karnataka, India
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankithashetty Karnataka, India

    Updated the MR as suggested in #32.

    Tested the change on Drupal 10.1.7-dev, works as expected.

    Actual image -

    After rotating -

    Recording -

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sagesolutions

    Looks good, just one spelling typo and its ready to go

    In the composer.json file, change "GPL-2.0-or-latery" to "GPL-2.0-or-later"

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankithashetty Karnataka, India

    Addressed the change requested in #35, thanks!

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sagesolutions

    Thanks for the fix @ankithashetty

Production build 0.71.5 2024