Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tree] Missing path value on insert a new document #2792

Open
filmen opened this issue Apr 24, 2024 · 2 comments · Fixed by #2811
Open

[Tree] Missing path value on insert a new document #2792

filmen opened this issue Apr 24, 2024 · 2 comments · Fixed by #2811

Comments

@filmen
Copy link

filmen commented Apr 24, 2024

Environment

Debian 12.4
nginx/1.22.1

Package

show

name : gedmo/doctrine-extensions descrip. : Doctrine behavioral extensions keywords : Blameable, behaviors, doctrine, extensions, gedmo, loggable, nestedset, odm, orm, sluggable, sortable, timestampable, translatable, tree, uploadable versions : * v3.15.0 latest : v3.15.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 2a89103 dist : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/2a89103f4984d8970f3855284c8c04e6e6a63c0f 2a89103 path : /var/www/com-ipkom-abi2le/vendor/gedmo/doctrine-extensions names : gedmo/doctrine-extensions

support
email : [email protected]
issues : https://github.com/doctrine-extensions/DoctrineExtensions/issues
source : https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.15.0
wiki : https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc

autoload
psr-4
Gedmo\ => src/

requires
behat/transliterator ^1.2
doctrine/collections ^1.2 || ^2.0
doctrine/common ^2.13 || ^3.0
doctrine/deprecations ^1.0
doctrine/event-manager ^1.2 || ^2.0
doctrine/persistence ^2.2 || ^3.0
php ^7.4 || ^8.0
psr/cache ^1 || ^2 || ^3
psr/clock ^1
symfony/cache ^5.4 || ^6.0 || ^7.0

requires (dev)
doctrine/annotations ^1.13 || ^2.0
doctrine/cache ^1.11 || ^2.0
doctrine/dbal ^3.2
doctrine/doctrine-bundle ^2.3
doctrine/mongodb-odm ^2.3
doctrine/orm ^2.14.0
friendsofphp/php-cs-fixer ^3.14.0
nesbot/carbon ^2.71 || ^3.0
phpstan/phpstan ^1.10.2
phpstan/phpstan-doctrine ^1.0
phpstan/phpstan-phpunit ^1.0
phpunit/phpunit ^9.6
rector/rector ^0.19
symfony/console ^5.4 || ^6.0 || ^7.0
symfony/phpunit-bridge ^6.0 || ^7.0
symfony/yaml ^5.4 || ^6.0 || ^7.0

suggests
doctrine/mongodb-odm to use the extensions with the MongoDB ODM
doctrine/orm to use the extensions with the ORM

conflicts
doctrine/annotations <1.13 || >=3.0
doctrine/dbal <3.2 || >=4.0
doctrine/mongodb-odm <2.3 || >=3.0
doctrine/orm <2.14.0 || 2.16.0 || 2.16.1 || >=3.0

Doctrine packages

show

Direct dependencies required in composer.json: doctrine/annotations 2.0.1 2.0.1 Docblock Annotations Parser doctrine/doctrine-bundle 2.12.0 2.12.0 Symfony DoctrineBundle doctrine/doctrine-migrations-bundle 3.3.0 3.3.0 Symfony DoctrineMigrationsBundle doctrine/mongodb-odm-bundle 5.0.1 5.0.1 Symfony Doctrine MongoDB Bundle doctrine/orm 2.19.4 3.1.2 Object-Relational-Mapper for PHP

Transitive dependencies not required in composer.json:
doctrine/cache 2.2.0 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongod...
doctrine/collections 2.2.2 2.2.2 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common 3.4.4 3.4.4 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better ...
doctrine/dbal 3.8.3 4.0.1 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations 1.1.3 1.1.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for ...
doctrine/event-manager 2.0.0 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.10 2.0.10 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural for...
doctrine/instantiator 2.0.0 2.0.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer 3.0.1 3.0.1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations 3.7.4 3.7.4 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your dat...
doctrine/mongodb-odm 2.7.0 2.7.0 PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.
doctrine/persistence 3.3.2 3.3.2 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter 1.2.0 1.2.0 a PHP SQL highlighting library

PHP version

8.2.7

Subject

I've a document call "Category" with a property "path" defined as "Gedmo\TreePath". When I insert a new document (category), the "path" value doesn't exist. But when I update the same category, the "path" value is generated. Is the right behaviour?
Because the (documentation) reports that it is generated upon saving, no matter whether it is insert or update.

Steps to reproduce

Create a document with
#[Gedmo\Tree(type: "materializedPath", activateLocking: true)]

Define a property
#[MongoDB\Field(type: Type::STRING)]
#[Gedmo\TreePathSource]
#[Serializer\Groups(groups: ['default'])]
private $name;

#[MongoDB\Field(type: Type::STRING)]
#[Gedmo\TreePath(separator: '|'/* , appendId: true */)]
#[Serializer\Groups(groups: ['default'])]
private $path;

Expected results

The result reports in documentation:

{
  "_id": {
    "$oid": "6627dcce4ef5166cc70efef2"
  },
  "name": "TEST",
  "parent": {
    "$ref": "categories",
    "$id": {
      "$oid": "6627dcce4ef5166cc70efef1"
    },
    "_doctrine_class_name": "App\\Document\\Category"
  },
  "level": 1,
  "integration_id": 1,
  "path": "TEST|6627dcce4ef5166cc70efef1"
}

Actual results

{
  "_id": {
    "$oid": "6627dcce4ef5166cc70efef2"
  },
  "name": "TEST",
  "parent": {
    "$ref": "categories",
    "$id": {
      "$oid": "6627dcce4ef5166cc70efef1"
    },
    "_doctrine_class_name": "App\\Document\\Category"
  },
  "level": 1,
  "integration_id": 1
}

Thanks in advance for the replies.
Regards.

@mbabker
Copy link
Contributor

mbabker commented Apr 24, 2024

I don't use MongoDB but this might be similar to or hitting the same issue as the test failures I'm getting with doctrine/mongodb-odm 2.7 installed in #2781 (which based on the comments on that PR might be an upstream bug, but I wouldn't have an idea how to break it down to a simpler scenario to report there).

@franmomu franmomu linked a pull request Jun 9, 2024 that will close this issue
@franmomu
Copy link
Collaborator

franmomu commented Jun 9, 2024

@filmen thanks for reporting and sorry for taking so long, can you please try with the main branch? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants