From 5ba3a917415c9991c8a6248c59aa4a0128dcaa9f Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Sun, 8 Nov 2009 21:53:57 +0000 Subject: [PATCH] BUGFIX: Use Director::get_current_page() rather than Controller::curr() in Widget_Controller->Link() to avoid infinite loops when the widget controller is handling a request. From: Andrew Short git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90978 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- widgets/Widget.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/widgets/Widget.php b/widgets/Widget.php index 965798778..6b6797c84 100755 --- a/widgets/Widget.php +++ b/widgets/Widget.php @@ -155,9 +155,13 @@ class Widget_Controller extends Controller { } public function Link($action = null) { - return Controller::curr()->Link ( - Controller::join_links('widget', ($this->widget ? $this->widget->ID : null), $action) - ); + $segment = Controller::join_links('widget', ($this->widget ? $this->widget->ID : null), $action); + + if(Director::get_current_page()) { + return Director::get_current_page()->Link($segment); + } else { + return Controller::curr()->Link($segment); + } } /**