a tiny mvc framework for php using php-activerecord
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed a memory leak when using validations

Kien La 975645ef 2a6debf0

+17
+10
lib/php-activerecord/lib/Validations.php
··· 136 136 foreach ($this->validators as $validate) 137 137 $this->$validate($reflection->getStaticPropertyValue($validate)); 138 138 139 + $this->record->clear_model(); 139 140 return $this->record; 140 141 } 141 142 ··· 641 642 public function __construct(Model $model) 642 643 { 643 644 $this->model = $model; 645 + } 646 + 647 + /** 648 + * Nulls $model so we don't get pesky circular references. $model is only needed during the 649 + * validation process and so can be safely cleared once that is done. 650 + */ 651 + public function clear_model() 652 + { 653 + $this->model = null; 644 654 } 645 655 646 656 /**
+7
lib/php-activerecord/test/ValidationsTest.php
··· 114 114 $validators = BookValidations::first()->get_validation_rules(); 115 115 $this->assert_true(in_array(array('validator' => 'validates_presence_of'),$validators['name'])); 116 116 } 117 + 118 + public function test_model_is_nulled_out_to_prevent_memory_leak() 119 + { 120 + $book = new BookValidations(); 121 + $book->is_valid(); 122 + $this->assert_true(strpos(serialize($book->errors),'model";N;') !== false); 123 + } 117 124 }; 118 125 ?>