TypeError in using Textoverlay

Created on 17 December 2024, 2 months ago

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

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇧🇪Belgium ericvl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ericvl
  • First commit to issue fork.
  • Merge request !64Issue #3494550: Fix for typecast error. → (Merged) created by Unnamed author
  • Pipeline finished with Failed
    2 months ago
    Total: 209s
    #371955
  • I have created the patch please review it .

  • 🇧🇪Belgium ericvl

    Why 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.

  • 🇮🇹Italy mondrake 🇮🇹

    Thanks 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.

  • 🇮🇳India priti197 Mumbai - India

    @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.

  • 🇧🇪Belgium ericvl

    @priti Then it is OK for me, thanks

  • 🇮🇹Italy mondrake 🇮🇹

    Tests are failing.

  • 🇧🇪Belgium ericvl

    I 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.

  • 🇧🇪Belgium ericvl

    Hello 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.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 145s
    #396349
  • 🇧🇪Belgium ericvl

    Thanks 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.

  • 🇮🇹Italy mondrake 🇮🇹

    Rebased, all tests green now

  • Pipeline finished with Skipped
    about 1 month ago
    #396696
  • 🇮🇹Italy mondrake 🇮🇹

    Merged, thanks

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024