FriendsOfSymfony / FOSUserBundle

Provides user management for your Symfony project. Compatible with Doctrine ORM & ODM, and custom storages.
https://symfony.com/doc/master/bundles/FOSUserBundle/index.html
MIT License
3.25k stars 1.57k forks source link

Not Working for MongoDB #2948

Closed azamalvi closed 3 years ago

azamalvi commented 4 years ago

Symfony FOSUserBundle versions: v2.1.2

Description of the problem including expected versus actual behavior: It looks like that this plugin is not working for MongoDB. When I try to use that it throw an error The attribute 'fieldName' is not allowed. It is related to User.mongodb.xml and Group.mongodb.xml. fieldName should be field-name

Steps to reproduce:

  1. Install latest version
  2. Change DB to MongoDB
  3. Create new user class and extend it with FOS User class
  4. Try to clear cache or update schema

Provide logs (if relevant): Element '{http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping}field', attribute 'fieldName': The attribute 'fieldName' is not allowed.

azamalvi commented 4 years ago

any update?

dragos-andries commented 4 years ago

I'm having the same issue. @azamalvi I'm guessing you are using Doctrine ODM 2. I'm currently doing an upgrade to ODM 2 on my project and the same issue appears.

Can anyone from the team specify if this will be supported in the very near future?

Thanks.

smitt522 commented 4 years ago

There was a commit, but not a release https://github.com/FriendsOfSymfony/FOSUserBundle/commit/6733bc89e832335e3b6ef83568b51dcf4c06202f

Jean-Gian commented 3 years ago

Is there any update on this? it's still happening for me

webdevilopers commented 3 years ago

Can confirm with the following packages:

    "require": {
        "php": "^7.4",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-intl": "*",
        "friendsofsymfony/user-bundle": "^2.1",
        "sonata-project/admin-bundle": "^3.93",
        "sonata-project/doctrine-mongodb-admin-bundle": "^3.7",
        "sonata-project/exporter": "2.x",
        "sonata-project/intl-bundle": "^2.10",
        "sonata-project/translation-bundle": "^2.7",
        "sonata-project/user-bundle": "^4.11",
        "symfony/apache-pack": "^1.0",
        "symfony/dotenv": "^4.4",
        "symfony/flex": "^1.12",
        "symfony/framework-bundle": "^4.4",
        "symfony/http-kernel": "^4.4",
        "symfony/yaml": "^4.4",
        "twig/twig": "^2.9"
    },
webdevilopers commented 3 years ago

This has at least been fixed inside the SonataUserBundle itself:

https://github.com/sonata-project/SonataUserBundle/issues/1120

Should those mappings not overwrite these invalid ones?

Refs: https://github.com/FriendsOfSymfony/FOSUserBundle/pull/2889

webdevilopers commented 3 years ago

Strange! Composer uses 2.1.2.

According to the repo the fix is there for 2.x:

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/2.x/Resources/config/doctrine-mapping/User.mongodb.xml

But locally the code looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
                        http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">

    <mapped-superclass name="FOS\UserBundle\Model\User" collection="fos_user_user">

        <field name="username" fieldName="username" type="string" />

Am I missing something?

webdevilopers commented 3 years ago

Latest commit 658be34 on 16 Oct 2019 -> Fix included.

Latest release: 2.1.2 @stof stof released this on 8 Mar 2018

https://github.com/FriendsOfSymfony/FOSUserBundle/releases

I'm confused.

webdevilopers commented 3 years ago

Since the fix should be included in dev-master I will try that version.

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/config/doctrine-mapping/User.mongodb.xml

webdevilopers commented 3 years ago

As expected the issue does not exist with dev-master.

stof commented 3 years ago

This is fixed in the 2.2.0 release

bettinz commented 2 years ago

@stof can you release a 2.1.3 with this fix?