#56323 closed defect (bug) (invalid)
Undefined variable phpcs error for $new_size_meta
Reported by: | mehulkaklotar | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1 |
Component: | Media | Keywords: | has-patch needs-unit-tests |
Focuses: | performance | Cc: |
Description
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)
Change History (18)
This ticket was mentioned in PR #3052 on WordPress/wordpress-develop by mehulkaklotar.
2 years ago
#1
- Keywords has-patch added
#2
@
2 years 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.
#5
@
2 years 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
@
2 years 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
@
2 years ago
Yes, @adamsilverstein actually I saw this error first in my PHPCS run
Somehow missed this on my end, thanks for catching.
#9
@
2 years 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.
adamsilverstein commented on PR #3052:
2 years ago
#10
#11
@
2 years 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
@
2 years 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
@
2 years ago
@adamsilverstein Great. Thanks! Is there a good directory for me to put that file in?
#14
@
2 years ago
In the folder tests/phpunit/tests/image/
along with the other image test files should be good.
Trac ticket: https://core.trac.wordpress.org/ticket/56323