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.

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
new1019 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 #139

This patch was created using these packages:

  1. mglaman/phpstan-drupal: 1.1.24
  2. palantirnet/drupal-rector: 0.13.0
akshaydalvi212’s picture

Assigned: Unassigned » akshaydalvi212
Issue summary: View changes

Hello,

I will review whether the patch makes the module compatible with drupal 10.

akshaydalvi212’s picture

Assigned: akshaydalvi212 » Unassigned
Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new24.07 KB
new33.81 KB
new72.05 KB

Hello,

After applying the patch, the module gets installed successfully on drupal 10.

and we get an option as "Enable rotate icon" in the configuration of the image field.

But the icon to rotate the image is missing, hence shifting the issue to Needs work.

Thanks and regards.

reenaraghavan’s picture

Assigned: Unassigned » reenaraghavan
reenaraghavan’s picture

Assigned: reenaraghavan » Unassigned
StatusFileSize
new28.47 KB

Couldn't fix the issue, needs work.
I have attached the screenshot of Drupal 9 which contains the rotate button.

project update bot’s picture

tjtj’s picture

Issue summary: View changes

In D9 upgrade status, I get
web/modules/custom/simple_image_rotate/simple_image_rotate.module 184 Call to deprecated function file_move(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use Drupal\file\FileRepositoryInterface::move() instead.
The patch did not apply.

tjtj’s picture

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

tjtj’s picture

Please fix this for D10!

mukesh88’s picture

StatusFileSize
new5.37 KB

Patch created for D10 tjtj

mukesh88’s picture

Status: Needs work » Needs review
tjtj’s picture

mukesh88: Which version does this patch?

tjtj’s picture

Still does not work.
1. The patch is strange in that it is applied from the Web directory, 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 when the content page is saved:

Error: Class "FileSystemInterface" not found in
                                                     simple_image_rotate_rotate_image() (line 194 of
                                                     /home/mysite/public_html/web/modules/contrib/simple_image_rotat
                                                     e/simple_image_rotate.modul
mukesh88’s picture

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

tjtj’s picture

Also, I tried to edit composer.json to use 2.1.0, and wegan's patch plugin, and the lenient plugin, but that threw a gazillion composer update errors, so I just did a manual install and patch.

[~/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 (line 2) was not in the file:
- $image = $(this).closest(".image-widget").find("img")
- .add($(this).closest(".media-library-add-form li").find('[data-drupal-selector="edit-preview"] img'));

mukesh88’s picture

StatusFileSize
new2.49 KB
new2.34 KB

This 2 line was not in js file when i was created patch. After cloning 2.1.x branch and recreate patch

tjtj’s picture

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.
See two attached images

tjtj’s picture

StatusFileSize
new141.86 KB
new85.24 KB

See two images

mukesh88’s picture

@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.

tjtj’s picture

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

tjtj’s picture

I cloned the git repository and changed info.yml for D10. But when installed, and box checked to display the rotate icon, it is not displayed. I tried it on 2 sites.

mgstables’s picture

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

tjtj’s picture

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

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

jaime@gingerrobot.com’s picture

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",
mgstables’s picture

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

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

markus_petrux’s picture

Hello,

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

So back to ready to be reviewed.

Best regards,
Marc

mgstables’s picture

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

Drupal 10.1.4
PHP 8.1.6

sagesolutions’s picture

Status: Needs review » Needs work

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) {

ankithashetty’s picture

Assigned: Unassigned » ankithashetty
ankithashetty’s picture

Assigned: ankithashetty » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new4.38 MB
new448.59 KB
new238.29 KB
new389.83 KB
new522.66 KB

Updated the MR as suggested in #32.

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

Recording -
https://www.drupal.org/files/issues/2023-11-20/Screen%20Recording%202023...

Actual image -

After rotating -

sagesolutions’s picture

Status: Needs review » Needs work

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"

ankithashetty’s picture

Status: Needs work » Needs review

Addressed the change requested in #35, thanks!

sagesolutions’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the fix @ankithashetty

afagioli’s picture

afagioli’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

afagioli’s picture

Status: Closed (won't fix) » Closed (outdated)