fenepedia/contao-klicktipp-gateway

KlickTippGateway: Class "Haste\Util\StringUtil" not found

Closed this issue · 14 comments

Hey there,

I configured the following Gateway Message in contao:
image

When I submit a form that uses this Gateway, I run into a contao error and in the current log file it says:

[2024-01-03T10:58:27.808679+01:00] php.CRITICAL: Uncaught Error: Class "Haste\Util\StringUtil" not found {"exception":"[object] (Error(code: 0): Class \"Haste\\Util\\StringUtil\" not found at /www/htdocs/w01d660b/websites/contao-sites/vendor/fenepedia/contao-klicktipp-gateway/src/Gateway/KlickTippGateway.php:55)"} []
[2024-01-03T10:58:27.904482+01:00] request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\ClassNotFoundError: "Attempted to load class "StringUtil" from namespace "Haste\Util". Did you forget a "use" statement for "NotificationCenter\Util\StringUtil"?" at /www/htdocs/w01d660b/websites/contao-sites/vendor/fenepedia/contao-klicktipp-gateway/src/Gateway/KlickTippGateway.php line 55 {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\ClassNotFoundError(code: 0): Attempted to load class \"StringUtil\" from namespace \"Haste\\Util\".\nDid you forget a \"use\" statement for \"NotificationCenter\\Util\\StringUtil\"? at /www/htdocs/w01d660b/websites/contao-sites/vendor/fenepedia/contao-klicktipp-gateway/src/Gateway/KlickTippGateway.php:55)"} []

It refers to Line 55 in KlickTippGateway.php, which is the following code:

        $email = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($message->kt_email, $tokens);

I already updated all packages in contao manager, added contao haste to the project, but it still doesnt work.

Can anyone help or does anyone have a similar problem?

Hey @LinusHe.

Can you give me a few more details?

  • Which Contao version?
  • Which PHP version?
  • Which KlickTipp version?

I can then try to reproduce the error.

Bitte zudem noch die verwendete Version vom Notification-Center und von der Erweiterung Haste.

The issue is that we forgot to add a dependency for codefog/contao-haste.

Please try the following workaround:
Add a specific version-constraint for contao-haste to the composer.json under require:

    "require": {
        ...
        "codefog/contao-haste": "^4.25"
    },

Then update all packages again.
This should install contao-haste version 4.x.

You can also test dev-master now.

Thank you for your help.

My installed packages:

  • Contao Open Source CMS: 4.13.23
  • Contao Haste: 5.1.14
  • Contao KlickTipp Gateway: 1.2.0
  • Notification Center: 1.7.5

I added

    "require": {
        ...
        "codefog/contao-haste": "^4.25"
    },

to the vendor/fenepedia/contao-klicktipp-gateway/composer.json file and clicked on the grey "Pakete aktualisieren" button in contao manager, executed the composer class loader and cleared the prod cache in the maintenance tab.

Unfortunately that didn't help and I still get the same error. Do I need to do something else that the klicktipp plugin finds contao haste?
The log message says Did you forget a "use" statement for "NotificationCenter\Util\StringUtil"?" at (...)KlickTippGateway.php - could that be the problem?

to the vendor/fenepedia/contao-klicktipp-gateway/composer.json

No, you need to add that to the composer.json of your application.

But as already mentioned, you can also test dev-master.

You would have to add the whole thing in the root composer.json of Contao.

I'll test the dev-master myself tomorrow.

Okay. I'm not sure what you mean by "your application". I'm not developing a new app, I am just using the plugin in my contao system.

@LinusHe The "Contao system" is your application.

I changed the version of the plugin to dev-master in the contao manager and that fixed the previous error, but now I'm getting a new one:

[2024-01-09T15:57:22.099585+01:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Contao\CoreBundle\Image\Studio\FigureBuilder::fromPath(): Argument #1 ($path) must be of type string, null given, called in /www/htdocs/w01d660b/websites/contao-sites/vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php on line 1789" at /www/htdocs/w01d660b/websites/contao-sites/vendor/contao/core-bundle/src/Image/Studio/FigureBuilder.php line 216 {"exception":"[object] (TypeError(code: 0): Contao\\CoreBundle\\Image\\Studio\\FigureBuilder::fromPath(): Argument #1 ($path) must be of type string, null given, called in /www/htdocs/w01d660b/websites/contao-sites/vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php on line 1789 at /www/htdocs/w01d660b/websites/contao-sites/vendor/contao/core-bundle/src/Image/Studio/FigureBuilder.php:216)"} []```

@LinusHe this is unlikely related to this extension. In any case you would need to enable the debug mode and analyse the stack trace.

Sorry for the confusion. I also realized that it is not a problem of the plugin after I submitted the comment 🤦
That's why I deleted the comment 😅

It now works. Thank you for your quick help.

@LinusHe If the dev-master works, we will release a fixed version.

I have now tested an installation with Haste 4.25 and one with Haste 5. Both times I was able to send data to KlickTipp. I will therefore close the ticket and publish a new version.

@LinusHe You can change the version back to ^1.2 after the release so that you are no longer on the dev-master.

Release 1.2.1 fixes the problem. Please update.