Skip to content

Commit

Permalink
prevent calling the bootable trait boot method twice (#24556)
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid authored and taylorotwell committed Jun 12, 2018
1 parent 030956e commit 3162c65
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,15 @@ protected static function bootTraits()
{
$class = static::class;

$booted = [];

foreach (class_uses_recursive($class) as $trait) {
if (method_exists($class, $method = 'boot'.class_basename($trait))) {
$method = 'boot'.class_basename($trait);

if (method_exists($class, $method) && ! in_array($method, $booted)) {
forward_static_call([$class, $method]);

$booted[] = $method;
}
}
}
Expand Down

0 comments on commit 3162c65

Please sign in to comment.