Jump to content
thirty bees forum

What is the function of the trigger controller?


Recommended Posts

Posted

What is the function of the triggercontroller?

When I load a product page I see that a call is made to index.php?controller=trigger&ts=1677152722

What is returned is {"status":"failed","error":"Forbidden"}

When I look into the source code I see something about a scheduler but that doesn't make things much clearer. The line "ServiceLocator::getInstance()->getScheduler();" gives me nightmares about Symfony style complexity.

Posted
10 minutes ago, musicmaster said:

What is the function of the triggercontroller?

When I load a product page I see that a call is made to index.php?controller=trigger&ts=1677152722

What is returned is {"status":"failed","error":"Forbidden"}

It's a synthetic event to trigger scheduler. To run scheduled and deferred tasks. 

In ideal deployment, this would not be needed, because scheduler events would be triggered by cron or external process. That's not realistic for small shops, so it's emulated using this synthetic events.

10 minutes ago, musicmaster said:

When I look into the source code I see something about a scheduler but that doesn't make things much clearer. The line "ServiceLocator::getInstance()->getScheduler();" gives me nightmares about Symfony style complexity.

Tell me you have never wrote a test without telling me you have never wrote a test.

Posted
43 minutes ago, datakick said:

It's a synthetic event to trigger scheduler. To run scheduled and deferred tasks.

But what does that "failed"/"forbidden" reaction that I see mean for the functioning of my webshop?

Posted

What tb version are you using? In 1.3, this issue was caused by CORS preflight requests.

Not a critical issue, because trigger was executed during preflight request. Fixed anyway.

  • 2 years later...
Posted

I want to bring this question up again. I recently migrated to TB 1.6.

POST /index.php?controller=trigger&ts=XXX is the only request on our shop front end, where a file with .php file extension is directly executed. This causes issues with our security engine, which does not allow to directly call a .php - file.

Question:
Would it be possible to execute the trigger from server side directly via cron?
If so, what would be the URI to call?

Posted
33 minutes ago, Scully said:

Would it be possible to execute the trigger from server side directly via cron?

With some custom modifications/overrides it's possible.

Easier solution is to go to Preferences > SEO & URLs , click on Add new Page, and define friendly url for this controller.

image.png.246ac7d574e4b5d7870375237abaf758.png

With this in place, your store will use friendly url for this controller instead of direct php call:

image.png.4d2c11a6e3689e29b3571ae4c491c4c9.png

 

  • 1 year later...
Posted

...once again,  how to fix this with PHP 8.1  ?  Please help  @datakick

Is that simply sufficient?

in  /controllers/front/TriggerController.php

// BEFORE:
trigger_error("Attempt to update unsaved object", 512);

// AFTER:
@trigger_error("Attempt to update unsaved object", 512);

 

Posted
12 hours ago, DRMasterChief said:

...once again,  how to fix this with PHP 8.1  ?  Please help  @datakick

Is that simply sufficient?

in  /controllers/front/TriggerController.php

// BEFORE:
trigger_error("Attempt to update unsaved object", 512);

// AFTER:
@trigger_error("Attempt to update unsaved object", 512);

 

I'm not sure what is the question. There is no

trigger_error(...)

in TriggerController.

Posted (edited)

But you get this error with 'php collect module' very often in error logs:

This occurs after an admin login and logout, when an item is subsequently searched for in the front office (at least, that is how I was able to reproduce the error).

 

Stacktrace

#0  builtin
#1  classes/ObjectModel.php(752): trigger_error("Attempt to update unsaved object", 512)
#2  classes/Cart.php(2809): ObjectModelCore->update(false)
#3  classes/controller/FrontController.php(1437): CartCore->update()
#4  classes/controller/Controller.php(192): FrontControllerCore->init()
#5  classes/controller/FrontController.php(264): ControllerCore->run()
#6  classes/Dispatcher.php(858): FrontControllerCore->run()
#7  index.php(33): DispatcherCore->dispatch()

HTTP Request

POST /de/index.php?controller=trigger&ts=1772887354
Edited by DRMasterChief
Posted

This Attempt to update unsaved object warning message exists to alert developers to a code that do something they probably do not expect.

In this case,  FrontController is trying to update Cart object and set language/currency. But because the cart does not exists, that update is silently ignored - nothing is actually saved/updated into database. This is obviously strange situation that needs to be investigated and fixed. In this case, we should can simply add a check that cart exists before we try to do any of this stuff. In a lot of other cases, the fix may be much more complicated.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...