Problem/Motivation
In preparing another issue, I ran into the non OO function image_filter_keyword() in image.module.
Besides, image_filter_keyword()
can return float despite its doc says
* @return int|string
* The offset from the anchor, in pixels, or the anchor itself, if its value
* isn't one of the accepted values.
This causes deprecations in PHP 8.1 if the returned value is used in GD functions that expect ints instead.
Proposed resolution
This patch:
- Moves the function image_filter_keyword() to a static method in \Drupal\Component\Utility\Image.
- Adds test coverage for it.
Remaining tasks
User interface changes
None.
API changes
image_filter_keyword() deprecated
new \Drupal\Component\Utility\Image::getKeywordOffset() method
Comment | File | Size | Author |
---|
Issue fork drupal-2350849
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
Comment #1
fietserwinComment #3
jhedstromWe couldn't remove the funciton in 8.x, but we could mark it
@deprecated
for 9.x and convert the code within to call the new utility method.The patch no longer applies, so setting to NW.
Comment #13
mondrakeThis is now causing PHP 8.1 issues, see #3268390: image_filter_keyword returns floats causing PHP 8.1 deprecations
Comment #14
mondrakeComment #16
mondrakeRerolled and modernized...
Comment #17
mondrakeComment #19
ankithashettyJust rebased the MR and fixed phpcs errors, thanks!
Comment #20
mondrakeComment #21
mondrakeOn this.
Comment #22
mondrakeThanks @ankithashetty and @longwave!
Comment #23
longwaveLooks good, nice to finally resolve the @todo about test coverage :)
Comment #24
mondrakeEdited CR.
Comment #25
quietone CreditAttribution: quietone at PreviousNext commentedThe change record is the same as the deprecation message in the patch. At least it should have before and after code samples, similar to https://www.drupal.org/node/3220952.
Thanks.
Comment #27
mondrakeUpdated CR.
Comment #28
mondrakeNW for test failure
Comment #29
longwaveThis will have to go into 10.1.x now.
Comment #30
mondrakerebased