03.27 php saved
jonnyr
Tags add more
afterFind, infinite and recursion  
Note
afterFind() is causing infinite recursion as getFilePath() performs a field() lookup.
  1. function afterFind($results)
  2. {
  3.     if (isset($results[$i]['Media'])
  4.     {
  5.         // Will cause the recursion.
  6.         $results[$i]['Media']['path'] = $this->getFilePath();
  7.     }
  8. }
  9.  
  10. // Look up Absolute Path to file based on Project Model.
  11. public function getFilePath()
  12. {
  13.     // triggers afterFind() again, infinite loop time
  14.     $this->Project->id = $this->field('project_id');
  15.     return Configure::read('mediamanager.storage_dir').$this->Project->getStoragePath().$this->getFilename();
  16. }
Parsed in 0.025 seconds, using GeSHi 1.0.7.14

Modify this Paste