Coder Social home page Coder Social logo

Comments (8)

dunglas avatar dunglas commented on June 11, 2024

Hi,

This will be hard to investigate without a reproducer, or at least more details (DBMS, entities, indexes...).

If it is urgent, feel free to send a mail at [email protected] to hire an expert from our team. I'm sure that it will resolve the issue quickly.

from api-platform.

soyuka avatar soyuka commented on June 11, 2024

The property filter is adding attributes to the serialization context dynamically, my first guess is that something is happening in the cache. Try to add attributes at https://github.com/api-platform/core/blob/8e3a488103a51becd9c900ec5a3849b806121fbf/src/Serializer/CacheKeyTrait.php#L36 ? We're missing a lot of informations though:

  • content type? are you using jsonld or json ?
  • usage of the security option with the property filter
  • does the problem occurs with or without authentication ?

Please provide a reproducer at the email from the above message.

from api-platform.

simon-fa avatar simon-fa commented on June 11, 2024

Hello, we're using jsonld and the problem occurs with authentication.

What's absolutely crazy is that if I download the db and all configuration files and I start our app on my computer with exactly the same environment as production, it works well…

I tried to clear cache in production... Nothing.

In IGNORED_ATTRIBUTES, I should add attributes I don't want to cache ?

from api-platform.

soyuka avatar soyuka commented on June 11, 2024

In fact it's not the fix as they are present in the $context. Not sure what's going on.

from api-platform.

simon-fa avatar simon-fa commented on June 11, 2024

I contacted Les Tilleuls this morning, waiting for an answer...

I hope someone can help me there.

from api-platform.

simon-fa avatar simon-fa commented on June 11, 2024

Could it be due to the fact that my database is still a postgre 13 ?

from api-platform.

simon-fa avatar simon-fa commented on June 11, 2024

We have probably made some progress in resolving the issue.

After further tests, we were finally able to reproduce the error in a dev env.

So we abandoned the track of the prod env problem.

In desperation, we tried to undo all the work we did to organize nicely our routes and filters into dedicated YAML files for each entity, to put it back in the PHP file, like it was at the origin.

On the tested entities, the bug of the erratic property filters disappeared…

But I can't wrap my head around it… How can it create such an incomprehensible bug ?

from api-platform.

simon-fa avatar simon-fa commented on June 11, 2024

We undid all this work and put it back in api/src/Entity/Marketing/Campaign.php

`
#api/config/api_platform/marketing/campaign.yaml

resources:
App\Entity\Marketing\Campaign:
operations:
# collectionOperations

        ApiPlatform\Metadata\GetCollection:
            filters:
                [
                    "campaign.search_filter",
                    "campaign.boolean_filter",
                    "campaign.order_filter",
                    "entity.property_filter",
                ]

        # itemOperations
        get_campaign:
            class: ApiPlatform\Metadata\Get
            method: GET
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role')"
            securityMessage: "Access Denied."

        patch_campaign:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role')"
            securityMessage: "Access Denied."

        ApiPlatform\Metadata\Delete:
            security: "is_granted('ROLE_role')"
            securityMessage: "Access Denied."

        # workflow

        re_deploy_campaign_in_ghl:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role')"
            securityMessage: "Access Denied."

        boss_acceptation:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "(is_granted('ROLE_role') and user in object.getBusiness().getUsers().getValues()) or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        send_draft:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "(is_granted('ROLE_role') and user in object.getBusiness().getUsers().getValues()) or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        geek_validation:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role') or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        another_geek_validation:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role') or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        another_geek_rejection:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "is_granted('ROLE_role') or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        boss_rejection:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "(is_granted('ROLE_role') and user in object.getBusiness().getUsers().getValues()) or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        cancel:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "(is_granted('ROLE_role') and user in object.getBusiness().getUsers().getValues()) or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

        change_mind:
            class: ApiPlatform\Metadata\Patch
            method: PATCH
            uriTemplate: the_route
            controller: the_controller
            security: "(is_granted('ROLE_role') and user in object.getBusiness().getUsers().getValues()) or is_granted('ROLE_role')"
            securityMessage: "Acces Denied"

    denormalizationContext:
        groups: ["write:coach"]

properties:
App\Entity\Marketing\Campaign:
id: ~
name: ~
isActive: ~
dateFrom: ~
dateTo: ~
eventDateTo: ~
eventDateFrom: ~
passVIPduration: ~
budgetAmount: ~
budgetType: ~
offerDescription: ~
prizeDescription: ~
video: ~
guarantee: ~
broadcasts: ~
emailAutomatisms: ~
fbTitles: ~
fbCall2Actions: ~
fbMedias: ~
fbTexts: ~
wcScript: ~
wcPreviewLink: ~
followUpScenari: ~
followUpScript: ~
state: ~
reasonOfRefusal: ~
usersWhoApprove: ~
usersWhoRefuse: ~

    # ghl
    ghlTeamId:
        security: 'is_granted("ROLE_role") or is_granted("ROLE_role")'
    ghlTeam:
        security: 'is_granted("ROLE_role") or is_granted("ROLE_role")'

    # relation
    offer: ~
    services: ~
    marketingPlan: ~
    business: ~

`

`
#api/config/filter/marketing/campaign_filters.yaml

services:

campaign.search_filter:
    parent: 'api_platform.doctrine.orm.search_filter'
    arguments: [ {
        business.id: 'exact',
        business.name: 'ipartial',
        marketingPlan.id: 'exact',
        marketingPlan.isPermanent: 'exact',
        name: 'ipartial',
        state: 'exact',
    } ]
    tags:  [ 'api_platform.filter' ]

campaign.boolean_filter:
    parent: 'api_platform.doctrine.orm.boolean_filter'
    arguments: [ {
        isActive: 'exact',
    } ]
    tags:  [ 'api_platform.filter' ]

campaign.order_filter:
    parent: 'api_platform.doctrine.orm.order_filter'
    arguments:
        $properties: {
            id: ~,
            business.name: ~,
            dateFrom: ~,
            dateTo: ~,
        }
        $orderParameterName: order
    tags:  [ 'api_platform.filter' ]

`

from api-platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.