doctrine-extensions / DoctrineExtensions

Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable
MIT License
4.04k stars 1.27k forks source link

Sluggable behavior: unknown named parameter 'fields' #2666

Closed dimabredun closed 1 year ago

dimabredun commented 1 year ago

Hey guys! I'm facing the issue with doctrine extensions bundle. Not able to use it's sluggable behavior in my entity. Going over symfonycasts tutorial about Authentication, there they just adding use statement (use Gedmo\Mapping\Annotation\Slug;) and then adding #[Slug(fields: ['name'])]above the needed property. My IDE immediately telling me 'parameter 'fields' doesn't exist'. So when I'm trying to load the doctrine fixtures, I'm getting the error (stack trace below) Meanwhile sluggable behavior in config set to true.

Any ideas?

Package

name : gedmo/doctrine-extensions descrip. : Doctrine2 behavioral extensions keywords : Blameable, behaviors, doctrine2, extensions, gedmo, loggable, nestedset, sluggable, sortable, timestampable, translatable, tree, uploadable versions : * v3.1.0 latest : v3.13.0 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : http://gediminasm.org/ source : [git] https://github.com/doctrine-extensions/DoctrineExtensions.git 0803fa56b13cf858951599027f451738078c49f8 dist : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/0803fa56b13cf858951599027f451738078c49f8 0803fa56b13cf858951599027f451738078c49f8 path : /home/dima/PhpstormProjects/Authenticator symfony/start/vendor/gedmo/doctrine-extensions names : gedmo/doctrine-extensions, ext-mongo

support email : gediminas.morkevicius@gmail.com issues : https://github.com/doctrine-extensions/DoctrineExtensions/issues source : https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.1.0 wiki : https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc

autoload psr-4 Gedmo\ => src/

requires behat/transliterator ~1.2 doctrine/annotations ^1.13 doctrine/collections ^1.0 doctrine/common ^2.13 || ^3.0 doctrine/event-manager ^1.0 php ^7.2 || ^8.0

requires (dev) alcaeus/mongo-php-adapter ^1.1 doctrine/cache ^1.11 || ^2.0 doctrine/doctrine-bundle ^2.3 doctrine/mongodb-odm ^2.0 doctrine/orm ^2.6.3 friendsofphp/php-cs-fixer ^2.16 phpunit/phpunit ^8.5 symfony/cache ^4.4 || ^5.0 symfony/yaml ^4.1

suggests doctrine/mongodb-odm to use the extensions with the MongoDB ODM doctrine/orm to use the extensions with the ORM symfony/cache to cache parsed annotations

provides ext-mongo 1.6.12

conflicts doctrine/mongodb <1.3 doctrine/mongodb-odm <2.0 sebastian/comparator <2.0

Doctrine packages

Direct dependencies required in composer.json: doctrine/doctrine-bundle 2.6.3 2.10.2 Symfony DoctrineBundle doctrine/doctrine-fixtures-bundle 3.4.0 3.4.4 Symfony DoctrineFixturesBundle doctrine/doctrine-migrations-bundle 3.1.1 3.2.4 Symfony DoctrineMigrationsBundle doctrine/orm 2.10.1 2.16.2 Object-Relational-Mapper for PHP

Transitive dependencies not required in composer.json: doctrine/annotations 1.13.2 2.0.1 Docblock Annotations Parser doctrine/cache 2.1.1 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache... doctrine/collections 1.6.8 2.1.3 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays. doctrine/common 3.1.2 3.4.3 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on su... doctrine/data-fixtures 1.5.1 1.6.7 Data Fixtures for all Doctrine Object Managers doctrine/dbal 2.13.4 3.6.6 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management. doctrine/deprecations v0.5.3 v1.1.1 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or sel... doctrine/event-manager 1.1.1 2.0.0 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects. doctrine/inflector 2.0.3 2.0.8 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singul... doctrine/instantiator 1.4.0 2.0.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 1.2.1 3.0.0 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. doctrine/migrations 3.2.1 3.6.0 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versio... doctrine/persistence 2.2.2 3.2.0 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappe... doctrine/sql-formatter 1.1.1 1.1.3 a PHP SQL highlighting library

PHP Version

PHP 8.1.21 (cli) (built: Jul 8 2023 07:09:57) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.21, Copyright (c) Zend Technologies with Zend OPcache v8.1.21, Copyright (c), by Zend Technologies with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans

Stack trace for error

[2023-09-11T18:04:48.452738+03:00] console.CRITICAL: Error thrown while running command "doctrine:fixtures:load". Message: "An exception occurred while executing 'INSERT INTO question (name, question, asked_at, votes, slug) VALUES (?, ?, ?, ?, ?)' with params ["Duck and a sad tale!' said the Rabbit hastily.", "Dolor est dolore veniam neque. Mollitia autem tempora perferendis id enim. Quam cupiditate voluptates autem voluptas cumque dolorum molestiae.", "2023-06-28 17:15:45", -16, null]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null" {"exception":"[object] (Doctrine\DBAL\Exception\NotNullConstraintViolationException(code: 0): An exception occurred while executing 'INSERT INTO question (name, question, asked_at, votes, slug) VALUES (?, ?, ?, ?, ?)' with params [\"Duck and a sad tale!' said the Rabbit hastily.\", \"Dolor est dolore veniam neque. Mollitia autem tempora perferendis id enim. Quam cupiditate voluptates autem voluptas cumque dolorum molestiae.\", \"2023-06-28 17:15:45\", -16, null]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null at /home/dima/PhpstormProjects/Authenticator symfony/start/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:125)\n[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null at /home/dima/PhpstormProjects/Authenticator symfony/start/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18)\n[previous exception] [object] (PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null at /home/dima/PhpstormProjects/Authenticator symfony/start/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)","command":"doctrine:fixtures:load","message":"An exception occurred while executing 'INSERT INTO question (name, question, asked_at, votes, slug) VALUES (?, ?, ?, ?, ?)' with params [\"Duck and a sad tale!' said the Rabbit hastily.\", \"Dolor est dolore veniam neque. Mollitia autem tempora perferendis id enim. Quam cupiditate voluptates autem voluptas cumque dolorum molestiae.\", \"2023-06-28 17:15:45\", -16, null]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null"} []

Version of bundle: "stof/doctrine-extensions-bundle": "^1.4",

phansys commented 1 year ago

Hi @dimabredun. Could you please share more details about your setup and the stack trace for the described issue? In the description, please use the issue template in order to share as much information as possible about your setup.

Thank you.

dimabredun commented 1 year ago

Hi @dimabredun. Could you please share more details about your setup and the stack trace for the described issue? In the description, please use the issue template in order to share as much information as possible about your setup.

Thank you.

Hi @phansys ! I updated the question

P.S. Closed the issue. I upgraded the package and it worked out. Thank you

phansys commented 1 year ago

Thank you @dimabredun!