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

REST API PUT /contacts/{id}: update called with notrigger = 1 #29594

Closed
atm-florianm opened this issue May 3, 2024 · 1 comment
Closed

REST API PUT /contacts/{id}: update called with notrigger = 1 #29594

atm-florianm opened this issue May 3, 2024 · 1 comment
Labels
Bug This is a bug (something does not work as expected)

Comments

@atm-florianm
Copy link
Contributor

atm-florianm commented May 3, 2024

Bug

Currently, the API endpoint for contact update bypasses triggers (notrigger = 1).

The same is true for some other PUT endpoints (thirdparty for instance), but not all (contract, BOM, proposal, anything made with ModuleBuilder, etc.).

[edit] I was wrong about thirdparty because Societe::update's 3rd parameter is $call_trigger and not $notrigger as is usually the case. So the 3rd parameter is 1 but it does call the trigger. If the endpoint PUT /contacts/{id} was copy-pasted from the third party API, it could explain this issue because this detail is easy to overlook (I'm a good example of that).

I assume this is on purpose, but I can't find the reason why, and it is inconsinstent (why notrigger for updating and not for creating, why some objects and not others).

We are developing a feature using triggers to change information whenever a contact is created or updated, but because of this notrigger, we can't make it work in APIs.

Dolibarr Version

17.0, 18.0, 19.0, develop, …

Environment PHP

any

Environment Database

No response

Steps to reproduce the behavior and expected behavior

  1. Implement triggers CONTACT_MODIFY and CONTACT_CREATE (let's say they both do the same: they concatenate "elloworld" to the lastname of the contact)
  2. create a contact with lastname "h" using Dolibarr interface →OK, its name is "helloworld"
  3. edit the contact with lastname "h" using Dolibarr interface → OK, its name is "helloworld"
  4. create a contact with lastname "h" using Dolibarr API POST /contacts → OK, its name is "helloworld"
  5. update a contact with lastname "h"using Dolibarr API PUT /contacts/{id} → KO (its is still "h")

Attached files

No response

@atm-florianm atm-florianm added the Bug This is a bug (something does not work as expected) label May 3, 2024
atm-florianm added a commit to ATM-Consulting/dolibarr that referenced this issue May 3, 2024
atm-florianm added a commit to ATM-Consulting/dolibarr that referenced this issue May 3, 2024
…tion if update returns < 0

+ FIX some PHPDoc (types and throws)
+ FIX issue Dolibarr#29594: trigger should be called on contact update by API
eldy pushed a commit that referenced this issue May 3, 2024
…tion if update returns < 0 (#29596)

+ FIX some PHPDoc (types and throws)
+ FIX issue #29594: trigger should be called on contact update by API
@atm-florianm
Copy link
Contributor Author

solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

1 participant