Make WordPress Core

Opened 23 months ago

Closed 22 months ago

Last modified 22 months ago

#56323 closed defect (bug) (invalid)

Undefined variable phpcs error for $new_size_meta

Reported by: mehulkaklotar's profile mehulkaklotar Owned by: adamsilverstein's profile adamsilverstein
Milestone: Priority: normal
Severity: normal Version: 6.1
Component: Media Keywords: has-patch needs-unit-tests
Focuses: performance Cc:


There is a undefined variable added in the code which is not defined in the context and actual variable should be $created_size_meta in src/wp-admin/includes/image.php line no 634

Attachments (1)

56323.diff (1.2 KB) - added by adamsilverstein 23 months ago.

Download all attachments as: .zip

Change History (18)

This ticket was mentioned in PR #3052 on WordPress/wordpress-develop by mehulkaklotar.

23 months ago

  • Keywords has-patch added

#2 @desrosj
23 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 6.1

Thanks for this one, @mehulkaklotar!

It looks like this was introduced in [53751] as part of #55443.

It does indeed seem that this variable will not be set here. But I'd like to confirm the intention here with those that worked on this change. @adamsilverstein and @flixos90, are you able to take a look?

It would also be great to add a unit test or two to catch this in the future.

#3 @adamsilverstein
23 months ago

Thanks for opening this @mehulkaklotar - I'll take a look!

#4 @adamsilverstein
23 months ago

  • Owner set to adamsilverstein

#5 @adamsilverstein
23 months ago

Good catch @mehulkaklotar! We missed this because it is only happening when make_subsize is unavailable and the system falls back to $editor->multi_resize(). I'm curious how you encountered this bug, were you using a custom image editor class?

#6 @mehulkaklotar
23 months ago

Yes, @adamsilverstein actually I saw this error first in my PHPCS run. And then when I was testing the generation, got it error in debug.log.

#7 @adamsilverstein
23 months ago

Yes, @adamsilverstein actually I saw this error first in my PHPCS run

Somehow missed this on my end, thanks for catching.

#8 @adamsilverstein
23 months ago

56323.diff is the fix from the PR from @mehulkaklotar

#9 @adamsilverstein
23 months ago

  • Focuses performance added

@mehulkaklotar - fix looks good, a nice improvement would be improved test coverage that fails before the fix - clearly our test coverage isn't complete here.

#11 @johnregan3
23 months ago

@adamsilverstein I'm working on writing tests for this, but I need to create an image editor class that doesn't have a 'make_subsize' method. Also, wp_get_image_editor() requires a $file name, so I'll need to make a new file to hold this class. Am I thinking about this correctly, and if so, where should I put that file? Thanks!

#12 @adamsilverstein
23 months ago

Hey @johnregan3 - thanks for offering to help here!

Reviewing our test files, it looks like you would need to implement a new image class that lacks a make_subsize function to do this testing. I'm not sure what else you will need to implement there, you can probably start with a copy of the existing GD class, then remove anything that isn't needed.

#13 @johnregan3
23 months ago

@adamsilverstein Great. Thanks! Is there a good directory for me to put that file in?

#14 @adamsilverstein
23 months ago

In the folder tests/phpunit/tests/image/ along with the other image test files should be good.

#15 @johnregan3
23 months ago

Perfect. Thanks!

#16 @adamsilverstein
22 months ago

This is no longer needed as the multi-mime code was reverted in [54085]. Closing.

Last edited 22 months ago by SergeyBiryukov (previous) (diff)

#17 @adamsilverstein
22 months ago

  • Milestone 6.1 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.