Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ModelAsController wasn't at the top of the stack


Go to End


1423 Views

Avatar
dead_salt

Community Member, 2 Posts

25 November 2013 at 4:38pm

Edited: 25/11/2013 4:40pm

Error:
PHP Warning: popCurrent called on ModelAsController controller, but it wasn't at the top of the stack in /var/www/framework/control/Controller.php on line 447

Stack Trace:
1. {main}() /var/www/framework/main.php:0
2. Director::direct() /var/www/framework/main.php:187
3. Director::handleRequest() /var/www/framework/control/Director.php:119
4. ModelAsController->handleRequest() /var/www/framework/control/Director.php:296
5. Controller->popCurrent() /var/www/cms/code/controllers/ModelAsController.php:77
6. user_error() /var/www/framework/control/Controller.php:447

Hi!

This is my very first post, so bear with me :)

So I have a tricky little problem. In the error log of a client's live site we have been receiving the above error with the accompanying stack trace.
The tricky part is that it seems nearly impossible to recreate it on a local site and machine.

The site is a shop and uses a customised shop module as well as the payments module and the PaymentExpressHostedPayment sub module.

I did some investigating with a recent copy of the site's live database and found that the time that the error was logged was quite reliably a few seconds after the gateway redirected back to the completion page of the order process from the External payment gateway.

I found that it wasn't happening to everyone but it was happening to the did happen a number of times to the same people. It also didn't seem to affect the completion of the order.

The gateway's PaymentExpressHostedPayment_Controller redirects to a CheckoutPage with action 'finish' and an id of the order. So the url looks like this: {web_root}/checkout/finish/{orderID}

I did Google the issue first and it seems that other people who encountered this message had been able to solve it by defining $url_handlers for their controller or adding a function to their $allowed_actions. However the SilverStripe documentation on Controllers stated that $Action/$ID/$OtherID is the standard handler for a controller and since the problematic url conformed to this format and 'finish' is definitely in the $allowed_actions array this solution seemed unlikely.

In addition to this, because the problem refuses to be replicated on a local machine I can't be sure it would solve the issue before pushing it live and monitoring the error logs.

I did some error logging on local and only found that the Controller stack was empty before ModelAsController being pushed to the top and it is empty after ModelAsController is popped from the top.

I was wondering if anyone would be able to help me answering a few questions here:

- Why might it only be occurring on the live site?

- Since it is happening to some people only, and happening more than once to that person, could it be machine or ISP related?

- Is there a chance that pushCurrent() is pushing some other controller to the top of the stack instead of ModelAsController?

- Do Controllers that extend Page_Controller need to have $url_handlers redefined if they still conform to the Standard handler?

Any help would be greatly appreciated and let me know if you need me to provide more information.
Thanks!