mautic / api-library

Mautic API Library
MIT License
180 stars 124 forks source link

Mautic API not working with Psr/Log v3 #312

Closed rebbieboi closed 2 months ago

rebbieboi commented 1 year ago

Declaration of Mautic\Api\Api::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void {"userId":27,"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Declaration of Mautic\Api\Api::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void at /vendor/mautic/api-library/lib/Api/Api.php:127)

I fixed this by forcing "psr/log": "~2.0". Note that I'm using Laravel 10 which I think upgraded it to v3.0

I'm also using: "mautic/api-library": "^3.1.0",

escopecz commented 1 year ago

Can you try updating to the changes in the main branch? It should have been fixed there but not yet released.

rebbieboi commented 1 year ago

Can you try updating to the changes in the main branch? It should have been fixed there but not yet released.

not too sure how to do that. But I'll just wait for the official release. Do we know when that would be? Thank you!

escopecz commented 1 year ago

Here is how to checkout a branch with Composer: https://getcomposer.org/doc/articles/versions.md#branches

There is no release date at the moment.

michaelandre0 commented 11 months ago

Had the same error, I managed to solve it by activating the PSR extension in PHP. In my case the PSR extension was not activated by default on my install.

theodorosploumis commented 8 months ago

Since I cannot create a PR for a git tag here is a patch for tag 3.1.0 (taken from https://github.com/mautic/api-library/compare/3.1.0...theodorosploumis:api-library:3.1.0.patch)

mautic_api_3.1.0_psr_log_v3.PATCH

gulios commented 2 months ago

Hi All,

Can you merge these changes to main tag or release new one, please ?

escopecz commented 2 months ago

@gulios please review, test and approve the PR you wish to merge. Most of them are stuck open as they aren't approved at least 2 times.

gulios commented 2 months ago

there is someting wrong with tags in that repo.

When i download latest version 3.1.0 in lib/Api/Api.php i see changes like: ` use Mautic\Auth\ApiAuth; use Mautic\Auth\AuthInterface; use Mautic\QueryBuilder\QueryBuilder; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger;

/**

because it was merged to main branch in git log ` commit 622e15f774f4d6ca48621fefe4b52e812d6b8d9c Merge: c1ae7f7 a448f0c Author: John Linhart admin@escope.cz Date: Fri Jul 19 10:06:32 2024 +0200

Merge pull request #327 from matbcvo/psr-logger

Use LoggerAwareTrait from Psr/Log

commit a448f0cadb22d88b1f5255b2818d9afae56d7a80 Author: Martin Vooremäe martin.vooremae@gmail.com Date: Thu Jul 18 21:06:05 2024 +0300

use LoggerAwareTrait from Psr/Log
`

but now when use composer in project composer info says: mautic/api-library 3.1.0

but don't see these changes in lib/Api/Api.php

gulios commented 2 months ago

@escopecz can you create new TAG e.g 3.1.1 with latest changes from main branch, please?

Try to create simply composer.json with "mautic/api-library": "^3.1" and look into lib/Api/Api.php it's not same as main branch so it would be nice to have latest tag synced.

escopecz commented 2 months ago

@gulios see https://github.com/mautic/api-library/releases/tag/3.1.1

escopecz commented 2 months ago

Update: The release contained some potential BC breaks. I've retagged it with https://github.com/mautic/api-library/releases/tag/4.0.0-beta