Skip to main content

Why Are Triggers Called Twice After Content Update?

When processing within a trigger includes logic that meets its own execution conditions, effectively creating a trigger loop, triggers may be called twice. Below, we explain the constraints in Kuroco regarding infinite loops and the reasons for triggers being called twice.

About Infinite Loops

In cases where incorrect implementations such as "calling one's own endpoint within a custom process set for Api::request_api's endpoint" or "calling one's own endpoint in post-processing" occur, related actions are executed continuously, resulting in a program that never terminates. Infinite loops are a serious issue as they increase server load and lead to resource wastage.

Constraints on Loops Configured in APIs

Kuroco has established the following restrictions as a preventive measure against infinite loops:

Prohibition of Requests to One's Own Endpoint

In custom processes, it is not possible to send requests to the endpoint that called itself. This constraint cancels requests to the endpoint and terminates the process in cases such as:

  • Calling one's own endpoint within the custom process set for Api::request_api/Api::request_api_post's endpoint
  • Calling one's own endpoint in pre-processing/post-processing, and so on.

Prohibition of Multi-level APIs

At Kuroco, calling APIs in a nested manner is prohibited. For instance, invoking an API from the {api_internal} plugin, and if {api_internal} is further executed during that API call, it will result in an error.

Trigger-Based Loop Processing

Process Until Loop Termination

When creating a loop based on triggers, for example, if you make an API call to edit content within a trigger after editing the content, the API call in the first trigger is initiated from the admin content editing page. Therefore, it is not subject to the constraints of prohibiting requests to your own endpoint, and content editing via the API is performed, and the second trigger is executed.

In the second trigger, the API call is made from your own endpoint, causing the API request to be canceled, and the loop terminates.

Content Update(Admin panel)

Trigger Execution (1st time)
Content Update API Request (1st time)

Content Update(API)

Trigger Execution (2nd time)
Content Update API Request is canceled due to the constraint

Process Completion

Writing Code to Terminate Trigger Loops in One Execution

To end the execution of triggers in one go when using the trigger after content updates to update content with the same content definition, please include the following code at the beginning of your custom process:

{if $smarty.server.HTTP_RCMS_X_API_REQUEST_CNT > 0}


If you have any other questions, please contact us or check out Our Slack Community.