Skip to content

Commit

Permalink
Fix CakeDC#147 Don't activate if table is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
inigoflores committed Nov 2, 2015
1 parent e9a3261 commit 03637fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contributing
============

This repository follows the [CakeDC Plugin Standard](http://cakedc.com/plugins). If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our [Contribution Guidelines](http://cakedc.com/plugins) for detailed instructions.
This repository follows the [CakeDC Plugin Standard](http://cakedc.com/plugin-standard). If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our [Contribution Guidelines](http://cakedc.com/plugins) for detailed instructions.
14 changes: 7 additions & 7 deletions Model/Behavior/SoftDeleteBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class SoftDeleteBehavior extends ModelBehavior {
* @param array $settings
*/
public function setup(Model $model, $settings = array()) {
//Issue #147: Don't activate behavior if table is not found. Prevents unit tests from failing
try{
$model->setSource($model->table);
} catch (MissingTableException $e) {
return;
}

if (empty($settings)) {
$settings = $this->default;
} elseif (!is_array($settings)) {
Expand Down Expand Up @@ -346,13 +353,6 @@ protected function _softDeleteAssociations(Model $model, $active) {
$parentModels = array_keys($model->belongsTo);

foreach ($parentModels as $parentModel) {
list($plugin, $modelClass) = pluginSplit($parentModel, true);
App::uses($modelClass, $plugin . 'Model');
if (!class_exists($modelClass)) {
throw new MissingModelException(array('class' => $modelClass));
}
$model->{$parentModel} = new $parentModel(null, null, $model->useDbConfig);

foreach (array('hasOne', 'hasMany') as $assocType) {
if (empty($model->{$parentModel}->{$assocType})) {
continue;
Expand Down

0 comments on commit 03637fd

Please sign in to comment.