Permalink
Browse files

MINOR fix call to undefined method when a virtual page picks up the w…

…rong object. (from r97875)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102540 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 7312699 commit 279031cc3ab5b6be4724aa803202adc0c14de967 @chillu chillu committed Apr 12, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 core/model/VirtualPage.php
View
8 core/model/VirtualPage.php
@@ -316,7 +316,7 @@ function loadcontentall() {
}
/**
- * Also check the original objects' original controller for the method
+ * Also check the original object's original controller for the method
*
* @param string $method
* @return bool
@@ -347,7 +347,11 @@ function __call($method, $args) {
// if the exception isn't a 'no method' error, rethrow it
if ($e->getCode() !== 2175) throw $e;
$original = $this->copyContentFrom();
- return call_user_func_array(array($original, $method), $args);
+ $originalClass = get_class($original);
+ if ($originalClass == 'SiteTree') $name = 'ContentController';
+ else $name = $originalClass."_Controller";
+ $controller = new $name($this->dataRecord->copyContentFrom());
+ return call_user_func_array(array($controller, $method), $args);
}
}
}

0 comments on commit 279031c

Please sign in to comment.