Skip to content

Commit

Permalink
Ensure the class has a constructor
Browse files Browse the repository at this point in the history
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
AD7six committed Jan 9, 2012
1 parent 0be71a0 commit b8598c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Cake/Utility/ClassRegistry.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit b8598c5

Please sign in to comment.