Permalink
Browse files

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
  • Loading branch information...
1 parent 0be71a0 commit b8598c5ca03f6cadc2076d0dba543b37e3cfefc5 @AD7six AD7six committed Jan 9, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/Cake/Utility/ClassRegistry.php
@@ -158,7 +158,11 @@ public static function init($class, $strict = false) {
}
}
}
- $instance = $reflection->newInstance($settings);
+ if ($reflection->getConstructor()) {
+ $instance = $reflection->newInstance($settings);
+ } else {
+ $instance = $reflection->newInstance();
+ }
if ($strict) {
$instance = ($instance instanceof Model) ? $instance : null;
}

0 comments on commit b8598c5

Please sign in to comment.