Problem/Motivation
By using TextOverlay, I'm having this error:
TypeError - Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\TextOverlay::imagettftextWrapper(): Argument #4 ($x) must be of type int, float given, called in C:\xampp\htdocs\site11\web\modules\contrib\image_effects\src\Plugin\ImageToolkit\Operation\gd\TextOverlay.php on line 83.
Drupal 10.3.10, PHP 8.3 and Image_effects 4.0.
Problem is probably the more strict usage of types in php 8.3.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #4
niharika.s commentedI have created the patch please review it .
Comment #5
ericvlWhy is the patch different from the diff of the merge request?
The patch covers 2 issues while the MR covers just one.
The MR works for me for the issue that is specified in the title but maybe there is a second issue in the file that is covered by the patch too that I can't test.
Comment #6
mondrakeThanks all!
Please do not post patch files: this project only accepts MRs.
Automated tests are failing, so this issue needs work to solve the failures.
Comment #7
priti197 commented@ericvl, there is no need of typecasting at line 69 & 70 as per patch #4. Variables $c1, $c2 are simply defined for iteration of the for() loop.
@mondrake, MR !64 is created to fix the addressed issue.
Thank you.
Comment #8
ericvl@priti Then it is OK for me, thanks
Comment #9
mondrakeTests are failing.
Comment #10
ericvlI tested the issue just by manually adding the two (int) casts in the file and checked of the issue still existed. And the test did well. What I don't understand is how the junit tests could fail after the patch in the MR was applied?
If this test fails now it should have been failed at release of the 4.0.0 version.
Strange...
Anyway, the two casts are the solution to this issue.
Comment #11
ericvlHello eveyone,
I was able to detect the real cause of the problem.
The real cause is a bug in the TextToWrapper.php file in the image_effects\src\Plugin\ImageToolkit\Operation\gd\TextToWrapper.php folder. The problem I've mentioned in the title I had it with PHP 8.2. Due that PHP 8.3 is more strict it generated an error in the assert(is_int()) function in the function translate() in image_effects\src\Component\PositionedRectangle.php.
In the file TextToWrapper.php on line 174 one should replace the line
$x_offset = round($x_delta / 2);with
$x_offset = (int) round($x_delta / 2);The round() function creates a non-integer and is detected in the assert(is_innt()).
Is someone able to change this in the merge branch? I am not capable to.
This is the only change that should be done. The previous changes may be deleted.
Thank you.
Comment #12
dhruv.mittal commentedComment #13
dhruv.mittal commentedPlease review
Comment #14
ericvlThanks for the modification.
This modification solves the issue now but the test fails again. I think, this has nothing to do with the modification but with the test itself. Some files could not be downloaded in intialisation of the test.
So I've put it on again on "needs work".
If the test is ok, it may be put in RTBC.
Comment #15
mondrakeRebased, all tests green now
Comment #17
mondrakeMerged, thanks