Problem/Motivation

file_validate_image_resolution() expects a resolution like 600x400 but EditorImageDialog::buildForm() passes 600×400. Yep x is not ×.

Steps to reproduce

Proposed resolution

Remaining tasks

Postponed on #2395377: Write integration test for EditorImageDialog
Change back to using ×.
Write a test so this does not revert again.

User interface changes

API changes

Data model changes

Release notes snippet

Comments

wim leers’s picture

Issue tags: +php-novice

Wow. Amazing find!

This used to work, but #657166: use × instead of x changed x to × for the UI. I don't think we realized it'd affect validation. Clearly, tests are massively lacking here (there is zero test coverage for EditorImageDialog).

aneek’s picture

@Wim Leers,
By changing
$max_dimensions = $image_upload['dimensions']['max_width'] . '×' . $image_upload['dimensions']['max_height']; to
$max_dimensions = $image_upload['dimensions']['max_width'] . 'x' . $image_upload['dimensions']['max_height']; may solve this issue. But if this section is missing a test case then it needs to be written in Editor module.

wim leers’s picture

#2: but that then breaks the work that was done in #657166: use × instead of x. That's not an option. We should just pass on the data in the expected format to file_validate_image_resolution().

aneek’s picture

@Wim Leers, but then the function (file_validate_image_resolution()) checks for image width and height exploded by x but not with ×.
Isn't the issue #657166: use × instead of x only for front end UI? Sending x in PHP code internally can be done right? if you agree then, in EditorImageDialog::buildForm() method @line 56,
Instead of

$max_dimensions = $image_upload['dimensions']['max_width'] . '×' . $image_upload['dimensions']['max_height'];

(This uses the ×-mark instead of alphabetical x)
we could use,

$max_dimensions = $image_upload['dimensions']['max_width'] . 'x' . $image_upload['dimensions']['max_height'];
wim leers’s picture

Yes, exactly :)

aneek’s picture

@Wim Leers, okay so a quick patch can be made. But what are your thoughts on test cases? How the test cases would behave?

wim leers’s picture

Currently, there is zero test coverage for EditorImageDialog. This issue doesn't need to add full test coverage, but it will have to start test coverage. It should be a WebTestBase test. If it's a problem to get started with that, I can help out! :)

Note: because a dialog is just a form rendered in a special way, you can just perform tests against the form itself, because it's a route like any other:

editor.image_dialog:
  path: '/editor/dialog/image/{filter_format}'
  …

(Try it on your local D8: http://yoursite.local/editor/dialog/image/basic_html.)

aneek’s picture

@Wim Leers, thanks.
Btw, this issue I've found while checking on this one. #2387205: Insert Image modal redirected to image upload form. Can you please have a look at it?

wim leers’s picture

I just replied to that :)

aneek’s picture

Ohh, I see it's duplicate. Never mind :-P

aneek’s picture

@Wim Leers, thanks for the explanation. But help needed on how to validate the function file_validate_image_resolution()?
To validate the image dimension test, I think we have to set max_dimension in admin/structure/types/manage/article/fields/node.article.field_image page.
In Drupal's UI even if I save the max dimension to 400x400px and upload a much bigger image, in EditorImageDialog::buildForm() the snippet $image_upload = $editor->getImageUploadSettings(); doesn't give the array by which the code is conditioned.

if (!empty($image_upload['dimensions'])) {
      $max_dimensions = $image_upload['dimensions']['max_width'] . 'x' . $image_upload['dimensions']['max_height'];
    }
    else {
      $max_dimensions = 0;
    }

But the array that is returned is,
array ( 'status' => true, 'scheme' => 'public', 'directory' => 'inline-images', 'max_size' => '', 'max_dimensions' => array ( 'width' => 0, 'height' => 0, ), )
As you see the array keys are different in both if condition and return array.
So for this the image is not re-sized to desired size.

I think this causes another bug. What are your thoughts?

wim leers’s picture

Status: Active » Postponed

You're right; this is apparently broken. The root cause for that: we don't have any tests for EditorImageDialog at all. That's my fault. I opened #2395377: Write integration test for EditorImageDialog to rectify that. Let's postpone this issue on that, because it'll be difficult to start test coverage from zero for fixing this exact problem.

Apologies for having wasted some of your time, but I very much appreciate you taking this on!

aneek’s picture

@Wim Leers, thanks for creating the test case issue. It was a nice learning experience in the image core to find the bug. So, no worries you haven't wasted my time :-)

Can you tell me one thing, will this bug with invalid array keys in image validation can be raised as a different issue or its been taken care of?

Thanks!

manningpete’s picture

Issue tags: -Novice

Removing the novice tag.

Why: because issue is postponed. People new to the issue queue might search for just the Novice tag and not know to filter to active issues. If/when issue is updated, consider re-adding the novice tag.

Novice tag documentation: https://www.drupal.org/core-mentoring/novice-tasks

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Issue tags: - +Bug Smash Initiative

This issue was discussed at a Bug Smash Initiative group triage meeting. This is still valid, update IS a bit.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture