#6164: Allow association afterFind to be skipped ------------------------------------------------------------+--------------- Reporter: maular | Type: Enhancement Status: new | Priority: Medium Milestone: 1.2.x.x | Component: Model Version: 1.2 Final | Severity: Normal Keywords: dbo_source filter afterFind __filterResults | Php_version: n/a Cake_version: r8074 | ------------------------------------------------------------+--------------- Currently a query can skip the before and after filters for the primary model, using the 'callbacks' parameter:
{{{ // only the beforeFind runs, not the afterFind $this->Post->find('all', array('callbacks'=>'before')); }}} However, this only applies to the primary model - in the case above the Post->User association will have its afterFind run, as this happens in dbo_source.php rather than model.php. [[BR]] [[BR]] It would be advantageous for this setting to apply to associations too - in optimizing our application we have found instances where query time is reduced by 80% by this. Attached is a patch to the latest 1.2.x revision 8074. With this my core model tests pass the same as before (I get a half dozen failures either way). {{{ Index: dbo_source.php =================================================================== --- dbo_source.php (revision 8074) +++ dbo_source.php (working copy) @@ -640,8 +640,10 @@ return false; } - $filtered = $this->__filterResults($resultSet, $model); - + if (!array_key_exists('callbacks', $queryData) || $queryData['callbacks'] === true || $queryData['callbacks'] === 'after') { + $filtered = $this->__filterResults($resultSet, $model); + } + if ($model->recursive > 0) { foreach ($model->__associations as $type) { foreach ($model->{$type} as $assoc => $assocData) { @@ -664,7 +666,9 @@ } } } - $this->__filterResults($resultSet, $model, $filtered); + if (!array_key_exists('callbacks', $queryData) || $queryData['callbacks'] === true || $queryData['callbacks'] === 'after') { + $this->__filterResults($resultSet, $model, $filtered); + } } if (!is_null($recursive)) { }}} -- Ticket URL: <https://trac.cakephp.org/ticket/6164> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---