From 7391081d8165b2906de182469ce0fc98d67f993a Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 7 Oct 2007 23:36:28 +0000 Subject: [PATCH] fixed fatal method delegation bug --- lib/Doctrine/Record.php | 8 +++----- lib/Doctrine/Table.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index c3977757d..2ad81b807 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1597,16 +1597,14 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count */ public function __call($method, $args) { - static $methods = array(); - if ( isset( $methods[$method])) { - $template = $methods[$method]; + if (($template = $this->_table->getMethodOwner($method)) !== false) { $template->setInvoker($this); - return call_user_func_array( array($template, $method ), $args); + return call_user_func_array(array($template, $method), $args); } foreach ($this->_table->getTemplates() as $template) { if (method_exists($template, $method)) { $template->setInvoker($this); - $methods[$method] = $template; + $this->_table->setMethodOwner($method, $template); return call_user_func_array(array($template, $method), $args); } diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 4337f03dd..94450284a 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -162,6 +162,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable * @var array $_filters an array containing all record filters attached to this table */ protected $_filters = array(); + + protected $_invokedMethods = array(); @@ -295,6 +297,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $this->_filters[] = new Doctrine_Record_Filter_Standard(); $this->_repository = new Doctrine_Table_Repository($this); } + public function getMethodOwner($method) + { + return (isset($this->_invokedMethods[$method])) ? + $this->_invokedMethods[$method] : false; + } + + public function setMethodOwner($method, $class) + { + $this->_invokedMethods[$method] = $class; + } /** * getTemplates * returns all templates attached to this table