Browse Source

Ensure the class has a constructor

if there is no constructor (this means a model which does not inherit
from Model) newInstance will throw an exception.

Conflicts:

	lib/Cake/Utility/ClassRegistry.php
AD7six 14 years ago
parent
commit
b8598c5ca0
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/Cake/Utility/ClassRegistry.php

+ 5 - 1
lib/Cake/Utility/ClassRegistry.php

@@ -158,7 +158,11 @@ class ClassRegistry {
 							}
 						}
 					}
-					$instance = $reflection->newInstance($settings);
+					if ($reflection->getConstructor()) {
+						$instance = $reflection->newInstance($settings);
+					} else {
+						$instance = $reflection->newInstance();
+					}
 					if ($strict) {
 						$instance = ($instance instanceof Model) ? $instance : null;
 					}