Symfony Messenger 4.3 - Consuming messages from doctrine transport fails (exception thrown) - symfony

Symfony version: 4.3.2
PHP: 7.2.20
I am trying to use the messenger component with the doctrine transport asynchronously. I have installed the messenger via composer require messenger with the help of Symfony Flex.
I have activated the doctrine transport by MESSENGER_TRANSPORT_DSN=doctrine://default in the .env.local.
In the messenger config the transport is configured as well:
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
routing:
'App\Message\SomeNotification': async
When dispatching the message in the controller with $this->dispatchMessage(new SomeNotification('some content')); everything is fine. The table messenger_messages of the doctrine transport gets created automatically and the message is saved in the table correctly.
When trying to consume the message with ./bin/console messenger:consume async I'm getting the following error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Argument 2 passed to Symfony\Component\Messenger\Worker::__construct() must implement interface Symfony\Component\Messenger\MessageBusInterface, string given, called in ..../vendor/symfony/messenger/
Command/ConsumeMessagesCommand.php on line 190
So the $routableBus in the Symfony\Component\Messenger\Command\ConsumeMessagesCommand is empty which leads to the crash when instantiating the Worker.

The answer for the question is to update symfony/framework-bundle to 4.3.2 as well. Due to a bug in the composer.json of the messenger component version 4.3.2 of the framework bundle is not enforced. This leads to the default misconfiguration when using an older version of the symfony/framework-bundle in combination with 4.3.2 of the messenger component. This explained my error since I had 4.3.0 of the framework bundle installed.
More about it can be found on the GitHub issue tracker right here:
https://github.com/symfony/symfony/issues/32738
After updating the symfony/framework-bundle everything works as expected.

Related

how to fix Botman error with conversation?

BotMan Version: 2.6
PHP Version: 8.1
Symfony Version : 5.4
Cache Driver: Symfony Cache
i'm using botman for telegram bot. everything is ok with botman just the conversation is not working
The question is asked, but when I answer, I see such an error.
An exception has been thrown during the rendering of a template ("Warning: is_file(): Unable to find the wrapper "closure" - did you forget to enable it when you configured PHP?").
Can someone help?
Tried to install php 8.2. Similarly
DriverManager::loadDriver(TelegramDriver::class);
$adapter = new FilesystemAdapter();
$botman = BotManFactory::create($this->config, new SymfonyCache($adapter));

Error while creating a controller for a cloud using juju

sudo juju bootstrap --constraints tags=juju mymaas maas-controller
Creating Juju controller "maas-controller" on mymaas
Looking for packaged Juju agent version 2.3.7 for amd64
Launching controller instance(s) on mymaas...
ERROR failed to bootstrap model: cannot start bootstrap instance: failed to acquire node: unexpected: ServerError: 400 BAD REQUEST ({"tags": ["No such tag(s): 'juju'."]})
Please refer to: https://docs.jujucharms.com/2.5/en/reference-constraints
This is an issue with tagging in MAAS as well as not using supported tags:
tags=juju mymaas maas-controller
This will specifically look for all servers with all of the tags:
juju
mymaas
maas-controller
Unless your maas controller has a server with all of those tags attached to it it will not find any servers and error out saying it cannot acquire a node with those tags, as it did.
Make the constraints match the supported standard, i.e. resource constraints.
Or, use a non-supported feature that I use when I deploy charms to maas and use the hostname.
juju bootstrap --to hostname.superdomain.com
this will search maas (assuming you have set it up correctly) for that hostname specifically and use it to bootstrap.

EXC_BAD_ACCESS code=2 on including Firebase/Auth in Podfile

I am getting EXC_BAD_ACCESS after including 'Firebase/Auth' in Podfile. This happens without adding any line of firebase code. I am using swift3 on xcode 8 and the resultant pods are -
Installing Firebase (3.8.0)
Installing FirebaseAnalytics (3.5.1)
Installing FirebaseAuth (3.0.6)
Installing FirebaseCore (3.4.4)
Installing FirebaseInstanceID (1.0.8)
Using GTMOAuth2 (1.1.4)
Using GTMSessionFetcher (1.1.7)
Using GoogleAppUtilities (1.1.2)
Installing GoogleInterchangeUtilities (1.2.2)
Using GoogleSignIn (4.0.1)
Using GoogleSymbolUtilities (1.1.2)
Installing GoogleToolboxForMac 2.1.0 (was 2.1.0)
Using Localize-Swift (1.6)
Using ProtocolBuffers-Swift (3.0.6)
Using QorumLogs (0.9)
The error comes in Thread 1 in [UIViewController(FIRAScreenClassName) fira_viewDidAppear:]:
This happens only if the pod target is itself a framework which is embedded in an app eventually.
I do have Google analytics as well. Is it because ARC is not enabled? How do I do that on xcode-8?
Any other options to try?
There appears to be a problem in the latest Firebase/Core (3.8.0) release. Even #IBDesignable was crashing with a recursive call to the method signature you mentioned.
You have a couple of options:
In Info.plist (app), set FirebaseAutomaticScreenReportingEnabled to NO (bool). This solved the problem for my running application, but IBDesignable resources caused this error on build:
file:///path/to/project/Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for UIViewController (svZ-78-1Mn): The agent crashed
You may want to temporarily downgrade to 3.7.1, for example,
pod 'Firebase/Core', '~> 3.7.1'
pod 'Firebase/Auth'
pod 'Firebase/Database'
The rest of the dependencies should take care of themselves when you run pod update.
I made a silly mistake. Never turned on Google under Authentication -> Sign in methods on Firebase
I am suspecting that the Podfile is not correct. I got into similar problem by adding Firebase dependency into a framework and I ran into the problem like this
objc[12345]: Class FIRAAppEnvironmentUtil is implemented in both
/Users/...Build/Products/Debug-iphonesimulator/SomeFramework.framework/SomeFramework
(0x105ef7fc8) and /Users/.../CurrentProject.app/CurrentProject
(0x105945108). One of the two will be used. Which one is undefined.
As mentioned in this post, you might have duplicate dependencies in different targets which could lead to weird bug like this. Adding Firebase pod into the main target and removing the Firebase pod from the framework fixed the problem for me.

The field 'usernameCanonical' is not mapped by Doctrine, so it cannot be validated for uniqueness

I am using FOSUserBundle in my Symfony 2.7 project. In the composer.json file the requirement is defined as "friendsofsymfony/user-bundle" : "~2.0#dev". Currently version/commit 45d6f40 (11/03/2015) is installed.
After using composer update the latest version 7abb0ff was installed. After this, I get the following exception when trying to create new users:
The field 'usernameCanonical' is not mapped by Doctrine, so it cannot be validated for uniqueness
Searching for solution for this problem brought up older issues dealing with the same exception (here and here). However I was not able to solve the problem with the solution discussed in these issues.
Issue 1565 proposes to use FOS\UserBundle\Entity\User as BaseUser; instead of FOS\UserBundle\Model\User as BaseUser;. But this solution seems not to be valid for version 2.x. The 2.x documentation says that you should extend from FOS\UserBundle\Model\User, which makes sense since there are no FOS\UserBundle\Entity\... classes anymore.
My User class looks like this:
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* This class represents the User entity and extends the FOSBundle base user
* Entity class to be able to use FOSUserBundle to manage the application users.
*
* #ORM\Entity(repositoryClass="AppBundle\Entity\UserRepository")
* #ORM\Table(name="app_user") *
* #ORM\HasLifecycleCallbacks()
*/
class User extends BaseUser {
...
}
In Issue 1638 the solution was to use auto_mapping in the Doctrine configuration. I already did this.
So neither of the existing solutions worked for my. Additional all existing issues to this problem are quite old.
Of course I could simply downgrade back to version/commit 45d6f40. However I would prefer to solve the problem instead of ignoring it :-)
Any other idea how I can solve this?
PS: This is my composer show -i output:
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.6.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.6.1 Common Library for Doctrine projects
doctrine/dbal v2.4.5 Database Abstraction Layer
doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.8 Object-Relational-Mapper for PHP
friendsofsymfony/http-cache 1.4.0 Tools to manage cache invalidation
friendsofsymfony/http-cache-bundle 1.3.4 Set path based HTTP cache headers and send invalidation requests to your HTTP cache
friendsofsymfony/rest-bundle 1.4.2 This Bundle provides various tools to rapidly develop RESTful API's with Symfony2
friendsofsymfony/user-bundle dev-master 7abb0ff Symfony FOSUserBundle
gremo/buzz-bundle v1.1.0 Symfony Bundle for using the lightweight Buzz HTTP client.
guzzle/guzzle v3.9.3 PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle
jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library
jms/metadata 1.5.1 Class/method/property metadata management in PHP
jms/parser-lib 1.0.0 A library for easily creating recursive-descent parsers.
jms/serializer 1.3.1 Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle 1.1.0 Allows you to easily serialize, and deserialize data of any complexity
kriswallsmith/assetic v1.3.2 Asset Management for PHP
kriswallsmith/buzz v0.15 Lightweight HTTP client
leafo/scssphp v0.6.6 scssphp is a compiler for SCSS written in PHP.
moontoast/math 1.1.0 A mathematics library, providing functionality for large numbers
paragonie/random_compat v2.0.2 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpcollection/phpcollection 0.5.0 General-Purpose Collection Library for PHP
phpoption/phpoption 1.5.0 Option Type for PHP
psr/log 1.0.0 Common interface for logging libraries
sensio/distribution-bundle v2.3.22 The base bundle for the Symfony Distributions
sensio/framework-extra-bundle v2.3.4 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle v2.3.5 This bundle generates code for you
swiftmailer/swiftmailer v5.4.3 Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle v2.7.1 Integrates Assetic into Symfony2
symfony/monolog-bundle v2.8.2 Symfony MonologBundle
symfony/swiftmailer-bundle v2.3.11 Symfony SwiftmailerBundle
symfony/symfony v2.7.7 The Symfony PHP framework
tfox/mpdf-port-bundle 1.3.1 A wrapper for mPDF class which allows to use mPDF in Symfony2 projects
twig/extensions v1.0.1 Common additional features for Twig that do not directly belong in core
twig/twig v1.25.0 Twig, the flexible, fast, and secure template language for PHP
willdurand/jsonp-callback-validator v1.1.0 JSONP callback validator.
willdurand/negotiation 1.5.0 Content Negotiation tools for PHP provided as a standalone library.
Maybe this solve someone problems when you get the error
The field 'usernameCanonical' is not mapped by Doctrine, so it cannot be validated for uniqueness
One cause is using FOS\UserBundle\Model\User as BaseUser and running doctrine schema:update, if you did this you create a table on a database without several columns like username, usernameCanonical, password, etc.
When you want to access to any functionalities of this you get that message.
How to fix:
Dropping table fos_user on database
Change FOS\UserBundle\Model\User as BaseUser
to
FOS\UserBundle\Entity\User as BaseUser
Run php app/console doctrine:schema:update --force

Keep getting error on Symfony after installing JsFormValidatorBundle

After installing JsFormValidatorBundle, I keep getting the error bellow when I try to open my page on localhost. I installed the bundle following the instruction on https://github.com/formapro/JsFormValidatorBundle, composer installed the bundle successfully. My Symfony version is the 2.8. And my composer is updated.
InvalidArgumentException in FormPass.php line 59:
Tagged form type extension must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "fp_js_form_validator.extension" service.
I tried to add this information at app/config/services.yml, but did not work:
fp_js_form_validator.extension:
class: Fp\JsFormValidatorBundle\Form\Extension\FormExtension
tags:
- { name: form.type_extension, alias='form', extended_type: Symfony\Component\Form\Extension\Core\Type\FileType }
Thanks

Resources